documentation.d.ts 3.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623
  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 mip = nearest */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  774. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** nearest is mag = nearest and min = nearest and mip = linear */
  778. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: 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. /** mag = nearest and min = nearest and mip = none */
  792. static readonly TEXTURE_NEAREST_NEAREST: 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. /** mag = linear and min = linear and mip = none */
  798. static readonly TEXTURE_LINEAR_LINEAR: 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 usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9238. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9239. */
  9240. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9241. /**
  9242. * Binds the lights information from the scene to the effect for the given mesh.
  9243. * @param scene The scene the lights belongs to
  9244. * @param mesh The mesh we are binding the information to render
  9245. * @param effect The effect we are binding the data to
  9246. * @param defines The generated defines for the effect
  9247. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9248. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9249. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9250. */
  9251. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9252. private static _tempFogColor;
  9253. /**
  9254. * Binds the fog information from the scene to the effect for the given mesh.
  9255. * @param scene The scene the lights belongs to
  9256. * @param mesh The mesh we are binding the information to render
  9257. * @param effect The effect we are binding the data to
  9258. * @param linearSpace Defines if the fog effect is applied in linear space
  9259. */
  9260. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9261. /**
  9262. * Binds the bones information from the mesh to the effect.
  9263. * @param mesh The mesh we are binding the information to render
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9267. /**
  9268. * Binds the morph targets information from the mesh to the effect.
  9269. * @param abstractMesh The mesh we are binding the information to render
  9270. * @param effect The effect we are binding the data to
  9271. */
  9272. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9273. /**
  9274. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9275. * @param defines The generated defines used in the effect
  9276. * @param effect The effect we are binding the data to
  9277. * @param scene The scene we are willing to render with logarithmic scale for
  9278. */
  9279. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9280. /**
  9281. * Binds the clip plane information from the scene to the effect.
  9282. * @param scene The scene the clip plane information are extracted from
  9283. * @param effect The effect we are binding the data to
  9284. */
  9285. static BindClipPlane(effect: Effect, scene: Scene): void;
  9286. }
  9287. }
  9288. declare module BABYLON {
  9289. /** @hidden */
  9290. export var packingFunctions: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module BABYLON {
  9296. /** @hidden */
  9297. export var shadowMapPixelShader: {
  9298. name: string;
  9299. shader: string;
  9300. };
  9301. }
  9302. declare module BABYLON {
  9303. /** @hidden */
  9304. export var bonesDeclaration: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module BABYLON {
  9310. /** @hidden */
  9311. export var morphTargetsVertexGlobalDeclaration: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module BABYLON {
  9317. /** @hidden */
  9318. export var morphTargetsVertexDeclaration: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module BABYLON {
  9324. /** @hidden */
  9325. export var instancesDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module BABYLON {
  9331. /** @hidden */
  9332. export var helperFunctions: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module BABYLON {
  9338. /** @hidden */
  9339. export var morphTargetsVertex: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module BABYLON {
  9345. /** @hidden */
  9346. export var instancesVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module BABYLON {
  9352. /** @hidden */
  9353. export var bonesVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module BABYLON {
  9359. /** @hidden */
  9360. export var shadowMapVertexShader: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module BABYLON {
  9366. /** @hidden */
  9367. export var depthBoxBlurPixelShader: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module BABYLON {
  9373. /**
  9374. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9375. */
  9376. export interface ICustomShaderOptions {
  9377. /**
  9378. * Gets or sets the custom shader name to use
  9379. */
  9380. shaderName: string;
  9381. /**
  9382. * The list of attribute names used in the shader
  9383. */
  9384. attributes?: string[];
  9385. /**
  9386. * The list of unifrom names used in the shader
  9387. */
  9388. uniforms?: string[];
  9389. /**
  9390. * The list of sampler names used in the shader
  9391. */
  9392. samplers?: string[];
  9393. /**
  9394. * The list of defines used in the shader
  9395. */
  9396. defines?: string[];
  9397. }
  9398. /**
  9399. * Interface to implement to create a shadow generator compatible with BJS.
  9400. */
  9401. export interface IShadowGenerator {
  9402. /**
  9403. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9404. * @returns The render target texture if present otherwise, null
  9405. */
  9406. getShadowMap(): Nullable<RenderTargetTexture>;
  9407. /**
  9408. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9409. * @returns The render target texture if the shadow map is present otherwise, null
  9410. */
  9411. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9412. /**
  9413. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9414. * @param subMesh The submesh we want to render in the shadow map
  9415. * @param useInstances Defines wether will draw in the map using instances
  9416. * @returns true if ready otherwise, false
  9417. */
  9418. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9419. /**
  9420. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9421. * @param defines Defines of the material we want to update
  9422. * @param lightIndex Index of the light in the enabled light list of the material
  9423. */
  9424. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9425. /**
  9426. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9427. * defined in the generator but impacting the effect).
  9428. * It implies the unifroms available on the materials are the standard BJS ones.
  9429. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9430. * @param effect The effect we are binfing the information for
  9431. */
  9432. bindShadowLight(lightIndex: string, effect: Effect): void;
  9433. /**
  9434. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9435. * (eq to shadow prjection matrix * light transform matrix)
  9436. * @returns The transform matrix used to create the shadow map
  9437. */
  9438. getTransformMatrix(): Matrix;
  9439. /**
  9440. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9441. * Cube and 2D textures for instance.
  9442. */
  9443. recreateShadowMap(): void;
  9444. /**
  9445. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9446. * @param onCompiled Callback triggered at the and of the effects compilation
  9447. * @param options Sets of optional options forcing the compilation with different modes
  9448. */
  9449. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9450. useInstances: boolean;
  9451. }>): void;
  9452. /**
  9453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9454. * @param options Sets of optional options forcing the compilation with different modes
  9455. * @returns A promise that resolves when the compilation completes
  9456. */
  9457. forceCompilationAsync(options?: Partial<{
  9458. useInstances: boolean;
  9459. }>): Promise<void>;
  9460. /**
  9461. * Serializes the shadow generator setup to a json object.
  9462. * @returns The serialized JSON object
  9463. */
  9464. serialize(): any;
  9465. /**
  9466. * Disposes the Shadow map and related Textures and effects.
  9467. */
  9468. dispose(): void;
  9469. }
  9470. /**
  9471. * Default implementation IShadowGenerator.
  9472. * This is the main object responsible of generating shadows in the framework.
  9473. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9474. */
  9475. export class ShadowGenerator implements IShadowGenerator {
  9476. /**
  9477. * Shadow generator mode None: no filtering applied.
  9478. */
  9479. static readonly FILTER_NONE: number;
  9480. /**
  9481. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9482. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9483. */
  9484. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9485. /**
  9486. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9487. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9488. */
  9489. static readonly FILTER_POISSONSAMPLING: number;
  9490. /**
  9491. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9492. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9493. */
  9494. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9495. /**
  9496. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9497. * edge artifacts on steep falloff.
  9498. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9499. */
  9500. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9501. /**
  9502. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9503. * edge artifacts on steep falloff.
  9504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9505. */
  9506. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9507. /**
  9508. * Shadow generator mode PCF: Percentage Closer Filtering
  9509. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9510. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9511. */
  9512. static readonly FILTER_PCF: number;
  9513. /**
  9514. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9515. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9516. * Contact Hardening
  9517. */
  9518. static readonly FILTER_PCSS: number;
  9519. /**
  9520. * Reserved for PCF and PCSS
  9521. * Highest Quality.
  9522. *
  9523. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9524. *
  9525. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9526. */
  9527. static readonly QUALITY_HIGH: number;
  9528. /**
  9529. * Reserved for PCF and PCSS
  9530. * Good tradeoff for quality/perf cross devices
  9531. *
  9532. * Execute PCF on a 3*3 kernel.
  9533. *
  9534. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9535. */
  9536. static readonly QUALITY_MEDIUM: number;
  9537. /**
  9538. * Reserved for PCF and PCSS
  9539. * The lowest quality but the fastest.
  9540. *
  9541. * Execute PCF on a 1*1 kernel.
  9542. *
  9543. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9544. */
  9545. static readonly QUALITY_LOW: number;
  9546. /** Gets or sets the custom shader name to use */
  9547. customShaderOptions: ICustomShaderOptions;
  9548. /**
  9549. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9550. */
  9551. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9552. /**
  9553. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9554. */
  9555. onAfterShadowMapRenderObservable: Observable<Effect>;
  9556. /**
  9557. * Observable triggered before a mesh is rendered in the shadow map.
  9558. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9559. */
  9560. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9561. /**
  9562. * Observable triggered after a mesh is rendered in the shadow map.
  9563. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9564. */
  9565. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9566. private _bias;
  9567. /**
  9568. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9569. */
  9570. get bias(): number;
  9571. /**
  9572. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9573. */
  9574. set bias(bias: number);
  9575. private _normalBias;
  9576. /**
  9577. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9578. */
  9579. get normalBias(): number;
  9580. /**
  9581. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9582. */
  9583. set normalBias(normalBias: number);
  9584. private _blurBoxOffset;
  9585. /**
  9586. * Gets the blur box offset: offset applied during the blur pass.
  9587. * Only useful if useKernelBlur = false
  9588. */
  9589. get blurBoxOffset(): number;
  9590. /**
  9591. * Sets the blur box offset: offset applied during the blur pass.
  9592. * Only useful if useKernelBlur = false
  9593. */
  9594. set blurBoxOffset(value: number);
  9595. private _blurScale;
  9596. /**
  9597. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9598. * 2 means half of the size.
  9599. */
  9600. get blurScale(): number;
  9601. /**
  9602. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9603. * 2 means half of the size.
  9604. */
  9605. set blurScale(value: number);
  9606. private _blurKernel;
  9607. /**
  9608. * Gets the blur kernel: kernel size of the blur pass.
  9609. * Only useful if useKernelBlur = true
  9610. */
  9611. get blurKernel(): number;
  9612. /**
  9613. * Sets the blur kernel: kernel size of the blur pass.
  9614. * Only useful if useKernelBlur = true
  9615. */
  9616. set blurKernel(value: number);
  9617. private _useKernelBlur;
  9618. /**
  9619. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9620. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9621. */
  9622. get useKernelBlur(): boolean;
  9623. /**
  9624. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9625. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9626. */
  9627. set useKernelBlur(value: boolean);
  9628. private _depthScale;
  9629. /**
  9630. * Gets the depth scale used in ESM mode.
  9631. */
  9632. get depthScale(): number;
  9633. /**
  9634. * Sets the depth scale used in ESM mode.
  9635. * This can override the scale stored on the light.
  9636. */
  9637. set depthScale(value: number);
  9638. private _filter;
  9639. /**
  9640. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9641. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9642. */
  9643. get filter(): number;
  9644. /**
  9645. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9646. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9647. */
  9648. set filter(value: number);
  9649. /**
  9650. * Gets if the current filter is set to Poisson Sampling.
  9651. */
  9652. get usePoissonSampling(): boolean;
  9653. /**
  9654. * Sets the current filter to Poisson Sampling.
  9655. */
  9656. set usePoissonSampling(value: boolean);
  9657. /**
  9658. * Gets if the current filter is set to ESM.
  9659. */
  9660. get useExponentialShadowMap(): boolean;
  9661. /**
  9662. * Sets the current filter is to ESM.
  9663. */
  9664. set useExponentialShadowMap(value: boolean);
  9665. /**
  9666. * Gets if the current filter is set to filtered ESM.
  9667. */
  9668. get useBlurExponentialShadowMap(): boolean;
  9669. /**
  9670. * Gets if the current filter is set to filtered ESM.
  9671. */
  9672. set useBlurExponentialShadowMap(value: boolean);
  9673. /**
  9674. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9675. * exponential to prevent steep falloff artifacts).
  9676. */
  9677. get useCloseExponentialShadowMap(): boolean;
  9678. /**
  9679. * Sets the current filter to "close ESM" (using the inverse of the
  9680. * exponential to prevent steep falloff artifacts).
  9681. */
  9682. set useCloseExponentialShadowMap(value: boolean);
  9683. /**
  9684. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9685. * exponential to prevent steep falloff artifacts).
  9686. */
  9687. get useBlurCloseExponentialShadowMap(): boolean;
  9688. /**
  9689. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9690. * exponential to prevent steep falloff artifacts).
  9691. */
  9692. set useBlurCloseExponentialShadowMap(value: boolean);
  9693. /**
  9694. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9695. */
  9696. get usePercentageCloserFiltering(): boolean;
  9697. /**
  9698. * Sets the current filter to "PCF" (percentage closer filtering).
  9699. */
  9700. set usePercentageCloserFiltering(value: boolean);
  9701. private _filteringQuality;
  9702. /**
  9703. * Gets the PCF or PCSS Quality.
  9704. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9705. */
  9706. get filteringQuality(): number;
  9707. /**
  9708. * Sets the PCF or PCSS Quality.
  9709. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9710. */
  9711. set filteringQuality(filteringQuality: number);
  9712. /**
  9713. * Gets if the current filter is set to "PCSS" (contact hardening).
  9714. */
  9715. get useContactHardeningShadow(): boolean;
  9716. /**
  9717. * Sets the current filter to "PCSS" (contact hardening).
  9718. */
  9719. set useContactHardeningShadow(value: boolean);
  9720. private _contactHardeningLightSizeUVRatio;
  9721. /**
  9722. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9723. * Using a ratio helps keeping shape stability independently of the map size.
  9724. *
  9725. * It does not account for the light projection as it was having too much
  9726. * instability during the light setup or during light position changes.
  9727. *
  9728. * Only valid if useContactHardeningShadow is true.
  9729. */
  9730. get contactHardeningLightSizeUVRatio(): number;
  9731. /**
  9732. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9733. * Using a ratio helps keeping shape stability independently of the map size.
  9734. *
  9735. * It does not account for the light projection as it was having too much
  9736. * instability during the light setup or during light position changes.
  9737. *
  9738. * Only valid if useContactHardeningShadow is true.
  9739. */
  9740. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9741. private _darkness;
  9742. /** Gets or sets the actual darkness of a shadow */
  9743. get darkness(): number;
  9744. set darkness(value: number);
  9745. /**
  9746. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9747. * 0 means strongest and 1 would means no shadow.
  9748. * @returns the darkness.
  9749. */
  9750. getDarkness(): number;
  9751. /**
  9752. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9753. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9754. * @returns the shadow generator allowing fluent coding.
  9755. */
  9756. setDarkness(darkness: number): ShadowGenerator;
  9757. private _transparencyShadow;
  9758. /** Gets or sets the ability to have transparent shadow */
  9759. get transparencyShadow(): boolean;
  9760. set transparencyShadow(value: boolean);
  9761. /**
  9762. * Sets the ability to have transparent shadow (boolean).
  9763. * @param transparent True if transparent else False
  9764. * @returns the shadow generator allowing fluent coding
  9765. */
  9766. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9767. private _shadowMap;
  9768. private _shadowMap2;
  9769. /**
  9770. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9771. * @returns The render target texture if present otherwise, null
  9772. */
  9773. getShadowMap(): Nullable<RenderTargetTexture>;
  9774. /**
  9775. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9776. * @returns The render target texture if the shadow map is present otherwise, null
  9777. */
  9778. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9779. /**
  9780. * Gets the class name of that object
  9781. * @returns "ShadowGenerator"
  9782. */
  9783. getClassName(): string;
  9784. /**
  9785. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9786. * @param mesh Mesh to add
  9787. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9788. * @returns the Shadow Generator itself
  9789. */
  9790. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9791. /**
  9792. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9793. * @param mesh Mesh to remove
  9794. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9795. * @returns the Shadow Generator itself
  9796. */
  9797. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9798. /**
  9799. * Controls the extent to which the shadows fade out at the edge of the frustum
  9800. * Used only by directionals and spots
  9801. */
  9802. frustumEdgeFalloff: number;
  9803. private _light;
  9804. /**
  9805. * Returns the associated light object.
  9806. * @returns the light generating the shadow
  9807. */
  9808. getLight(): IShadowLight;
  9809. /**
  9810. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9811. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9812. * It might on the other hand introduce peter panning.
  9813. */
  9814. forceBackFacesOnly: boolean;
  9815. private _scene;
  9816. private _lightDirection;
  9817. private _effect;
  9818. private _viewMatrix;
  9819. private _projectionMatrix;
  9820. private _transformMatrix;
  9821. private _cachedPosition;
  9822. private _cachedDirection;
  9823. private _cachedDefines;
  9824. private _currentRenderID;
  9825. private _boxBlurPostprocess;
  9826. private _kernelBlurXPostprocess;
  9827. private _kernelBlurYPostprocess;
  9828. private _blurPostProcesses;
  9829. private _mapSize;
  9830. private _currentFaceIndex;
  9831. private _currentFaceIndexCache;
  9832. private _textureType;
  9833. private _defaultTextureMatrix;
  9834. private _storedUniqueId;
  9835. /** @hidden */
  9836. static _SceneComponentInitialization: (scene: Scene) => void;
  9837. /**
  9838. * Creates a ShadowGenerator object.
  9839. * A ShadowGenerator is the required tool to use the shadows.
  9840. * Each light casting shadows needs to use its own ShadowGenerator.
  9841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9843. * @param light The light object generating the shadows.
  9844. * @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.
  9845. */
  9846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9847. private _initializeGenerator;
  9848. private _initializeShadowMap;
  9849. private _initializeBlurRTTAndPostProcesses;
  9850. private _renderForShadowMap;
  9851. private _renderSubMeshForShadowMap;
  9852. private _applyFilterValues;
  9853. /**
  9854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9855. * @param onCompiled Callback triggered at the and of the effects compilation
  9856. * @param options Sets of optional options forcing the compilation with different modes
  9857. */
  9858. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9859. useInstances: boolean;
  9860. }>): void;
  9861. /**
  9862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9863. * @param options Sets of optional options forcing the compilation with different modes
  9864. * @returns A promise that resolves when the compilation completes
  9865. */
  9866. forceCompilationAsync(options?: Partial<{
  9867. useInstances: boolean;
  9868. }>): Promise<void>;
  9869. /**
  9870. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9871. * @param subMesh The submesh we want to render in the shadow map
  9872. * @param useInstances Defines wether will draw in the map using instances
  9873. * @returns true if ready otherwise, false
  9874. */
  9875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9876. /**
  9877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9878. * @param defines Defines of the material we want to update
  9879. * @param lightIndex Index of the light in the enabled light list of the material
  9880. */
  9881. prepareDefines(defines: any, lightIndex: number): void;
  9882. /**
  9883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9884. * defined in the generator but impacting the effect).
  9885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9886. * @param effect The effect we are binfing the information for
  9887. */
  9888. bindShadowLight(lightIndex: string, effect: Effect): void;
  9889. /**
  9890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9891. * (eq to shadow prjection matrix * light transform matrix)
  9892. * @returns The transform matrix used to create the shadow map
  9893. */
  9894. getTransformMatrix(): Matrix;
  9895. /**
  9896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9897. * Cube and 2D textures for instance.
  9898. */
  9899. recreateShadowMap(): void;
  9900. private _disposeBlurPostProcesses;
  9901. private _disposeRTTandPostProcesses;
  9902. /**
  9903. * Disposes the ShadowGenerator.
  9904. * Returns nothing.
  9905. */
  9906. dispose(): void;
  9907. /**
  9908. * Serializes the shadow generator setup to a json object.
  9909. * @returns The serialized JSON object
  9910. */
  9911. serialize(): any;
  9912. /**
  9913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9914. * @param parsedShadowGenerator The JSON object to parse
  9915. * @param scene The scene to create the shadow map for
  9916. * @returns The parsed shadow generator
  9917. */
  9918. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9919. }
  9920. }
  9921. declare module BABYLON {
  9922. /**
  9923. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9924. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9925. * 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.
  9926. */
  9927. export abstract class Light extends Node {
  9928. /**
  9929. * Falloff Default: light is falling off following the material specification:
  9930. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9931. */
  9932. static readonly FALLOFF_DEFAULT: number;
  9933. /**
  9934. * Falloff Physical: light is falling off following the inverse squared distance law.
  9935. */
  9936. static readonly FALLOFF_PHYSICAL: number;
  9937. /**
  9938. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9939. * to enhance interoperability with other engines.
  9940. */
  9941. static readonly FALLOFF_GLTF: number;
  9942. /**
  9943. * Falloff Standard: light is falling off like in the standard material
  9944. * to enhance interoperability with other materials.
  9945. */
  9946. static readonly FALLOFF_STANDARD: number;
  9947. /**
  9948. * If every light affecting the material is in this lightmapMode,
  9949. * material.lightmapTexture adds or multiplies
  9950. * (depends on material.useLightmapAsShadowmap)
  9951. * after every other light calculations.
  9952. */
  9953. static readonly LIGHTMAP_DEFAULT: number;
  9954. /**
  9955. * material.lightmapTexture as only diffuse lighting from this light
  9956. * adds only specular lighting from this light
  9957. * adds dynamic shadows
  9958. */
  9959. static readonly LIGHTMAP_SPECULAR: number;
  9960. /**
  9961. * material.lightmapTexture as only lighting
  9962. * no light calculation from this light
  9963. * only adds dynamic shadows from this light
  9964. */
  9965. static readonly LIGHTMAP_SHADOWSONLY: number;
  9966. /**
  9967. * Each light type uses the default quantity according to its type:
  9968. * point/spot lights use luminous intensity
  9969. * directional lights use illuminance
  9970. */
  9971. static readonly INTENSITYMODE_AUTOMATIC: number;
  9972. /**
  9973. * lumen (lm)
  9974. */
  9975. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9976. /**
  9977. * candela (lm/sr)
  9978. */
  9979. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9980. /**
  9981. * lux (lm/m^2)
  9982. */
  9983. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9984. /**
  9985. * nit (cd/m^2)
  9986. */
  9987. static readonly INTENSITYMODE_LUMINANCE: number;
  9988. /**
  9989. * Light type const id of the point light.
  9990. */
  9991. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9992. /**
  9993. * Light type const id of the directional light.
  9994. */
  9995. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9996. /**
  9997. * Light type const id of the spot light.
  9998. */
  9999. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10000. /**
  10001. * Light type const id of the hemispheric light.
  10002. */
  10003. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10004. /**
  10005. * Diffuse gives the basic color to an object.
  10006. */
  10007. diffuse: Color3;
  10008. /**
  10009. * Specular produces a highlight color on an object.
  10010. * Note: This is note affecting PBR materials.
  10011. */
  10012. specular: Color3;
  10013. /**
  10014. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10015. * falling off base on range or angle.
  10016. * This can be set to any values in Light.FALLOFF_x.
  10017. *
  10018. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10019. * other types of materials.
  10020. */
  10021. falloffType: number;
  10022. /**
  10023. * Strength of the light.
  10024. * Note: By default it is define in the framework own unit.
  10025. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10026. */
  10027. intensity: number;
  10028. private _range;
  10029. protected _inverseSquaredRange: number;
  10030. /**
  10031. * Defines how far from the source the light is impacting in scene units.
  10032. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10033. */
  10034. get range(): number;
  10035. /**
  10036. * Defines how far from the source the light is impacting in scene units.
  10037. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10038. */
  10039. set range(value: number);
  10040. /**
  10041. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10042. * of light.
  10043. */
  10044. private _photometricScale;
  10045. private _intensityMode;
  10046. /**
  10047. * Gets the photometric scale used to interpret the intensity.
  10048. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10049. */
  10050. get intensityMode(): number;
  10051. /**
  10052. * Sets the photometric scale used to interpret the intensity.
  10053. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10054. */
  10055. set intensityMode(value: number);
  10056. private _radius;
  10057. /**
  10058. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10059. */
  10060. get radius(): number;
  10061. /**
  10062. * sets the light radius used by PBR Materials to simulate soft area lights.
  10063. */
  10064. set radius(value: number);
  10065. private _renderPriority;
  10066. /**
  10067. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10068. * exceeding the number allowed of the materials.
  10069. */
  10070. renderPriority: number;
  10071. private _shadowEnabled;
  10072. /**
  10073. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10074. * the current shadow generator.
  10075. */
  10076. get shadowEnabled(): boolean;
  10077. /**
  10078. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10079. * the current shadow generator.
  10080. */
  10081. set shadowEnabled(value: boolean);
  10082. private _includedOnlyMeshes;
  10083. /**
  10084. * Gets the only meshes impacted by this light.
  10085. */
  10086. get includedOnlyMeshes(): AbstractMesh[];
  10087. /**
  10088. * Sets the only meshes impacted by this light.
  10089. */
  10090. set includedOnlyMeshes(value: AbstractMesh[]);
  10091. private _excludedMeshes;
  10092. /**
  10093. * Gets the meshes not impacted by this light.
  10094. */
  10095. get excludedMeshes(): AbstractMesh[];
  10096. /**
  10097. * Sets the meshes not impacted by this light.
  10098. */
  10099. set excludedMeshes(value: AbstractMesh[]);
  10100. private _excludeWithLayerMask;
  10101. /**
  10102. * Gets the layer id use to find what meshes are not impacted by the light.
  10103. * Inactive if 0
  10104. */
  10105. get excludeWithLayerMask(): number;
  10106. /**
  10107. * Sets the layer id use to find what meshes are not impacted by the light.
  10108. * Inactive if 0
  10109. */
  10110. set excludeWithLayerMask(value: number);
  10111. private _includeOnlyWithLayerMask;
  10112. /**
  10113. * Gets the layer id use to find what meshes are impacted by the light.
  10114. * Inactive if 0
  10115. */
  10116. get includeOnlyWithLayerMask(): number;
  10117. /**
  10118. * Sets the layer id use to find what meshes are impacted by the light.
  10119. * Inactive if 0
  10120. */
  10121. set includeOnlyWithLayerMask(value: number);
  10122. private _lightmapMode;
  10123. /**
  10124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10125. */
  10126. get lightmapMode(): number;
  10127. /**
  10128. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10129. */
  10130. set lightmapMode(value: number);
  10131. /**
  10132. * Shadow generator associted to the light.
  10133. * @hidden Internal use only.
  10134. */
  10135. _shadowGenerator: Nullable<IShadowGenerator>;
  10136. /**
  10137. * @hidden Internal use only.
  10138. */
  10139. _excludedMeshesIds: string[];
  10140. /**
  10141. * @hidden Internal use only.
  10142. */
  10143. _includedOnlyMeshesIds: string[];
  10144. /**
  10145. * The current light unifom buffer.
  10146. * @hidden Internal use only.
  10147. */
  10148. _uniformBuffer: UniformBuffer;
  10149. /** @hidden */
  10150. _renderId: number;
  10151. /**
  10152. * Creates a Light object in the scene.
  10153. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10154. * @param name The firendly name of the light
  10155. * @param scene The scene the light belongs too
  10156. */
  10157. constructor(name: string, scene: Scene);
  10158. protected abstract _buildUniformLayout(): void;
  10159. /**
  10160. * Sets the passed Effect "effect" with the Light information.
  10161. * @param effect The effect to update
  10162. * @param lightIndex The index of the light in the effect to update
  10163. * @returns The light
  10164. */
  10165. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10166. /**
  10167. * Sets the passed Effect "effect" with the Light textures.
  10168. * @param effect The effect to update
  10169. * @param lightIndex The index of the light in the effect to update
  10170. * @returns The light
  10171. */
  10172. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10173. /**
  10174. * Binds the lights information from the scene to the effect for the given mesh.
  10175. * @param lightIndex Light index
  10176. * @param scene The scene where the light belongs to
  10177. * @param effect The effect we are binding the data to
  10178. * @param useSpecular Defines if specular is supported
  10179. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10180. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10181. */
  10182. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10183. /**
  10184. * Sets the passed Effect "effect" with the Light information.
  10185. * @param effect The effect to update
  10186. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10187. * @returns The light
  10188. */
  10189. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10190. /**
  10191. * Returns the string "Light".
  10192. * @returns the class name
  10193. */
  10194. getClassName(): string;
  10195. /** @hidden */
  10196. readonly _isLight: boolean;
  10197. /**
  10198. * Converts the light information to a readable string for debug purpose.
  10199. * @param fullDetails Supports for multiple levels of logging within scene loading
  10200. * @returns the human readable light info
  10201. */
  10202. toString(fullDetails?: boolean): string;
  10203. /** @hidden */
  10204. protected _syncParentEnabledState(): void;
  10205. /**
  10206. * Set the enabled state of this node.
  10207. * @param value - the new enabled state
  10208. */
  10209. setEnabled(value: boolean): void;
  10210. /**
  10211. * Returns the Light associated shadow generator if any.
  10212. * @return the associated shadow generator.
  10213. */
  10214. getShadowGenerator(): Nullable<IShadowGenerator>;
  10215. /**
  10216. * Returns a Vector3, the absolute light position in the World.
  10217. * @returns the world space position of the light
  10218. */
  10219. getAbsolutePosition(): Vector3;
  10220. /**
  10221. * Specifies if the light will affect the passed mesh.
  10222. * @param mesh The mesh to test against the light
  10223. * @return true the mesh is affected otherwise, false.
  10224. */
  10225. canAffectMesh(mesh: AbstractMesh): boolean;
  10226. /**
  10227. * Sort function to order lights for rendering.
  10228. * @param a First Light object to compare to second.
  10229. * @param b Second Light object to compare first.
  10230. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10231. */
  10232. static CompareLightsPriority(a: Light, b: Light): number;
  10233. /**
  10234. * Releases resources associated with this node.
  10235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10237. */
  10238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10239. /**
  10240. * Returns the light type ID (integer).
  10241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10242. */
  10243. getTypeID(): number;
  10244. /**
  10245. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10246. * @returns the scaled intensity in intensity mode unit
  10247. */
  10248. getScaledIntensity(): number;
  10249. /**
  10250. * Returns a new Light object, named "name", from the current one.
  10251. * @param name The name of the cloned light
  10252. * @returns the new created light
  10253. */
  10254. clone(name: string): Nullable<Light>;
  10255. /**
  10256. * Serializes the current light into a Serialization object.
  10257. * @returns the serialized object.
  10258. */
  10259. serialize(): any;
  10260. /**
  10261. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10262. * This new light is named "name" and added to the passed scene.
  10263. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10264. * @param name The friendly name of the light
  10265. * @param scene The scene the new light will belong to
  10266. * @returns the constructor function
  10267. */
  10268. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10269. /**
  10270. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10271. * @param parsedLight The JSON representation of the light
  10272. * @param scene The scene to create the parsed light in
  10273. * @returns the created light after parsing
  10274. */
  10275. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10276. private _hookArrayForExcluded;
  10277. private _hookArrayForIncludedOnly;
  10278. private _resyncMeshes;
  10279. /**
  10280. * Forces the meshes to update their light related information in their rendering used effects
  10281. * @hidden Internal Use Only
  10282. */
  10283. _markMeshesAsLightDirty(): void;
  10284. /**
  10285. * Recomputes the cached photometric scale if needed.
  10286. */
  10287. private _computePhotometricScale;
  10288. /**
  10289. * Returns the Photometric Scale according to the light type and intensity mode.
  10290. */
  10291. private _getPhotometricScale;
  10292. /**
  10293. * Reorder the light in the scene according to their defined priority.
  10294. * @hidden Internal Use Only
  10295. */
  10296. _reorderLightsInScene(): void;
  10297. /**
  10298. * Prepares the list of defines specific to the light type.
  10299. * @param defines the list of defines
  10300. * @param lightIndex defines the index of the light for the effect
  10301. */
  10302. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10303. }
  10304. }
  10305. declare module BABYLON {
  10306. /**
  10307. * Interface used to define Action
  10308. */
  10309. export interface IAction {
  10310. /**
  10311. * Trigger for the action
  10312. */
  10313. trigger: number;
  10314. /** Options of the trigger */
  10315. triggerOptions: any;
  10316. /**
  10317. * Gets the trigger parameters
  10318. * @returns the trigger parameters
  10319. */
  10320. getTriggerParameter(): any;
  10321. /**
  10322. * Internal only - executes current action event
  10323. * @hidden
  10324. */
  10325. _executeCurrent(evt?: ActionEvent): void;
  10326. /**
  10327. * Serialize placeholder for child classes
  10328. * @param parent of child
  10329. * @returns the serialized object
  10330. */
  10331. serialize(parent: any): any;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. _prepare(): void;
  10337. /**
  10338. * Internal only - manager for action
  10339. * @hidden
  10340. */
  10341. _actionManager: AbstractActionManager;
  10342. /**
  10343. * Adds action to chain of actions, may be a DoNothingAction
  10344. * @param action defines the next action to execute
  10345. * @returns The action passed in
  10346. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10347. */
  10348. then(action: IAction): IAction;
  10349. }
  10350. /**
  10351. * The action to be carried out following a trigger
  10352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10353. */
  10354. export class Action implements IAction {
  10355. /** the trigger, with or without parameters, for the action */
  10356. triggerOptions: any;
  10357. /**
  10358. * Trigger for the action
  10359. */
  10360. trigger: number;
  10361. /**
  10362. * Internal only - manager for action
  10363. * @hidden
  10364. */
  10365. _actionManager: ActionManager;
  10366. private _nextActiveAction;
  10367. private _child;
  10368. private _condition?;
  10369. private _triggerParameter;
  10370. /**
  10371. * An event triggered prior to action being executed.
  10372. */
  10373. onBeforeExecuteObservable: Observable<Action>;
  10374. /**
  10375. * Creates a new Action
  10376. * @param triggerOptions the trigger, with or without parameters, for the action
  10377. * @param condition an optional determinant of action
  10378. */
  10379. constructor(
  10380. /** the trigger, with or without parameters, for the action */
  10381. triggerOptions: any, condition?: Condition);
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. _prepare(): void;
  10387. /**
  10388. * Gets the trigger parameters
  10389. * @returns the trigger parameters
  10390. */
  10391. getTriggerParameter(): any;
  10392. /**
  10393. * Internal only - executes current action event
  10394. * @hidden
  10395. */
  10396. _executeCurrent(evt?: ActionEvent): void;
  10397. /**
  10398. * Execute placeholder for child classes
  10399. * @param evt optional action event
  10400. */
  10401. execute(evt?: ActionEvent): void;
  10402. /**
  10403. * Skips to next active action
  10404. */
  10405. skipToNextActiveAction(): void;
  10406. /**
  10407. * Adds action to chain of actions, may be a DoNothingAction
  10408. * @param action defines the next action to execute
  10409. * @returns The action passed in
  10410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10411. */
  10412. then(action: Action): Action;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. _getProperty(propertyPath: string): string;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. _getEffectiveTarget(target: any, propertyPath: string): any;
  10423. /**
  10424. * Serialize placeholder for child classes
  10425. * @param parent of child
  10426. * @returns the serialized object
  10427. */
  10428. serialize(parent: any): any;
  10429. /**
  10430. * Internal only called by serialize
  10431. * @hidden
  10432. */
  10433. protected _serialize(serializedAction: any, parent?: any): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. static _SerializeValueAsString: (value: any) => string;
  10439. /**
  10440. * Internal only
  10441. * @hidden
  10442. */
  10443. static _GetTargetProperty: (target: Node | Scene) => {
  10444. name: string;
  10445. targetType: string;
  10446. value: string;
  10447. };
  10448. }
  10449. }
  10450. declare module BABYLON {
  10451. /**
  10452. * A Condition applied to an Action
  10453. */
  10454. export class Condition {
  10455. /**
  10456. * Internal only - manager for action
  10457. * @hidden
  10458. */
  10459. _actionManager: ActionManager;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _evaluationId: number;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. _currentResult: boolean;
  10470. /**
  10471. * Creates a new Condition
  10472. * @param actionManager the manager of the action the condition is applied to
  10473. */
  10474. constructor(actionManager: ActionManager);
  10475. /**
  10476. * Check if the current condition is valid
  10477. * @returns a boolean
  10478. */
  10479. isValid(): boolean;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getProperty(propertyPath: string): string;
  10485. /**
  10486. * Internal only
  10487. * @hidden
  10488. */
  10489. _getEffectiveTarget(target: any, propertyPath: string): any;
  10490. /**
  10491. * Serialize placeholder for child classes
  10492. * @returns the serialized object
  10493. */
  10494. serialize(): any;
  10495. /**
  10496. * Internal only
  10497. * @hidden
  10498. */
  10499. protected _serialize(serializedCondition: any): any;
  10500. }
  10501. /**
  10502. * Defines specific conditional operators as extensions of Condition
  10503. */
  10504. export class ValueCondition extends Condition {
  10505. /** path to specify the property of the target the conditional operator uses */
  10506. propertyPath: string;
  10507. /** the value compared by the conditional operator against the current value of the property */
  10508. value: any;
  10509. /** the conditional operator, default ValueCondition.IsEqual */
  10510. operator: number;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsEqual;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsDifferent;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsGreater;
  10526. /**
  10527. * Internal only
  10528. * @hidden
  10529. */
  10530. private static _IsLesser;
  10531. /**
  10532. * returns the number for IsEqual
  10533. */
  10534. static get IsEqual(): number;
  10535. /**
  10536. * Returns the number for IsDifferent
  10537. */
  10538. static get IsDifferent(): number;
  10539. /**
  10540. * Returns the number for IsGreater
  10541. */
  10542. static get IsGreater(): number;
  10543. /**
  10544. * Returns the number for IsLesser
  10545. */
  10546. static get IsLesser(): number;
  10547. /**
  10548. * Internal only The action manager for the condition
  10549. * @hidden
  10550. */
  10551. _actionManager: ActionManager;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _target;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _effectiveTarget;
  10562. /**
  10563. * Internal only
  10564. * @hidden
  10565. */
  10566. private _property;
  10567. /**
  10568. * Creates a new ValueCondition
  10569. * @param actionManager manager for the action the condition applies to
  10570. * @param target for the action
  10571. * @param propertyPath path to specify the property of the target the conditional operator uses
  10572. * @param value the value compared by the conditional operator against the current value of the property
  10573. * @param operator the conditional operator, default ValueCondition.IsEqual
  10574. */
  10575. constructor(actionManager: ActionManager, target: any,
  10576. /** path to specify the property of the target the conditional operator uses */
  10577. propertyPath: string,
  10578. /** the value compared by the conditional operator against the current value of the property */
  10579. value: any,
  10580. /** the conditional operator, default ValueCondition.IsEqual */
  10581. operator?: number);
  10582. /**
  10583. * Compares the given value with the property value for the specified conditional operator
  10584. * @returns the result of the comparison
  10585. */
  10586. isValid(): boolean;
  10587. /**
  10588. * Serialize the ValueCondition into a JSON compatible object
  10589. * @returns serialization object
  10590. */
  10591. serialize(): any;
  10592. /**
  10593. * Gets the name of the conditional operator for the ValueCondition
  10594. * @param operator the conditional operator
  10595. * @returns the name
  10596. */
  10597. static GetOperatorName(operator: number): string;
  10598. }
  10599. /**
  10600. * Defines a predicate condition as an extension of Condition
  10601. */
  10602. export class PredicateCondition extends Condition {
  10603. /** defines the predicate function used to validate the condition */
  10604. predicate: () => boolean;
  10605. /**
  10606. * Internal only - manager for action
  10607. * @hidden
  10608. */
  10609. _actionManager: ActionManager;
  10610. /**
  10611. * Creates a new PredicateCondition
  10612. * @param actionManager manager for the action the condition applies to
  10613. * @param predicate defines the predicate function used to validate the condition
  10614. */
  10615. constructor(actionManager: ActionManager,
  10616. /** defines the predicate function used to validate the condition */
  10617. predicate: () => boolean);
  10618. /**
  10619. * @returns the validity of the predicate condition
  10620. */
  10621. isValid(): boolean;
  10622. }
  10623. /**
  10624. * Defines a state condition as an extension of Condition
  10625. */
  10626. export class StateCondition extends Condition {
  10627. /** Value to compare with target state */
  10628. value: string;
  10629. /**
  10630. * Internal only - manager for action
  10631. * @hidden
  10632. */
  10633. _actionManager: ActionManager;
  10634. /**
  10635. * Internal only
  10636. * @hidden
  10637. */
  10638. private _target;
  10639. /**
  10640. * Creates a new StateCondition
  10641. * @param actionManager manager for the action the condition applies to
  10642. * @param target of the condition
  10643. * @param value to compare with target state
  10644. */
  10645. constructor(actionManager: ActionManager, target: any,
  10646. /** Value to compare with target state */
  10647. value: string);
  10648. /**
  10649. * Gets a boolean indicating if the current condition is met
  10650. * @returns the validity of the state
  10651. */
  10652. isValid(): boolean;
  10653. /**
  10654. * Serialize the StateCondition into a JSON compatible object
  10655. * @returns serialization object
  10656. */
  10657. serialize(): any;
  10658. }
  10659. }
  10660. declare module BABYLON {
  10661. /**
  10662. * This defines an action responsible to toggle a boolean once triggered.
  10663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10664. */
  10665. export class SwitchBooleanAction extends Action {
  10666. /**
  10667. * The path to the boolean property in the target object
  10668. */
  10669. propertyPath: string;
  10670. private _target;
  10671. private _effectiveTarget;
  10672. private _property;
  10673. /**
  10674. * Instantiate the action
  10675. * @param triggerOptions defines the trigger options
  10676. * @param target defines the object containing the boolean
  10677. * @param propertyPath defines the path to the boolean property in the target object
  10678. * @param condition defines the trigger related conditions
  10679. */
  10680. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10681. /** @hidden */
  10682. _prepare(): void;
  10683. /**
  10684. * Execute the action toggle the boolean value.
  10685. */
  10686. execute(): void;
  10687. /**
  10688. * Serializes the actions and its related information.
  10689. * @param parent defines the object to serialize in
  10690. * @returns the serialized object
  10691. */
  10692. serialize(parent: any): any;
  10693. }
  10694. /**
  10695. * This defines an action responsible to set a the state field of the target
  10696. * to a desired value once triggered.
  10697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10698. */
  10699. export class SetStateAction extends Action {
  10700. /**
  10701. * The value to store in the state field.
  10702. */
  10703. value: string;
  10704. private _target;
  10705. /**
  10706. * Instantiate the action
  10707. * @param triggerOptions defines the trigger options
  10708. * @param target defines the object containing the state property
  10709. * @param value defines the value to store in the state field
  10710. * @param condition defines the trigger related conditions
  10711. */
  10712. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10713. /**
  10714. * Execute the action and store the value on the target state property.
  10715. */
  10716. execute(): void;
  10717. /**
  10718. * Serializes the actions and its related information.
  10719. * @param parent defines the object to serialize in
  10720. * @returns the serialized object
  10721. */
  10722. serialize(parent: any): any;
  10723. }
  10724. /**
  10725. * This defines an action responsible to set a property of the target
  10726. * to a desired value once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class SetValueAction extends Action {
  10730. /**
  10731. * The path of the property to set in the target.
  10732. */
  10733. propertyPath: string;
  10734. /**
  10735. * The value to set in the property
  10736. */
  10737. value: any;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the property
  10745. * @param propertyPath defines the path of the property to set in the target
  10746. * @param value defines the value to set in the property
  10747. * @param condition defines the trigger related conditions
  10748. */
  10749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10750. /** @hidden */
  10751. _prepare(): void;
  10752. /**
  10753. * Execute the action and set the targetted property to the desired value.
  10754. */
  10755. execute(): void;
  10756. /**
  10757. * Serializes the actions and its related information.
  10758. * @param parent defines the object to serialize in
  10759. * @returns the serialized object
  10760. */
  10761. serialize(parent: any): any;
  10762. }
  10763. /**
  10764. * This defines an action responsible to increment the target value
  10765. * to a desired value once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class IncrementValueAction extends Action {
  10769. /**
  10770. * The path of the property to increment in the target.
  10771. */
  10772. propertyPath: string;
  10773. /**
  10774. * The value we should increment the property by.
  10775. */
  10776. value: any;
  10777. private _target;
  10778. private _effectiveTarget;
  10779. private _property;
  10780. /**
  10781. * Instantiate the action
  10782. * @param triggerOptions defines the trigger options
  10783. * @param target defines the object containing the property
  10784. * @param propertyPath defines the path of the property to increment in the target
  10785. * @param value defines the value value we should increment the property by
  10786. * @param condition defines the trigger related conditions
  10787. */
  10788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10789. /** @hidden */
  10790. _prepare(): void;
  10791. /**
  10792. * Execute the action and increment the target of the value amount.
  10793. */
  10794. execute(): void;
  10795. /**
  10796. * Serializes the actions and its related information.
  10797. * @param parent defines the object to serialize in
  10798. * @returns the serialized object
  10799. */
  10800. serialize(parent: any): any;
  10801. }
  10802. /**
  10803. * This defines an action responsible to start an animation once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class PlayAnimationAction extends Action {
  10807. /**
  10808. * Where the animation should start (animation frame)
  10809. */
  10810. from: number;
  10811. /**
  10812. * Where the animation should stop (animation frame)
  10813. */
  10814. to: number;
  10815. /**
  10816. * Define if the animation should loop or stop after the first play.
  10817. */
  10818. loop?: boolean;
  10819. private _target;
  10820. /**
  10821. * Instantiate the action
  10822. * @param triggerOptions defines the trigger options
  10823. * @param target defines the target animation or animation name
  10824. * @param from defines from where the animation should start (animation frame)
  10825. * @param end defines where the animation should stop (animation frame)
  10826. * @param loop defines if the animation should loop or stop after the first play
  10827. * @param condition defines the trigger related conditions
  10828. */
  10829. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10830. /** @hidden */
  10831. _prepare(): void;
  10832. /**
  10833. * Execute the action and play the animation.
  10834. */
  10835. execute(): void;
  10836. /**
  10837. * Serializes the actions and its related information.
  10838. * @param parent defines the object to serialize in
  10839. * @returns the serialized object
  10840. */
  10841. serialize(parent: any): any;
  10842. }
  10843. /**
  10844. * This defines an action responsible to stop an animation once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class StopAnimationAction extends Action {
  10848. private _target;
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param target defines the target animation or animation name
  10853. * @param condition defines the trigger related conditions
  10854. */
  10855. constructor(triggerOptions: any, target: any, condition?: Condition);
  10856. /** @hidden */
  10857. _prepare(): void;
  10858. /**
  10859. * Execute the action and stop the animation.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible that does nothing once triggered.
  10871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10872. */
  10873. export class DoNothingAction extends Action {
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param condition defines the trigger related conditions
  10878. */
  10879. constructor(triggerOptions?: any, condition?: Condition);
  10880. /**
  10881. * Execute the action and do nothing.
  10882. */
  10883. execute(): void;
  10884. /**
  10885. * Serializes the actions and its related information.
  10886. * @param parent defines the object to serialize in
  10887. * @returns the serialized object
  10888. */
  10889. serialize(parent: any): any;
  10890. }
  10891. /**
  10892. * This defines an action responsible to trigger several actions once triggered.
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10894. */
  10895. export class CombineAction extends Action {
  10896. /**
  10897. * The list of aggregated animations to run.
  10898. */
  10899. children: Action[];
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param children defines the list of aggregated animations to run
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and executes all the aggregated actions.
  10911. */
  10912. execute(evt: ActionEvent): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to run code (external event) once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ExecuteCodeAction extends Action {
  10925. /**
  10926. * The callback function to run.
  10927. */
  10928. func: (evt: ActionEvent) => void;
  10929. /**
  10930. * Instantiate the action
  10931. * @param triggerOptions defines the trigger options
  10932. * @param func defines the callback function to run
  10933. * @param condition defines the trigger related conditions
  10934. */
  10935. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10936. /**
  10937. * Execute the action and run the attached code.
  10938. */
  10939. execute(evt: ActionEvent): void;
  10940. }
  10941. /**
  10942. * This defines an action responsible to set the parent property of the target once triggered.
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10944. */
  10945. export class SetParentAction extends Action {
  10946. private _parent;
  10947. private _target;
  10948. /**
  10949. * Instantiate the action
  10950. * @param triggerOptions defines the trigger options
  10951. * @param target defines the target containing the parent property
  10952. * @param parent defines from where the animation should start (animation frame)
  10953. * @param condition defines the trigger related conditions
  10954. */
  10955. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10956. /** @hidden */
  10957. _prepare(): void;
  10958. /**
  10959. * Execute the action and set the parent property.
  10960. */
  10961. execute(): void;
  10962. /**
  10963. * Serializes the actions and its related information.
  10964. * @param parent defines the object to serialize in
  10965. * @returns the serialized object
  10966. */
  10967. serialize(parent: any): any;
  10968. }
  10969. }
  10970. declare module BABYLON {
  10971. /**
  10972. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10973. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class ActionManager extends AbstractActionManager {
  10977. /**
  10978. * Nothing
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly NothingTrigger: number;
  10982. /**
  10983. * On pick
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly OnPickTrigger: number;
  10987. /**
  10988. * On left pick
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnLeftPickTrigger: number;
  10992. /**
  10993. * On right pick
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10995. */
  10996. static readonly OnRightPickTrigger: number;
  10997. /**
  10998. * On center pick
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly OnCenterPickTrigger: number;
  11002. /**
  11003. * On pick down
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnPickDownTrigger: number;
  11007. /**
  11008. * On double pick
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnDoublePickTrigger: number;
  11012. /**
  11013. * On pick up
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnPickUpTrigger: number;
  11017. /**
  11018. * On pick out.
  11019. * This trigger will only be raised if you also declared a OnPickDown
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnPickOutTrigger: number;
  11023. /**
  11024. * On long press
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnLongPressTrigger: number;
  11028. /**
  11029. * On pointer over
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnPointerOverTrigger: number;
  11033. /**
  11034. * On pointer out
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnPointerOutTrigger: number;
  11038. /**
  11039. * On every frame
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnEveryFrameTrigger: number;
  11043. /**
  11044. * On intersection enter
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnIntersectionEnterTrigger: number;
  11048. /**
  11049. * On intersection exit
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnIntersectionExitTrigger: number;
  11053. /**
  11054. * On key down
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnKeyDownTrigger: number;
  11058. /**
  11059. * On key up
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnKeyUpTrigger: number;
  11063. private _scene;
  11064. /**
  11065. * Creates a new action manager
  11066. * @param scene defines the hosting scene
  11067. */
  11068. constructor(scene: Scene);
  11069. /**
  11070. * Releases all associated resources
  11071. */
  11072. dispose(): void;
  11073. /**
  11074. * Gets hosting scene
  11075. * @returns the hosting scene
  11076. */
  11077. getScene(): Scene;
  11078. /**
  11079. * Does this action manager handles actions of any of the given triggers
  11080. * @param triggers defines the triggers to be tested
  11081. * @return a boolean indicating whether one (or more) of the triggers is handled
  11082. */
  11083. hasSpecificTriggers(triggers: number[]): boolean;
  11084. /**
  11085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11086. * speed.
  11087. * @param triggerA defines the trigger to be tested
  11088. * @param triggerB defines the trigger to be tested
  11089. * @return a boolean indicating whether one (or more) of the triggers is handled
  11090. */
  11091. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11092. /**
  11093. * Does this action manager handles actions of a given trigger
  11094. * @param trigger defines the trigger to be tested
  11095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11096. * @return whether the trigger is handled
  11097. */
  11098. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11099. /**
  11100. * Does this action manager has pointer triggers
  11101. */
  11102. get hasPointerTriggers(): boolean;
  11103. /**
  11104. * Does this action manager has pick triggers
  11105. */
  11106. get hasPickTriggers(): boolean;
  11107. /**
  11108. * Registers an action to this action manager
  11109. * @param action defines the action to be registered
  11110. * @return the action amended (prepared) after registration
  11111. */
  11112. registerAction(action: IAction): Nullable<IAction>;
  11113. /**
  11114. * Unregisters an action to this action manager
  11115. * @param action defines the action to be unregistered
  11116. * @return a boolean indicating whether the action has been unregistered
  11117. */
  11118. unregisterAction(action: IAction): Boolean;
  11119. /**
  11120. * Process a specific trigger
  11121. * @param trigger defines the trigger to process
  11122. * @param evt defines the event details to be processed
  11123. */
  11124. processTrigger(trigger: number, evt?: IActionEvent): void;
  11125. /** @hidden */
  11126. _getEffectiveTarget(target: any, propertyPath: string): any;
  11127. /** @hidden */
  11128. _getProperty(propertyPath: string): string;
  11129. /**
  11130. * Serialize this manager to a JSON object
  11131. * @param name defines the property name to store this manager
  11132. * @returns a JSON representation of this manager
  11133. */
  11134. serialize(name: string): any;
  11135. /**
  11136. * Creates a new ActionManager from a JSON data
  11137. * @param parsedActions defines the JSON data to read from
  11138. * @param object defines the hosting mesh
  11139. * @param scene defines the hosting scene
  11140. */
  11141. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11142. /**
  11143. * Get a trigger name by index
  11144. * @param trigger defines the trigger index
  11145. * @returns a trigger name
  11146. */
  11147. static GetTriggerName(trigger: number): string;
  11148. }
  11149. }
  11150. declare module BABYLON {
  11151. /**
  11152. * Class representing a ray with position and direction
  11153. */
  11154. export class Ray {
  11155. /** origin point */
  11156. origin: Vector3;
  11157. /** direction */
  11158. direction: Vector3;
  11159. /** length of the ray */
  11160. length: number;
  11161. private static readonly TmpVector3;
  11162. private _tmpRay;
  11163. /**
  11164. * Creates a new ray
  11165. * @param origin origin point
  11166. * @param direction direction
  11167. * @param length length of the ray
  11168. */
  11169. constructor(
  11170. /** origin point */
  11171. origin: Vector3,
  11172. /** direction */
  11173. direction: Vector3,
  11174. /** length of the ray */
  11175. length?: number);
  11176. /**
  11177. * Checks if the ray intersects a box
  11178. * @param minimum bound of the box
  11179. * @param maximum bound of the box
  11180. * @param intersectionTreshold extra extend to be added to the box in all direction
  11181. * @returns if the box was hit
  11182. */
  11183. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11184. /**
  11185. * Checks if the ray intersects a box
  11186. * @param box the bounding box to check
  11187. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11188. * @returns if the box was hit
  11189. */
  11190. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11191. /**
  11192. * If the ray hits a sphere
  11193. * @param sphere the bounding sphere to check
  11194. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11195. * @returns true if it hits the sphere
  11196. */
  11197. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11198. /**
  11199. * If the ray hits a triange
  11200. * @param vertex0 triangle vertex
  11201. * @param vertex1 triangle vertex
  11202. * @param vertex2 triangle vertex
  11203. * @returns intersection information if hit
  11204. */
  11205. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11206. /**
  11207. * Checks if ray intersects a plane
  11208. * @param plane the plane to check
  11209. * @returns the distance away it was hit
  11210. */
  11211. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11212. /**
  11213. * Calculate the intercept of a ray on a given axis
  11214. * @param axis to check 'x' | 'y' | 'z'
  11215. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11216. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11217. */
  11218. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11219. /**
  11220. * Checks if ray intersects a mesh
  11221. * @param mesh the mesh to check
  11222. * @param fastCheck if only the bounding box should checked
  11223. * @returns picking info of the intersecton
  11224. */
  11225. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11226. /**
  11227. * Checks if ray intersects a mesh
  11228. * @param meshes the meshes to check
  11229. * @param fastCheck if only the bounding box should checked
  11230. * @param results array to store result in
  11231. * @returns Array of picking infos
  11232. */
  11233. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11234. private _comparePickingInfo;
  11235. private static smallnum;
  11236. private static rayl;
  11237. /**
  11238. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11239. * @param sega the first point of the segment to test the intersection against
  11240. * @param segb the second point of the segment to test the intersection against
  11241. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11242. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11243. */
  11244. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11245. /**
  11246. * Update the ray from viewport position
  11247. * @param x position
  11248. * @param y y position
  11249. * @param viewportWidth viewport width
  11250. * @param viewportHeight viewport height
  11251. * @param world world matrix
  11252. * @param view view matrix
  11253. * @param projection projection matrix
  11254. * @returns this ray updated
  11255. */
  11256. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11257. /**
  11258. * Creates a ray with origin and direction of 0,0,0
  11259. * @returns the new ray
  11260. */
  11261. static Zero(): Ray;
  11262. /**
  11263. * Creates a new ray from screen space and viewport
  11264. * @param x position
  11265. * @param y y position
  11266. * @param viewportWidth viewport width
  11267. * @param viewportHeight viewport height
  11268. * @param world world matrix
  11269. * @param view view matrix
  11270. * @param projection projection matrix
  11271. * @returns new ray
  11272. */
  11273. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11274. /**
  11275. * 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
  11276. * transformed to the given world matrix.
  11277. * @param origin The origin point
  11278. * @param end The end point
  11279. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11280. * @returns the new ray
  11281. */
  11282. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11283. /**
  11284. * Transforms a ray by a matrix
  11285. * @param ray ray to transform
  11286. * @param matrix matrix to apply
  11287. * @returns the resulting new ray
  11288. */
  11289. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11290. /**
  11291. * Transforms a ray by a matrix
  11292. * @param ray ray to transform
  11293. * @param matrix matrix to apply
  11294. * @param result ray to store result in
  11295. */
  11296. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11297. /**
  11298. * Unproject a ray from screen space to object space
  11299. * @param sourceX defines the screen space x coordinate to use
  11300. * @param sourceY defines the screen space y coordinate to use
  11301. * @param viewportWidth defines the current width of the viewport
  11302. * @param viewportHeight defines the current height of the viewport
  11303. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11304. * @param view defines the view matrix to use
  11305. * @param projection defines the projection matrix to use
  11306. */
  11307. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11308. }
  11309. /**
  11310. * Type used to define predicate used to select faces when a mesh intersection is detected
  11311. */
  11312. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11313. interface Scene {
  11314. /** @hidden */
  11315. _tempPickingRay: Nullable<Ray>;
  11316. /** @hidden */
  11317. _cachedRayForTransform: Ray;
  11318. /** @hidden */
  11319. _pickWithRayInverseMatrix: Matrix;
  11320. /** @hidden */
  11321. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11322. /** @hidden */
  11323. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11324. }
  11325. }
  11326. declare module BABYLON {
  11327. /**
  11328. * Groups all the scene component constants in one place to ease maintenance.
  11329. * @hidden
  11330. */
  11331. export class SceneComponentConstants {
  11332. static readonly NAME_EFFECTLAYER: string;
  11333. static readonly NAME_LAYER: string;
  11334. static readonly NAME_LENSFLARESYSTEM: string;
  11335. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11336. static readonly NAME_PARTICLESYSTEM: string;
  11337. static readonly NAME_GAMEPAD: string;
  11338. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11339. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11340. static readonly NAME_DEPTHRENDERER: string;
  11341. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11342. static readonly NAME_SPRITE: string;
  11343. static readonly NAME_OUTLINERENDERER: string;
  11344. static readonly NAME_PROCEDURALTEXTURE: string;
  11345. static readonly NAME_SHADOWGENERATOR: string;
  11346. static readonly NAME_OCTREE: string;
  11347. static readonly NAME_PHYSICSENGINE: string;
  11348. static readonly NAME_AUDIO: string;
  11349. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11350. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11351. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11352. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11353. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11354. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11355. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11356. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11357. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11358. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11359. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11360. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11361. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11362. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11363. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11364. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11365. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11366. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11367. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11368. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11369. static readonly STEP_AFTERRENDER_AUDIO: number;
  11370. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11371. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11372. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11373. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11374. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11375. static readonly STEP_POINTERMOVE_SPRITE: number;
  11376. static readonly STEP_POINTERDOWN_SPRITE: number;
  11377. static readonly STEP_POINTERUP_SPRITE: number;
  11378. }
  11379. /**
  11380. * This represents a scene component.
  11381. *
  11382. * This is used to decouple the dependency the scene is having on the different workloads like
  11383. * layers, post processes...
  11384. */
  11385. export interface ISceneComponent {
  11386. /**
  11387. * The name of the component. Each component must have a unique name.
  11388. */
  11389. name: string;
  11390. /**
  11391. * The scene the component belongs to.
  11392. */
  11393. scene: Scene;
  11394. /**
  11395. * Register the component to one instance of a scene.
  11396. */
  11397. register(): void;
  11398. /**
  11399. * Rebuilds the elements related to this component in case of
  11400. * context lost for instance.
  11401. */
  11402. rebuild(): void;
  11403. /**
  11404. * Disposes the component and the associated ressources.
  11405. */
  11406. dispose(): void;
  11407. }
  11408. /**
  11409. * This represents a SERIALIZABLE scene component.
  11410. *
  11411. * This extends Scene Component to add Serialization methods on top.
  11412. */
  11413. export interface ISceneSerializableComponent extends ISceneComponent {
  11414. /**
  11415. * Adds all the elements from the container to the scene
  11416. * @param container the container holding the elements
  11417. */
  11418. addFromContainer(container: AbstractScene): void;
  11419. /**
  11420. * Removes all the elements in the container from the scene
  11421. * @param container contains the elements to remove
  11422. * @param dispose if the removed element should be disposed (default: false)
  11423. */
  11424. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11425. /**
  11426. * Serializes the component data to the specified json object
  11427. * @param serializationObject The object to serialize to
  11428. */
  11429. serialize(serializationObject: any): void;
  11430. }
  11431. /**
  11432. * Strong typing of a Mesh related stage step action
  11433. */
  11434. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11435. /**
  11436. * Strong typing of a Evaluate Sub Mesh related stage step action
  11437. */
  11438. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11439. /**
  11440. * Strong typing of a Active Mesh related stage step action
  11441. */
  11442. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11443. /**
  11444. * Strong typing of a Camera related stage step action
  11445. */
  11446. export type CameraStageAction = (camera: Camera) => void;
  11447. /**
  11448. * Strong typing of a Camera Frame buffer related stage step action
  11449. */
  11450. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11451. /**
  11452. * Strong typing of a Render Target related stage step action
  11453. */
  11454. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11455. /**
  11456. * Strong typing of a RenderingGroup related stage step action
  11457. */
  11458. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11459. /**
  11460. * Strong typing of a Mesh Render related stage step action
  11461. */
  11462. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11463. /**
  11464. * Strong typing of a simple stage step action
  11465. */
  11466. export type SimpleStageAction = () => void;
  11467. /**
  11468. * Strong typing of a render target action.
  11469. */
  11470. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11471. /**
  11472. * Strong typing of a pointer move action.
  11473. */
  11474. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11475. /**
  11476. * Strong typing of a pointer up/down action.
  11477. */
  11478. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11479. /**
  11480. * Representation of a stage in the scene (Basically a list of ordered steps)
  11481. * @hidden
  11482. */
  11483. export class Stage<T extends Function> extends Array<{
  11484. index: number;
  11485. component: ISceneComponent;
  11486. action: T;
  11487. }> {
  11488. /**
  11489. * Hide ctor from the rest of the world.
  11490. * @param items The items to add.
  11491. */
  11492. private constructor();
  11493. /**
  11494. * Creates a new Stage.
  11495. * @returns A new instance of a Stage
  11496. */
  11497. static Create<T extends Function>(): Stage<T>;
  11498. /**
  11499. * Registers a step in an ordered way in the targeted stage.
  11500. * @param index Defines the position to register the step in
  11501. * @param component Defines the component attached to the step
  11502. * @param action Defines the action to launch during the step
  11503. */
  11504. registerStep(index: number, component: ISceneComponent, action: T): void;
  11505. /**
  11506. * Clears all the steps from the stage.
  11507. */
  11508. clear(): void;
  11509. }
  11510. }
  11511. declare module BABYLON {
  11512. interface Scene {
  11513. /** @hidden */
  11514. _pointerOverSprite: Nullable<Sprite>;
  11515. /** @hidden */
  11516. _pickedDownSprite: Nullable<Sprite>;
  11517. /** @hidden */
  11518. _tempSpritePickingRay: Nullable<Ray>;
  11519. /**
  11520. * All of the sprite managers added to this scene
  11521. * @see http://doc.babylonjs.com/babylon101/sprites
  11522. */
  11523. spriteManagers: Array<ISpriteManager>;
  11524. /**
  11525. * An event triggered when sprites rendering is about to start
  11526. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11527. */
  11528. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11529. /**
  11530. * An event triggered when sprites rendering is done
  11531. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11532. */
  11533. onAfterSpritesRenderingObservable: Observable<Scene>;
  11534. /** @hidden */
  11535. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11536. /** Launch a ray to try to pick a sprite in the scene
  11537. * @param x position on screen
  11538. * @param y position on screen
  11539. * @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
  11540. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11541. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11542. * @returns a PickingInfo
  11543. */
  11544. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11545. /** Use the given ray to pick a sprite in the scene
  11546. * @param ray The ray (in world space) to use to pick meshes
  11547. * @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
  11548. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11549. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11550. * @returns a PickingInfo
  11551. */
  11552. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11553. /** @hidden */
  11554. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11555. /** Launch a ray to try to pick sprites in the scene
  11556. * @param x position on screen
  11557. * @param y position on screen
  11558. * @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
  11559. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11560. * @returns a PickingInfo array
  11561. */
  11562. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11563. /** Use the given ray to pick sprites in the scene
  11564. * @param ray The ray (in world space) to use to pick meshes
  11565. * @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
  11566. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11567. * @returns a PickingInfo array
  11568. */
  11569. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11570. /**
  11571. * Force the sprite under the pointer
  11572. * @param sprite defines the sprite to use
  11573. */
  11574. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11575. /**
  11576. * Gets the sprite under the pointer
  11577. * @returns a Sprite or null if no sprite is under the pointer
  11578. */
  11579. getPointerOverSprite(): Nullable<Sprite>;
  11580. }
  11581. /**
  11582. * Defines the sprite scene component responsible to manage sprites
  11583. * in a given scene.
  11584. */
  11585. export class SpriteSceneComponent implements ISceneComponent {
  11586. /**
  11587. * The component name helpfull to identify the component in the list of scene components.
  11588. */
  11589. readonly name: string;
  11590. /**
  11591. * The scene the component belongs to.
  11592. */
  11593. scene: Scene;
  11594. /** @hidden */
  11595. private _spritePredicate;
  11596. /**
  11597. * Creates a new instance of the component for the given scene
  11598. * @param scene Defines the scene to register the component in
  11599. */
  11600. constructor(scene: Scene);
  11601. /**
  11602. * Registers the component in a given scene
  11603. */
  11604. register(): void;
  11605. /**
  11606. * Rebuilds the elements related to this component in case of
  11607. * context lost for instance.
  11608. */
  11609. rebuild(): void;
  11610. /**
  11611. * Disposes the component and the associated ressources.
  11612. */
  11613. dispose(): void;
  11614. private _pickSpriteButKeepRay;
  11615. private _pointerMove;
  11616. private _pointerDown;
  11617. private _pointerUp;
  11618. }
  11619. }
  11620. declare module BABYLON {
  11621. /** @hidden */
  11622. export var fogFragmentDeclaration: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module BABYLON {
  11628. /** @hidden */
  11629. export var fogFragment: {
  11630. name: string;
  11631. shader: string;
  11632. };
  11633. }
  11634. declare module BABYLON {
  11635. /** @hidden */
  11636. export var spritesPixelShader: {
  11637. name: string;
  11638. shader: string;
  11639. };
  11640. }
  11641. declare module BABYLON {
  11642. /** @hidden */
  11643. export var fogVertexDeclaration: {
  11644. name: string;
  11645. shader: string;
  11646. };
  11647. }
  11648. declare module BABYLON {
  11649. /** @hidden */
  11650. export var spritesVertexShader: {
  11651. name: string;
  11652. shader: string;
  11653. };
  11654. }
  11655. declare module BABYLON {
  11656. /**
  11657. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11658. */
  11659. export interface ISpriteManager extends IDisposable {
  11660. /**
  11661. * Restricts the camera to viewing objects with the same layerMask.
  11662. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11663. */
  11664. layerMask: number;
  11665. /**
  11666. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11667. */
  11668. isPickable: boolean;
  11669. /**
  11670. * Specifies the rendering group id for this mesh (0 by default)
  11671. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11672. */
  11673. renderingGroupId: number;
  11674. /**
  11675. * Defines the list of sprites managed by the manager.
  11676. */
  11677. sprites: Array<Sprite>;
  11678. /**
  11679. * Tests the intersection of a sprite with a specific ray.
  11680. * @param ray The ray we are sending to test the collision
  11681. * @param camera The camera space we are sending rays in
  11682. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11683. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11684. * @returns picking info or null.
  11685. */
  11686. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11687. /**
  11688. * Intersects the sprites with a ray
  11689. * @param ray defines the ray to intersect with
  11690. * @param camera defines the current active camera
  11691. * @param predicate defines a predicate used to select candidate sprites
  11692. * @returns null if no hit or a PickingInfo array
  11693. */
  11694. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11695. /**
  11696. * Renders the list of sprites on screen.
  11697. */
  11698. render(): void;
  11699. }
  11700. /**
  11701. * Class used to manage multiple sprites on the same spritesheet
  11702. * @see http://doc.babylonjs.com/babylon101/sprites
  11703. */
  11704. export class SpriteManager implements ISpriteManager {
  11705. /** defines the manager's name */
  11706. name: string;
  11707. /** Gets the list of sprites */
  11708. sprites: Sprite[];
  11709. /** Gets or sets the rendering group id (0 by default) */
  11710. renderingGroupId: number;
  11711. /** Gets or sets camera layer mask */
  11712. layerMask: number;
  11713. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11714. fogEnabled: boolean;
  11715. /** Gets or sets a boolean indicating if the sprites are pickable */
  11716. isPickable: boolean;
  11717. /** Defines the default width of a cell in the spritesheet */
  11718. cellWidth: number;
  11719. /** Defines the default height of a cell in the spritesheet */
  11720. cellHeight: number;
  11721. /** Associative array from JSON sprite data file */
  11722. private _cellData;
  11723. /** Array of sprite names from JSON sprite data file */
  11724. private _spriteMap;
  11725. /** True when packed cell data from JSON file is ready*/
  11726. private _packedAndReady;
  11727. /**
  11728. * An event triggered when the manager is disposed.
  11729. */
  11730. onDisposeObservable: Observable<SpriteManager>;
  11731. private _onDisposeObserver;
  11732. /**
  11733. * Callback called when the manager is disposed
  11734. */
  11735. set onDispose(callback: () => void);
  11736. private _capacity;
  11737. private _fromPacked;
  11738. private _spriteTexture;
  11739. private _epsilon;
  11740. private _scene;
  11741. private _vertexData;
  11742. private _buffer;
  11743. private _vertexBuffers;
  11744. private _indexBuffer;
  11745. private _effectBase;
  11746. private _effectFog;
  11747. /**
  11748. * Gets or sets the spritesheet texture
  11749. */
  11750. get texture(): Texture;
  11751. set texture(value: Texture);
  11752. /**
  11753. * Creates a new sprite manager
  11754. * @param name defines the manager's name
  11755. * @param imgUrl defines the sprite sheet url
  11756. * @param capacity defines the maximum allowed number of sprites
  11757. * @param cellSize defines the size of a sprite cell
  11758. * @param scene defines the hosting scene
  11759. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11760. * @param samplingMode defines the smapling mode to use with spritesheet
  11761. * @param fromPacked set to false; do not alter
  11762. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11763. */
  11764. constructor(
  11765. /** defines the manager's name */
  11766. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11767. private _makePacked;
  11768. private _appendSpriteVertex;
  11769. /**
  11770. * Intersects the sprites with a ray
  11771. * @param ray defines the ray to intersect with
  11772. * @param camera defines the current active camera
  11773. * @param predicate defines a predicate used to select candidate sprites
  11774. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11775. * @returns null if no hit or a PickingInfo
  11776. */
  11777. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11778. /**
  11779. * Intersects the sprites with a ray
  11780. * @param ray defines the ray to intersect with
  11781. * @param camera defines the current active camera
  11782. * @param predicate defines a predicate used to select candidate sprites
  11783. * @returns null if no hit or a PickingInfo array
  11784. */
  11785. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11786. /**
  11787. * Render all child sprites
  11788. */
  11789. render(): void;
  11790. /**
  11791. * Release associated resources
  11792. */
  11793. dispose(): void;
  11794. }
  11795. }
  11796. declare module BABYLON {
  11797. /**
  11798. * Class used to represent a sprite
  11799. * @see http://doc.babylonjs.com/babylon101/sprites
  11800. */
  11801. export class Sprite {
  11802. /** defines the name */
  11803. name: string;
  11804. /** Gets or sets the current world position */
  11805. position: Vector3;
  11806. /** Gets or sets the main color */
  11807. color: Color4;
  11808. /** Gets or sets the width */
  11809. width: number;
  11810. /** Gets or sets the height */
  11811. height: number;
  11812. /** Gets or sets rotation angle */
  11813. angle: number;
  11814. /** Gets or sets the cell index in the sprite sheet */
  11815. cellIndex: number;
  11816. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11817. cellRef: string;
  11818. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11819. invertU: number;
  11820. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11821. invertV: number;
  11822. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11823. disposeWhenFinishedAnimating: boolean;
  11824. /** Gets the list of attached animations */
  11825. animations: Animation[];
  11826. /** Gets or sets a boolean indicating if the sprite can be picked */
  11827. isPickable: boolean;
  11828. /**
  11829. * Gets or sets the associated action manager
  11830. */
  11831. actionManager: Nullable<ActionManager>;
  11832. private _animationStarted;
  11833. private _loopAnimation;
  11834. private _fromIndex;
  11835. private _toIndex;
  11836. private _delay;
  11837. private _direction;
  11838. private _manager;
  11839. private _time;
  11840. private _onAnimationEnd;
  11841. /**
  11842. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11843. */
  11844. isVisible: boolean;
  11845. /**
  11846. * Gets or sets the sprite size
  11847. */
  11848. get size(): number;
  11849. set size(value: number);
  11850. /**
  11851. * Creates a new Sprite
  11852. * @param name defines the name
  11853. * @param manager defines the manager
  11854. */
  11855. constructor(
  11856. /** defines the name */
  11857. name: string, manager: ISpriteManager);
  11858. /**
  11859. * Starts an animation
  11860. * @param from defines the initial key
  11861. * @param to defines the end key
  11862. * @param loop defines if the animation must loop
  11863. * @param delay defines the start delay (in ms)
  11864. * @param onAnimationEnd defines a callback to call when animation ends
  11865. */
  11866. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11867. /** Stops current animation (if any) */
  11868. stopAnimation(): void;
  11869. /** @hidden */
  11870. _animate(deltaTime: number): void;
  11871. /** Release associated resources */
  11872. dispose(): void;
  11873. }
  11874. }
  11875. declare module BABYLON {
  11876. /**
  11877. * Information about the result of picking within a scene
  11878. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11879. */
  11880. export class PickingInfo {
  11881. /** @hidden */
  11882. _pickingUnavailable: boolean;
  11883. /**
  11884. * If the pick collided with an object
  11885. */
  11886. hit: boolean;
  11887. /**
  11888. * Distance away where the pick collided
  11889. */
  11890. distance: number;
  11891. /**
  11892. * The location of pick collision
  11893. */
  11894. pickedPoint: Nullable<Vector3>;
  11895. /**
  11896. * The mesh corresponding the the pick collision
  11897. */
  11898. pickedMesh: Nullable<AbstractMesh>;
  11899. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11900. bu: number;
  11901. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11902. bv: number;
  11903. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11904. faceId: number;
  11905. /** Id of the the submesh that was picked */
  11906. subMeshId: number;
  11907. /** If a sprite was picked, this will be the sprite the pick collided with */
  11908. pickedSprite: Nullable<Sprite>;
  11909. /**
  11910. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11911. */
  11912. originMesh: Nullable<AbstractMesh>;
  11913. /**
  11914. * The ray that was used to perform the picking.
  11915. */
  11916. ray: Nullable<Ray>;
  11917. /**
  11918. * Gets the normal correspodning to the face the pick collided with
  11919. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11920. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11921. * @returns The normal correspodning to the face the pick collided with
  11922. */
  11923. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11924. /**
  11925. * Gets the texture coordinates of where the pick occured
  11926. * @returns the vector containing the coordnates of the texture
  11927. */
  11928. getTextureCoordinates(): Nullable<Vector2>;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * Gather the list of pointer event types as constants.
  11934. */
  11935. export class PointerEventTypes {
  11936. /**
  11937. * 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.
  11938. */
  11939. static readonly POINTERDOWN: number;
  11940. /**
  11941. * The pointerup event is fired when a pointer is no longer active.
  11942. */
  11943. static readonly POINTERUP: number;
  11944. /**
  11945. * The pointermove event is fired when a pointer changes coordinates.
  11946. */
  11947. static readonly POINTERMOVE: number;
  11948. /**
  11949. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11950. */
  11951. static readonly POINTERWHEEL: number;
  11952. /**
  11953. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11954. */
  11955. static readonly POINTERPICK: number;
  11956. /**
  11957. * The pointertap event is fired when a the object has been touched and released without drag.
  11958. */
  11959. static readonly POINTERTAP: number;
  11960. /**
  11961. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11962. */
  11963. static readonly POINTERDOUBLETAP: number;
  11964. }
  11965. /**
  11966. * Base class of pointer info types.
  11967. */
  11968. export class PointerInfoBase {
  11969. /**
  11970. * Defines the type of event (PointerEventTypes)
  11971. */
  11972. type: number;
  11973. /**
  11974. * Defines the related dom event
  11975. */
  11976. event: PointerEvent | MouseWheelEvent;
  11977. /**
  11978. * Instantiates the base class of pointers info.
  11979. * @param type Defines the type of event (PointerEventTypes)
  11980. * @param event Defines the related dom event
  11981. */
  11982. constructor(
  11983. /**
  11984. * Defines the type of event (PointerEventTypes)
  11985. */
  11986. type: number,
  11987. /**
  11988. * Defines the related dom event
  11989. */
  11990. event: PointerEvent | MouseWheelEvent);
  11991. }
  11992. /**
  11993. * This class is used to store pointer related info for the onPrePointerObservable event.
  11994. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11995. */
  11996. export class PointerInfoPre extends PointerInfoBase {
  11997. /**
  11998. * Ray from a pointer if availible (eg. 6dof controller)
  11999. */
  12000. ray: Nullable<Ray>;
  12001. /**
  12002. * Defines the local position of the pointer on the canvas.
  12003. */
  12004. localPosition: Vector2;
  12005. /**
  12006. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12007. */
  12008. skipOnPointerObservable: boolean;
  12009. /**
  12010. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12011. * @param type Defines the type of event (PointerEventTypes)
  12012. * @param event Defines the related dom event
  12013. * @param localX Defines the local x coordinates of the pointer when the event occured
  12014. * @param localY Defines the local y coordinates of the pointer when the event occured
  12015. */
  12016. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12017. }
  12018. /**
  12019. * This type contains all the data related to a pointer event in Babylon.js.
  12020. * 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.
  12021. */
  12022. export class PointerInfo extends PointerInfoBase {
  12023. /**
  12024. * Defines the picking info associated to the info (if any)\
  12025. */
  12026. pickInfo: Nullable<PickingInfo>;
  12027. /**
  12028. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12029. * @param type Defines the type of event (PointerEventTypes)
  12030. * @param event Defines the related dom event
  12031. * @param pickInfo Defines the picking info associated to the info (if any)\
  12032. */
  12033. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12034. /**
  12035. * Defines the picking info associated to the info (if any)\
  12036. */
  12037. pickInfo: Nullable<PickingInfo>);
  12038. }
  12039. /**
  12040. * Data relating to a touch event on the screen.
  12041. */
  12042. export interface PointerTouch {
  12043. /**
  12044. * X coordinate of touch.
  12045. */
  12046. x: number;
  12047. /**
  12048. * Y coordinate of touch.
  12049. */
  12050. y: number;
  12051. /**
  12052. * Id of touch. Unique for each finger.
  12053. */
  12054. pointerId: number;
  12055. /**
  12056. * Event type passed from DOM.
  12057. */
  12058. type: any;
  12059. }
  12060. }
  12061. declare module BABYLON {
  12062. /**
  12063. * Manage the mouse inputs to control the movement of a free camera.
  12064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12065. */
  12066. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12067. /**
  12068. * Define if touch is enabled in the mouse input
  12069. */
  12070. touchEnabled: boolean;
  12071. /**
  12072. * Defines the camera the input is attached to.
  12073. */
  12074. camera: FreeCamera;
  12075. /**
  12076. * Defines the buttons associated with the input to handle camera move.
  12077. */
  12078. buttons: number[];
  12079. /**
  12080. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12081. */
  12082. angularSensibility: number;
  12083. private _pointerInput;
  12084. private _onMouseMove;
  12085. private _observer;
  12086. private previousPosition;
  12087. /**
  12088. * Observable for when a pointer move event occurs containing the move offset
  12089. */
  12090. onPointerMovedObservable: Observable<{
  12091. offsetX: number;
  12092. offsetY: number;
  12093. }>;
  12094. /**
  12095. * @hidden
  12096. * If the camera should be rotated automatically based on pointer movement
  12097. */
  12098. _allowCameraRotation: boolean;
  12099. /**
  12100. * Manage the mouse inputs to control the movement of a free camera.
  12101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12102. * @param touchEnabled Defines if touch is enabled or not
  12103. */
  12104. constructor(
  12105. /**
  12106. * Define if touch is enabled in the mouse input
  12107. */
  12108. touchEnabled?: boolean);
  12109. /**
  12110. * Attach the input controls to a specific dom element to get the input from.
  12111. * @param element Defines the element the controls should be listened from
  12112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12113. */
  12114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12115. /**
  12116. * Called on JS contextmenu event.
  12117. * Override this method to provide functionality.
  12118. */
  12119. protected onContextMenu(evt: PointerEvent): void;
  12120. /**
  12121. * Detach the current controls from the specified dom element.
  12122. * @param element Defines the element to stop listening the inputs from
  12123. */
  12124. detachControl(element: Nullable<HTMLElement>): void;
  12125. /**
  12126. * Gets the class name of the current intput.
  12127. * @returns the class name
  12128. */
  12129. getClassName(): string;
  12130. /**
  12131. * Get the friendly name associated with the input class.
  12132. * @returns the input friendly name
  12133. */
  12134. getSimpleName(): string;
  12135. }
  12136. }
  12137. declare module BABYLON {
  12138. /**
  12139. * Manage the touch inputs to control the movement of a free camera.
  12140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12141. */
  12142. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12143. /**
  12144. * Defines the camera the input is attached to.
  12145. */
  12146. camera: FreeCamera;
  12147. /**
  12148. * Defines the touch sensibility for rotation.
  12149. * The higher the faster.
  12150. */
  12151. touchAngularSensibility: number;
  12152. /**
  12153. * Defines the touch sensibility for move.
  12154. * The higher the faster.
  12155. */
  12156. touchMoveSensibility: number;
  12157. private _offsetX;
  12158. private _offsetY;
  12159. private _pointerPressed;
  12160. private _pointerInput;
  12161. private _observer;
  12162. private _onLostFocus;
  12163. /**
  12164. * Attach the input controls to a specific dom element to get the input from.
  12165. * @param element Defines the element the controls should be listened from
  12166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12167. */
  12168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12169. /**
  12170. * Detach the current controls from the specified dom element.
  12171. * @param element Defines the element to stop listening the inputs from
  12172. */
  12173. detachControl(element: Nullable<HTMLElement>): void;
  12174. /**
  12175. * Update the current camera state depending on the inputs that have been used this frame.
  12176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12177. */
  12178. checkInputs(): void;
  12179. /**
  12180. * Gets the class name of the current intput.
  12181. * @returns the class name
  12182. */
  12183. getClassName(): string;
  12184. /**
  12185. * Get the friendly name associated with the input class.
  12186. * @returns the input friendly name
  12187. */
  12188. getSimpleName(): string;
  12189. }
  12190. }
  12191. declare module BABYLON {
  12192. /**
  12193. * Default Inputs manager for the FreeCamera.
  12194. * It groups all the default supported inputs for ease of use.
  12195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12196. */
  12197. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12198. /**
  12199. * @hidden
  12200. */
  12201. _mouseInput: Nullable<FreeCameraMouseInput>;
  12202. /**
  12203. * Instantiates a new FreeCameraInputsManager.
  12204. * @param camera Defines the camera the inputs belong to
  12205. */
  12206. constructor(camera: FreeCamera);
  12207. /**
  12208. * Add keyboard input support to the input manager.
  12209. * @returns the current input manager
  12210. */
  12211. addKeyboard(): FreeCameraInputsManager;
  12212. /**
  12213. * Add mouse input support to the input manager.
  12214. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12215. * @returns the current input manager
  12216. */
  12217. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12218. /**
  12219. * Removes the mouse input support from the manager
  12220. * @returns the current input manager
  12221. */
  12222. removeMouse(): FreeCameraInputsManager;
  12223. /**
  12224. * Add touch input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addTouch(): FreeCameraInputsManager;
  12228. /**
  12229. * Remove all attached input methods from a camera
  12230. */
  12231. clear(): void;
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12237. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12239. */
  12240. export class FreeCamera extends TargetCamera {
  12241. /**
  12242. * Define the collision ellipsoid of the camera.
  12243. * This is helpful to simulate a camera body like the player body around the camera
  12244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12245. */
  12246. ellipsoid: Vector3;
  12247. /**
  12248. * Define an offset for the position of the ellipsoid around the camera.
  12249. * This can be helpful to determine the center of the body near the gravity center of the body
  12250. * instead of its head.
  12251. */
  12252. ellipsoidOffset: Vector3;
  12253. /**
  12254. * Enable or disable collisions of the camera with the rest of the scene objects.
  12255. */
  12256. checkCollisions: boolean;
  12257. /**
  12258. * Enable or disable gravity on the camera.
  12259. */
  12260. applyGravity: boolean;
  12261. /**
  12262. * Define the input manager associated to the camera.
  12263. */
  12264. inputs: FreeCameraInputsManager;
  12265. /**
  12266. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12267. * Higher values reduce sensitivity.
  12268. */
  12269. get angularSensibility(): number;
  12270. /**
  12271. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12272. * Higher values reduce sensitivity.
  12273. */
  12274. set angularSensibility(value: number);
  12275. /**
  12276. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12277. */
  12278. get keysUp(): number[];
  12279. set keysUp(value: number[]);
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12282. */
  12283. get keysDown(): number[];
  12284. set keysDown(value: number[]);
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12287. */
  12288. get keysLeft(): number[];
  12289. set keysLeft(value: number[]);
  12290. /**
  12291. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12292. */
  12293. get keysRight(): number[];
  12294. set keysRight(value: number[]);
  12295. /**
  12296. * Event raised when the camera collide with a mesh in the scene.
  12297. */
  12298. onCollide: (collidedMesh: AbstractMesh) => void;
  12299. private _collider;
  12300. private _needMoveForGravity;
  12301. private _oldPosition;
  12302. private _diffPosition;
  12303. private _newPosition;
  12304. /** @hidden */
  12305. _localDirection: Vector3;
  12306. /** @hidden */
  12307. _transformedDirection: Vector3;
  12308. /**
  12309. * Instantiates a Free Camera.
  12310. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12311. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12313. * @param name Define the name of the camera in the scene
  12314. * @param position Define the start position of the camera in the scene
  12315. * @param scene Define the scene the camera belongs to
  12316. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12317. */
  12318. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12319. /**
  12320. * Attached controls to the current camera.
  12321. * @param element Defines the element the controls should be listened from
  12322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12323. */
  12324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12325. /**
  12326. * Detach the current controls from the camera.
  12327. * The camera will stop reacting to inputs.
  12328. * @param element Defines the element to stop listening the inputs from
  12329. */
  12330. detachControl(element: HTMLElement): void;
  12331. private _collisionMask;
  12332. /**
  12333. * Define a collision mask to limit the list of object the camera can collide with
  12334. */
  12335. get collisionMask(): number;
  12336. set collisionMask(mask: number);
  12337. /** @hidden */
  12338. _collideWithWorld(displacement: Vector3): void;
  12339. private _onCollisionPositionChange;
  12340. /** @hidden */
  12341. _checkInputs(): void;
  12342. /** @hidden */
  12343. _decideIfNeedsToMove(): boolean;
  12344. /** @hidden */
  12345. _updatePosition(): void;
  12346. /**
  12347. * Destroy the camera and release the current resources hold by it.
  12348. */
  12349. dispose(): void;
  12350. /**
  12351. * Gets the current object class name.
  12352. * @return the class name
  12353. */
  12354. getClassName(): string;
  12355. }
  12356. }
  12357. declare module BABYLON {
  12358. /**
  12359. * Represents a gamepad control stick position
  12360. */
  12361. export class StickValues {
  12362. /**
  12363. * The x component of the control stick
  12364. */
  12365. x: number;
  12366. /**
  12367. * The y component of the control stick
  12368. */
  12369. y: number;
  12370. /**
  12371. * Initializes the gamepad x and y control stick values
  12372. * @param x The x component of the gamepad control stick value
  12373. * @param y The y component of the gamepad control stick value
  12374. */
  12375. constructor(
  12376. /**
  12377. * The x component of the control stick
  12378. */
  12379. x: number,
  12380. /**
  12381. * The y component of the control stick
  12382. */
  12383. y: number);
  12384. }
  12385. /**
  12386. * An interface which manages callbacks for gamepad button changes
  12387. */
  12388. export interface GamepadButtonChanges {
  12389. /**
  12390. * Called when a gamepad has been changed
  12391. */
  12392. changed: boolean;
  12393. /**
  12394. * Called when a gamepad press event has been triggered
  12395. */
  12396. pressChanged: boolean;
  12397. /**
  12398. * Called when a touch event has been triggered
  12399. */
  12400. touchChanged: boolean;
  12401. /**
  12402. * Called when a value has changed
  12403. */
  12404. valueChanged: boolean;
  12405. }
  12406. /**
  12407. * Represents a gamepad
  12408. */
  12409. export class Gamepad {
  12410. /**
  12411. * The id of the gamepad
  12412. */
  12413. id: string;
  12414. /**
  12415. * The index of the gamepad
  12416. */
  12417. index: number;
  12418. /**
  12419. * The browser gamepad
  12420. */
  12421. browserGamepad: any;
  12422. /**
  12423. * Specifies what type of gamepad this represents
  12424. */
  12425. type: number;
  12426. private _leftStick;
  12427. private _rightStick;
  12428. /** @hidden */
  12429. _isConnected: boolean;
  12430. private _leftStickAxisX;
  12431. private _leftStickAxisY;
  12432. private _rightStickAxisX;
  12433. private _rightStickAxisY;
  12434. /**
  12435. * Triggered when the left control stick has been changed
  12436. */
  12437. private _onleftstickchanged;
  12438. /**
  12439. * Triggered when the right control stick has been changed
  12440. */
  12441. private _onrightstickchanged;
  12442. /**
  12443. * Represents a gamepad controller
  12444. */
  12445. static GAMEPAD: number;
  12446. /**
  12447. * Represents a generic controller
  12448. */
  12449. static GENERIC: number;
  12450. /**
  12451. * Represents an XBox controller
  12452. */
  12453. static XBOX: number;
  12454. /**
  12455. * Represents a pose-enabled controller
  12456. */
  12457. static POSE_ENABLED: number;
  12458. /**
  12459. * Represents an Dual Shock controller
  12460. */
  12461. static DUALSHOCK: number;
  12462. /**
  12463. * Specifies whether the left control stick should be Y-inverted
  12464. */
  12465. protected _invertLeftStickY: boolean;
  12466. /**
  12467. * Specifies if the gamepad has been connected
  12468. */
  12469. get isConnected(): boolean;
  12470. /**
  12471. * Initializes the gamepad
  12472. * @param id The id of the gamepad
  12473. * @param index The index of the gamepad
  12474. * @param browserGamepad The browser gamepad
  12475. * @param leftStickX The x component of the left joystick
  12476. * @param leftStickY The y component of the left joystick
  12477. * @param rightStickX The x component of the right joystick
  12478. * @param rightStickY The y component of the right joystick
  12479. */
  12480. constructor(
  12481. /**
  12482. * The id of the gamepad
  12483. */
  12484. id: string,
  12485. /**
  12486. * The index of the gamepad
  12487. */
  12488. index: number,
  12489. /**
  12490. * The browser gamepad
  12491. */
  12492. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12493. /**
  12494. * Callback triggered when the left joystick has changed
  12495. * @param callback
  12496. */
  12497. onleftstickchanged(callback: (values: StickValues) => void): void;
  12498. /**
  12499. * Callback triggered when the right joystick has changed
  12500. * @param callback
  12501. */
  12502. onrightstickchanged(callback: (values: StickValues) => void): void;
  12503. /**
  12504. * Gets the left joystick
  12505. */
  12506. get leftStick(): StickValues;
  12507. /**
  12508. * Sets the left joystick values
  12509. */
  12510. set leftStick(newValues: StickValues);
  12511. /**
  12512. * Gets the right joystick
  12513. */
  12514. get rightStick(): StickValues;
  12515. /**
  12516. * Sets the right joystick value
  12517. */
  12518. set rightStick(newValues: StickValues);
  12519. /**
  12520. * Updates the gamepad joystick positions
  12521. */
  12522. update(): void;
  12523. /**
  12524. * Disposes the gamepad
  12525. */
  12526. dispose(): void;
  12527. }
  12528. /**
  12529. * Represents a generic gamepad
  12530. */
  12531. export class GenericPad extends Gamepad {
  12532. private _buttons;
  12533. private _onbuttondown;
  12534. private _onbuttonup;
  12535. /**
  12536. * Observable triggered when a button has been pressed
  12537. */
  12538. onButtonDownObservable: Observable<number>;
  12539. /**
  12540. * Observable triggered when a button has been released
  12541. */
  12542. onButtonUpObservable: Observable<number>;
  12543. /**
  12544. * Callback triggered when a button has been pressed
  12545. * @param callback Called when a button has been pressed
  12546. */
  12547. onbuttondown(callback: (buttonPressed: number) => void): void;
  12548. /**
  12549. * Callback triggered when a button has been released
  12550. * @param callback Called when a button has been released
  12551. */
  12552. onbuttonup(callback: (buttonReleased: number) => void): void;
  12553. /**
  12554. * Initializes the generic gamepad
  12555. * @param id The id of the generic gamepad
  12556. * @param index The index of the generic gamepad
  12557. * @param browserGamepad The browser gamepad
  12558. */
  12559. constructor(id: string, index: number, browserGamepad: any);
  12560. private _setButtonValue;
  12561. /**
  12562. * Updates the generic gamepad
  12563. */
  12564. update(): void;
  12565. /**
  12566. * Disposes the generic gamepad
  12567. */
  12568. dispose(): void;
  12569. }
  12570. }
  12571. declare module BABYLON {
  12572. interface Engine {
  12573. /**
  12574. * Creates a raw texture
  12575. * @param data defines the data to store in the texture
  12576. * @param width defines the width of the texture
  12577. * @param height defines the height of the texture
  12578. * @param format defines the format of the data
  12579. * @param generateMipMaps defines if the engine should generate the mip levels
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12582. * @param compression defines the compression used (null by default)
  12583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12584. * @returns the raw texture inside an InternalTexture
  12585. */
  12586. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12587. /**
  12588. * Update a raw texture
  12589. * @param texture defines the texture to update
  12590. * @param data defines the data to store in the texture
  12591. * @param format defines the format of the data
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. */
  12594. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12595. /**
  12596. * Update a raw texture
  12597. * @param texture defines the texture to update
  12598. * @param data defines the data to store in the texture
  12599. * @param format defines the format of the data
  12600. * @param invertY defines if data must be stored with Y axis inverted
  12601. * @param compression defines the compression used (null by default)
  12602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12603. */
  12604. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12605. /**
  12606. * Creates a new raw cube texture
  12607. * @param data defines the array of data to use to create each face
  12608. * @param size defines the size of the textures
  12609. * @param format defines the format of the data
  12610. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12611. * @param generateMipMaps defines if the engine should generate the mip levels
  12612. * @param invertY defines if data must be stored with Y axis inverted
  12613. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12614. * @param compression defines the compression used (null by default)
  12615. * @returns the cube texture as an InternalTexture
  12616. */
  12617. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12618. /**
  12619. * Update a raw cube texture
  12620. * @param texture defines the texture to udpdate
  12621. * @param data defines the data to store
  12622. * @param format defines the data format
  12623. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12624. * @param invertY defines if data must be stored with Y axis inverted
  12625. */
  12626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12627. /**
  12628. * Update a raw cube texture
  12629. * @param texture defines the texture to udpdate
  12630. * @param data defines the data to store
  12631. * @param format defines the data format
  12632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12633. * @param invertY defines if data must be stored with Y axis inverted
  12634. * @param compression defines the compression used (null by default)
  12635. */
  12636. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12637. /**
  12638. * Update a raw cube texture
  12639. * @param texture defines the texture to udpdate
  12640. * @param data defines the data to store
  12641. * @param format defines the data format
  12642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12643. * @param invertY defines if data must be stored with Y axis inverted
  12644. * @param compression defines the compression used (null by default)
  12645. * @param level defines which level of the texture to update
  12646. */
  12647. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12648. /**
  12649. * Creates a new raw cube texture from a specified url
  12650. * @param url defines the url where the data is located
  12651. * @param scene defines the current scene
  12652. * @param size defines the size of the textures
  12653. * @param format defines the format of the data
  12654. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12655. * @param noMipmap defines if the engine should avoid generating the mip levels
  12656. * @param callback defines a callback used to extract texture data from loaded data
  12657. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12658. * @param onLoad defines a callback called when texture is loaded
  12659. * @param onError defines a callback called if there is an error
  12660. * @returns the cube texture as an InternalTexture
  12661. */
  12662. 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;
  12663. /**
  12664. * Creates a new raw cube texture from a specified url
  12665. * @param url defines the url where the data is located
  12666. * @param scene defines the current scene
  12667. * @param size defines the size of the textures
  12668. * @param format defines the format of the data
  12669. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12670. * @param noMipmap defines if the engine should avoid generating the mip levels
  12671. * @param callback defines a callback used to extract texture data from loaded data
  12672. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12673. * @param onLoad defines a callback called when texture is loaded
  12674. * @param onError defines a callback called if there is an error
  12675. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12676. * @param invertY defines if data must be stored with Y axis inverted
  12677. * @returns the cube texture as an InternalTexture
  12678. */
  12679. 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;
  12680. /**
  12681. * Creates a new raw 3D texture
  12682. * @param data defines the data used to create the texture
  12683. * @param width defines the width of the texture
  12684. * @param height defines the height of the texture
  12685. * @param depth defines the depth of the texture
  12686. * @param format defines the format of the texture
  12687. * @param generateMipMaps defines if the engine must generate mip levels
  12688. * @param invertY defines if data must be stored with Y axis inverted
  12689. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12690. * @param compression defines the compressed used (can be null)
  12691. * @param textureType defines the compressed used (can be null)
  12692. * @returns a new raw 3D texture (stored in an InternalTexture)
  12693. */
  12694. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12695. /**
  12696. * Update a raw 3D texture
  12697. * @param texture defines the texture to update
  12698. * @param data defines the data to store
  12699. * @param format defines the data format
  12700. * @param invertY defines if data must be stored with Y axis inverted
  12701. */
  12702. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12703. /**
  12704. * Update a raw 3D texture
  12705. * @param texture defines the texture to update
  12706. * @param data defines the data to store
  12707. * @param format defines the data format
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. * @param compression defines the used compression (can be null)
  12710. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12711. */
  12712. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12713. /**
  12714. * Creates a new raw 2D array texture
  12715. * @param data defines the data used to create the texture
  12716. * @param width defines the width of the texture
  12717. * @param height defines the height of the texture
  12718. * @param depth defines the number of layers of the texture
  12719. * @param format defines the format of the texture
  12720. * @param generateMipMaps defines if the engine must generate mip levels
  12721. * @param invertY defines if data must be stored with Y axis inverted
  12722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12723. * @param compression defines the compressed used (can be null)
  12724. * @param textureType defines the compressed used (can be null)
  12725. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12726. */
  12727. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12728. /**
  12729. * Update a raw 2D array texture
  12730. * @param texture defines the texture to update
  12731. * @param data defines the data to store
  12732. * @param format defines the data format
  12733. * @param invertY defines if data must be stored with Y axis inverted
  12734. */
  12735. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12736. /**
  12737. * Update a raw 2D array texture
  12738. * @param texture defines the texture to update
  12739. * @param data defines the data to store
  12740. * @param format defines the data format
  12741. * @param invertY defines if data must be stored with Y axis inverted
  12742. * @param compression defines the used compression (can be null)
  12743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12744. */
  12745. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12746. }
  12747. }
  12748. declare module BABYLON {
  12749. /**
  12750. * Raw texture can help creating a texture directly from an array of data.
  12751. * This can be super useful if you either get the data from an uncompressed source or
  12752. * if you wish to create your texture pixel by pixel.
  12753. */
  12754. export class RawTexture extends Texture {
  12755. /**
  12756. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12757. */
  12758. format: number;
  12759. private _engine;
  12760. /**
  12761. * Instantiates a new RawTexture.
  12762. * Raw texture can help creating a texture directly from an array of data.
  12763. * This can be super useful if you either get the data from an uncompressed source or
  12764. * if you wish to create your texture pixel by pixel.
  12765. * @param data define the array of data to use to create the texture
  12766. * @param width define the width of the texture
  12767. * @param height define the height of the texture
  12768. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12769. * @param scene define the scene the texture belongs to
  12770. * @param generateMipMaps define whether mip maps should be generated or not
  12771. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12772. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12773. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12774. */
  12775. constructor(data: ArrayBufferView, width: number, height: number,
  12776. /**
  12777. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12778. */
  12779. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12780. /**
  12781. * Updates the texture underlying data.
  12782. * @param data Define the new data of the texture
  12783. */
  12784. update(data: ArrayBufferView): void;
  12785. /**
  12786. * Creates a luminance texture from some data.
  12787. * @param data Define the texture data
  12788. * @param width Define the width of the texture
  12789. * @param height Define the height of the texture
  12790. * @param scene Define the scene the texture belongs to
  12791. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12792. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12793. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12794. * @returns the luminance texture
  12795. */
  12796. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12797. /**
  12798. * Creates a luminance alpha texture from some data.
  12799. * @param data Define the texture data
  12800. * @param width Define the width of the texture
  12801. * @param height Define the height of the texture
  12802. * @param scene Define the scene the texture belongs to
  12803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12806. * @returns the luminance alpha texture
  12807. */
  12808. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12809. /**
  12810. * Creates an alpha texture from some data.
  12811. * @param data Define the texture data
  12812. * @param width Define the width of the texture
  12813. * @param height Define the height of the texture
  12814. * @param scene Define the scene the texture belongs to
  12815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @returns the alpha texture
  12819. */
  12820. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12821. /**
  12822. * Creates a RGB texture from some data.
  12823. * @param data Define the texture data
  12824. * @param width Define the width of the texture
  12825. * @param height Define the height of the texture
  12826. * @param scene Define the scene the texture belongs to
  12827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12830. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12831. * @returns the RGB alpha texture
  12832. */
  12833. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12834. /**
  12835. * Creates a RGBA texture from some data.
  12836. * @param data Define the texture data
  12837. * @param width Define the width of the texture
  12838. * @param height Define the height of the texture
  12839. * @param scene Define the scene the texture belongs to
  12840. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12841. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12842. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12843. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12844. * @returns the RGBA texture
  12845. */
  12846. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12847. /**
  12848. * Creates a R texture from some data.
  12849. * @param data Define the texture data
  12850. * @param width Define the width of the texture
  12851. * @param height Define the height of the texture
  12852. * @param scene Define the scene the texture belongs to
  12853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12856. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12857. * @returns the R texture
  12858. */
  12859. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12860. }
  12861. }
  12862. declare module BABYLON {
  12863. /**
  12864. * Interface for the size containing width and height
  12865. */
  12866. export interface ISize {
  12867. /**
  12868. * Width
  12869. */
  12870. width: number;
  12871. /**
  12872. * Heighht
  12873. */
  12874. height: number;
  12875. }
  12876. /**
  12877. * Size containing widht and height
  12878. */
  12879. export class Size implements ISize {
  12880. /**
  12881. * Width
  12882. */
  12883. width: number;
  12884. /**
  12885. * Height
  12886. */
  12887. height: number;
  12888. /**
  12889. * Creates a Size object from the given width and height (floats).
  12890. * @param width width of the new size
  12891. * @param height height of the new size
  12892. */
  12893. constructor(width: number, height: number);
  12894. /**
  12895. * Returns a string with the Size width and height
  12896. * @returns a string with the Size width and height
  12897. */
  12898. toString(): string;
  12899. /**
  12900. * "Size"
  12901. * @returns the string "Size"
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Returns the Size hash code.
  12906. * @returns a hash code for a unique width and height
  12907. */
  12908. getHashCode(): number;
  12909. /**
  12910. * Updates the current size from the given one.
  12911. * @param src the given size
  12912. */
  12913. copyFrom(src: Size): void;
  12914. /**
  12915. * Updates in place the current Size from the given floats.
  12916. * @param width width of the new size
  12917. * @param height height of the new size
  12918. * @returns the updated Size.
  12919. */
  12920. copyFromFloats(width: number, height: number): Size;
  12921. /**
  12922. * Updates in place the current Size from the given floats.
  12923. * @param width width to set
  12924. * @param height height to set
  12925. * @returns the updated Size.
  12926. */
  12927. set(width: number, height: number): Size;
  12928. /**
  12929. * Multiplies the width and height by numbers
  12930. * @param w factor to multiple the width by
  12931. * @param h factor to multiple the height by
  12932. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12933. */
  12934. multiplyByFloats(w: number, h: number): Size;
  12935. /**
  12936. * Clones the size
  12937. * @returns a new Size copied from the given one.
  12938. */
  12939. clone(): Size;
  12940. /**
  12941. * True if the current Size and the given one width and height are strictly equal.
  12942. * @param other the other size to compare against
  12943. * @returns True if the current Size and the given one width and height are strictly equal.
  12944. */
  12945. equals(other: Size): boolean;
  12946. /**
  12947. * The surface of the Size : width * height (float).
  12948. */
  12949. get surface(): number;
  12950. /**
  12951. * Create a new size of zero
  12952. * @returns a new Size set to (0.0, 0.0)
  12953. */
  12954. static Zero(): Size;
  12955. /**
  12956. * Sums the width and height of two sizes
  12957. * @param otherSize size to add to this size
  12958. * @returns a new Size set as the addition result of the current Size and the given one.
  12959. */
  12960. add(otherSize: Size): Size;
  12961. /**
  12962. * Subtracts the width and height of two
  12963. * @param otherSize size to subtract to this size
  12964. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12965. */
  12966. subtract(otherSize: Size): Size;
  12967. /**
  12968. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12969. * @param start starting size to lerp between
  12970. * @param end end size to lerp between
  12971. * @param amount amount to lerp between the start and end values
  12972. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12973. */
  12974. static Lerp(start: Size, end: Size, amount: number): Size;
  12975. }
  12976. }
  12977. declare module BABYLON {
  12978. /**
  12979. * Defines a runtime animation
  12980. */
  12981. export class RuntimeAnimation {
  12982. private _events;
  12983. /**
  12984. * The current frame of the runtime animation
  12985. */
  12986. private _currentFrame;
  12987. /**
  12988. * The animation used by the runtime animation
  12989. */
  12990. private _animation;
  12991. /**
  12992. * The target of the runtime animation
  12993. */
  12994. private _target;
  12995. /**
  12996. * The initiating animatable
  12997. */
  12998. private _host;
  12999. /**
  13000. * The original value of the runtime animation
  13001. */
  13002. private _originalValue;
  13003. /**
  13004. * The original blend value of the runtime animation
  13005. */
  13006. private _originalBlendValue;
  13007. /**
  13008. * The offsets cache of the runtime animation
  13009. */
  13010. private _offsetsCache;
  13011. /**
  13012. * The high limits cache of the runtime animation
  13013. */
  13014. private _highLimitsCache;
  13015. /**
  13016. * Specifies if the runtime animation has been stopped
  13017. */
  13018. private _stopped;
  13019. /**
  13020. * The blending factor of the runtime animation
  13021. */
  13022. private _blendingFactor;
  13023. /**
  13024. * The BabylonJS scene
  13025. */
  13026. private _scene;
  13027. /**
  13028. * The current value of the runtime animation
  13029. */
  13030. private _currentValue;
  13031. /** @hidden */
  13032. _animationState: _IAnimationState;
  13033. /**
  13034. * The active target of the runtime animation
  13035. */
  13036. private _activeTargets;
  13037. private _currentActiveTarget;
  13038. private _directTarget;
  13039. /**
  13040. * The target path of the runtime animation
  13041. */
  13042. private _targetPath;
  13043. /**
  13044. * The weight of the runtime animation
  13045. */
  13046. private _weight;
  13047. /**
  13048. * The ratio offset of the runtime animation
  13049. */
  13050. private _ratioOffset;
  13051. /**
  13052. * The previous delay of the runtime animation
  13053. */
  13054. private _previousDelay;
  13055. /**
  13056. * The previous ratio of the runtime animation
  13057. */
  13058. private _previousRatio;
  13059. private _enableBlending;
  13060. private _keys;
  13061. private _minFrame;
  13062. private _maxFrame;
  13063. private _minValue;
  13064. private _maxValue;
  13065. private _targetIsArray;
  13066. /**
  13067. * Gets the current frame of the runtime animation
  13068. */
  13069. get currentFrame(): number;
  13070. /**
  13071. * Gets the weight of the runtime animation
  13072. */
  13073. get weight(): number;
  13074. /**
  13075. * Gets the current value of the runtime animation
  13076. */
  13077. get currentValue(): any;
  13078. /**
  13079. * Gets the target path of the runtime animation
  13080. */
  13081. get targetPath(): string;
  13082. /**
  13083. * Gets the actual target of the runtime animation
  13084. */
  13085. get target(): any;
  13086. /** @hidden */
  13087. _onLoop: () => void;
  13088. /**
  13089. * Create a new RuntimeAnimation object
  13090. * @param target defines the target of the animation
  13091. * @param animation defines the source animation object
  13092. * @param scene defines the hosting scene
  13093. * @param host defines the initiating Animatable
  13094. */
  13095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13096. private _preparePath;
  13097. /**
  13098. * Gets the animation from the runtime animation
  13099. */
  13100. get animation(): Animation;
  13101. /**
  13102. * Resets the runtime animation to the beginning
  13103. * @param restoreOriginal defines whether to restore the target property to the original value
  13104. */
  13105. reset(restoreOriginal?: boolean): void;
  13106. /**
  13107. * Specifies if the runtime animation is stopped
  13108. * @returns Boolean specifying if the runtime animation is stopped
  13109. */
  13110. isStopped(): boolean;
  13111. /**
  13112. * Disposes of the runtime animation
  13113. */
  13114. dispose(): void;
  13115. /**
  13116. * Apply the interpolated value to the target
  13117. * @param currentValue defines the value computed by the animation
  13118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13119. */
  13120. setValue(currentValue: any, weight: number): void;
  13121. private _getOriginalValues;
  13122. private _setValue;
  13123. /**
  13124. * Gets the loop pmode of the runtime animation
  13125. * @returns Loop Mode
  13126. */
  13127. private _getCorrectLoopMode;
  13128. /**
  13129. * Move the current animation to a given frame
  13130. * @param frame defines the frame to move to
  13131. */
  13132. goToFrame(frame: number): void;
  13133. /**
  13134. * @hidden Internal use only
  13135. */
  13136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13137. /**
  13138. * Execute the current animation
  13139. * @param delay defines the delay to add to the current frame
  13140. * @param from defines the lower bound of the animation range
  13141. * @param to defines the upper bound of the animation range
  13142. * @param loop defines if the current animation must loop
  13143. * @param speedRatio defines the current speed ratio
  13144. * @param weight defines the weight of the animation (default is -1 so no weight)
  13145. * @param onLoop optional callback called when animation loops
  13146. * @returns a boolean indicating if the animation is running
  13147. */
  13148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13149. }
  13150. }
  13151. declare module BABYLON {
  13152. /**
  13153. * Class used to store an actual running animation
  13154. */
  13155. export class Animatable {
  13156. /** defines the target object */
  13157. target: any;
  13158. /** defines the starting frame number (default is 0) */
  13159. fromFrame: number;
  13160. /** defines the ending frame number (default is 100) */
  13161. toFrame: number;
  13162. /** defines if the animation must loop (default is false) */
  13163. loopAnimation: boolean;
  13164. /** defines a callback to call when animation ends if it is not looping */
  13165. onAnimationEnd?: (() => void) | null | undefined;
  13166. /** defines a callback to call when animation loops */
  13167. onAnimationLoop?: (() => void) | null | undefined;
  13168. private _localDelayOffset;
  13169. private _pausedDelay;
  13170. private _runtimeAnimations;
  13171. private _paused;
  13172. private _scene;
  13173. private _speedRatio;
  13174. private _weight;
  13175. private _syncRoot;
  13176. /**
  13177. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13178. * This will only apply for non looping animation (default is true)
  13179. */
  13180. disposeOnEnd: boolean;
  13181. /**
  13182. * Gets a boolean indicating if the animation has started
  13183. */
  13184. animationStarted: boolean;
  13185. /**
  13186. * Observer raised when the animation ends
  13187. */
  13188. onAnimationEndObservable: Observable<Animatable>;
  13189. /**
  13190. * Observer raised when the animation loops
  13191. */
  13192. onAnimationLoopObservable: Observable<Animatable>;
  13193. /**
  13194. * Gets the root Animatable used to synchronize and normalize animations
  13195. */
  13196. get syncRoot(): Nullable<Animatable>;
  13197. /**
  13198. * Gets the current frame of the first RuntimeAnimation
  13199. * Used to synchronize Animatables
  13200. */
  13201. get masterFrame(): number;
  13202. /**
  13203. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13204. */
  13205. get weight(): number;
  13206. set weight(value: number);
  13207. /**
  13208. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13209. */
  13210. get speedRatio(): number;
  13211. set speedRatio(value: number);
  13212. /**
  13213. * Creates a new Animatable
  13214. * @param scene defines the hosting scene
  13215. * @param target defines the target object
  13216. * @param fromFrame defines the starting frame number (default is 0)
  13217. * @param toFrame defines the ending frame number (default is 100)
  13218. * @param loopAnimation defines if the animation must loop (default is false)
  13219. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13220. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13221. * @param animations defines a group of animation to add to the new Animatable
  13222. * @param onAnimationLoop defines a callback to call when animation loops
  13223. */
  13224. constructor(scene: Scene,
  13225. /** defines the target object */
  13226. target: any,
  13227. /** defines the starting frame number (default is 0) */
  13228. fromFrame?: number,
  13229. /** defines the ending frame number (default is 100) */
  13230. toFrame?: number,
  13231. /** defines if the animation must loop (default is false) */
  13232. loopAnimation?: boolean, speedRatio?: number,
  13233. /** defines a callback to call when animation ends if it is not looping */
  13234. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13235. /** defines a callback to call when animation loops */
  13236. onAnimationLoop?: (() => void) | null | undefined);
  13237. /**
  13238. * Synchronize and normalize current Animatable with a source Animatable
  13239. * This is useful when using animation weights and when animations are not of the same length
  13240. * @param root defines the root Animatable to synchronize with
  13241. * @returns the current Animatable
  13242. */
  13243. syncWith(root: Animatable): Animatable;
  13244. /**
  13245. * Gets the list of runtime animations
  13246. * @returns an array of RuntimeAnimation
  13247. */
  13248. getAnimations(): RuntimeAnimation[];
  13249. /**
  13250. * Adds more animations to the current animatable
  13251. * @param target defines the target of the animations
  13252. * @param animations defines the new animations to add
  13253. */
  13254. appendAnimations(target: any, animations: Animation[]): void;
  13255. /**
  13256. * Gets the source animation for a specific property
  13257. * @param property defines the propertyu to look for
  13258. * @returns null or the source animation for the given property
  13259. */
  13260. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13261. /**
  13262. * Gets the runtime animation for a specific property
  13263. * @param property defines the propertyu to look for
  13264. * @returns null or the runtime animation for the given property
  13265. */
  13266. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13267. /**
  13268. * Resets the animatable to its original state
  13269. */
  13270. reset(): void;
  13271. /**
  13272. * Allows the animatable to blend with current running animations
  13273. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13274. * @param blendingSpeed defines the blending speed to use
  13275. */
  13276. enableBlending(blendingSpeed: number): void;
  13277. /**
  13278. * Disable animation blending
  13279. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13280. */
  13281. disableBlending(): void;
  13282. /**
  13283. * Jump directly to a given frame
  13284. * @param frame defines the frame to jump to
  13285. */
  13286. goToFrame(frame: number): void;
  13287. /**
  13288. * Pause the animation
  13289. */
  13290. pause(): void;
  13291. /**
  13292. * Restart the animation
  13293. */
  13294. restart(): void;
  13295. private _raiseOnAnimationEnd;
  13296. /**
  13297. * Stop and delete the current animation
  13298. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13299. * @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)
  13300. */
  13301. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13302. /**
  13303. * Wait asynchronously for the animation to end
  13304. * @returns a promise which will be fullfilled when the animation ends
  13305. */
  13306. waitAsync(): Promise<Animatable>;
  13307. /** @hidden */
  13308. _animate(delay: number): boolean;
  13309. }
  13310. interface Scene {
  13311. /** @hidden */
  13312. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13313. /** @hidden */
  13314. _processLateAnimationBindingsForMatrices(holder: {
  13315. totalWeight: number;
  13316. animations: RuntimeAnimation[];
  13317. originalValue: Matrix;
  13318. }): any;
  13319. /** @hidden */
  13320. _processLateAnimationBindingsForQuaternions(holder: {
  13321. totalWeight: number;
  13322. animations: RuntimeAnimation[];
  13323. originalValue: Quaternion;
  13324. }, refQuaternion: Quaternion): Quaternion;
  13325. /** @hidden */
  13326. _processLateAnimationBindings(): void;
  13327. /**
  13328. * Will start the animation sequence of a given target
  13329. * @param target defines the target
  13330. * @param from defines from which frame should animation start
  13331. * @param to defines until which frame should animation run.
  13332. * @param weight defines the weight to apply to the animation (1.0 by default)
  13333. * @param loop defines if the animation loops
  13334. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13335. * @param onAnimationEnd defines the function to be executed when the animation ends
  13336. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13337. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13338. * @param onAnimationLoop defines the callback to call when an animation loops
  13339. * @returns the animatable object created for this animation
  13340. */
  13341. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13342. /**
  13343. * Will start the animation sequence of a given target
  13344. * @param target defines the target
  13345. * @param from defines from which frame should animation start
  13346. * @param to defines until which frame should animation run.
  13347. * @param loop defines if the animation loops
  13348. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13349. * @param onAnimationEnd defines the function to be executed when the animation ends
  13350. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13351. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13352. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13353. * @param onAnimationLoop defines the callback to call when an animation loops
  13354. * @returns the animatable object created for this animation
  13355. */
  13356. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13357. /**
  13358. * Will start the animation sequence of a given target and its hierarchy
  13359. * @param target defines the target
  13360. * @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.
  13361. * @param from defines from which frame should animation start
  13362. * @param to defines until which frame should animation run.
  13363. * @param loop defines if the animation loops
  13364. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13365. * @param onAnimationEnd defines the function to be executed when the animation ends
  13366. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13367. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the list of created animatables
  13371. */
  13372. 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[];
  13373. /**
  13374. * Begin a new animation on a given node
  13375. * @param target defines the target where the animation will take place
  13376. * @param animations defines the list of animations to start
  13377. * @param from defines the initial value
  13378. * @param to defines the final value
  13379. * @param loop defines if you want animation to loop (off by default)
  13380. * @param speedRatio defines the speed ratio to apply to all animations
  13381. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13382. * @param onAnimationLoop defines the callback to call when an animation loops
  13383. * @returns the list of created animatables
  13384. */
  13385. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13386. /**
  13387. * Begin a new animation on a given node and its hierarchy
  13388. * @param target defines the root node where the animation will take place
  13389. * @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.
  13390. * @param animations defines the list of animations to start
  13391. * @param from defines the initial value
  13392. * @param to defines the final value
  13393. * @param loop defines if you want animation to loop (off by default)
  13394. * @param speedRatio defines the speed ratio to apply to all animations
  13395. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13396. * @param onAnimationLoop defines the callback to call when an animation loops
  13397. * @returns the list of animatables created for all nodes
  13398. */
  13399. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13400. /**
  13401. * Gets the animatable associated with a specific target
  13402. * @param target defines the target of the animatable
  13403. * @returns the required animatable if found
  13404. */
  13405. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13406. /**
  13407. * Gets all animatables associated with a given target
  13408. * @param target defines the target to look animatables for
  13409. * @returns an array of Animatables
  13410. */
  13411. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13412. /**
  13413. * Stops and removes all animations that have been applied to the scene
  13414. */
  13415. stopAllAnimations(): void;
  13416. /**
  13417. * Gets the current delta time used by animation engine
  13418. */
  13419. deltaTime: number;
  13420. }
  13421. interface Bone {
  13422. /**
  13423. * Copy an animation range from another bone
  13424. * @param source defines the source bone
  13425. * @param rangeName defines the range name to copy
  13426. * @param frameOffset defines the frame offset
  13427. * @param rescaleAsRequired defines if rescaling must be applied if required
  13428. * @param skelDimensionsRatio defines the scaling ratio
  13429. * @returns true if operation was successful
  13430. */
  13431. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13432. }
  13433. }
  13434. declare module BABYLON {
  13435. /**
  13436. * Class used to override all child animations of a given target
  13437. */
  13438. export class AnimationPropertiesOverride {
  13439. /**
  13440. * Gets or sets a value indicating if animation blending must be used
  13441. */
  13442. enableBlending: boolean;
  13443. /**
  13444. * Gets or sets the blending speed to use when enableBlending is true
  13445. */
  13446. blendingSpeed: number;
  13447. /**
  13448. * Gets or sets the default loop mode to use
  13449. */
  13450. loopMode: number;
  13451. }
  13452. }
  13453. declare module BABYLON {
  13454. /**
  13455. * Class used to handle skinning animations
  13456. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13457. */
  13458. export class Skeleton implements IAnimatable {
  13459. /** defines the skeleton name */
  13460. name: string;
  13461. /** defines the skeleton Id */
  13462. id: string;
  13463. /**
  13464. * Defines the list of child bones
  13465. */
  13466. bones: Bone[];
  13467. /**
  13468. * Defines an estimate of the dimension of the skeleton at rest
  13469. */
  13470. dimensionsAtRest: Vector3;
  13471. /**
  13472. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13473. */
  13474. needInitialSkinMatrix: boolean;
  13475. /**
  13476. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13477. */
  13478. overrideMesh: Nullable<AbstractMesh>;
  13479. /**
  13480. * Gets the list of animations attached to this skeleton
  13481. */
  13482. animations: Array<Animation>;
  13483. private _scene;
  13484. private _isDirty;
  13485. private _transformMatrices;
  13486. private _transformMatrixTexture;
  13487. private _meshesWithPoseMatrix;
  13488. private _animatables;
  13489. private _identity;
  13490. private _synchronizedWithMesh;
  13491. private _ranges;
  13492. private _lastAbsoluteTransformsUpdateId;
  13493. private _canUseTextureForBones;
  13494. private _uniqueId;
  13495. /** @hidden */
  13496. _numBonesWithLinkedTransformNode: number;
  13497. /** @hidden */
  13498. _hasWaitingData: Nullable<boolean>;
  13499. /**
  13500. * Specifies if the skeleton should be serialized
  13501. */
  13502. doNotSerialize: boolean;
  13503. private _useTextureToStoreBoneMatrices;
  13504. /**
  13505. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13506. * Please note that this option is not available if the hardware does not support it
  13507. */
  13508. get useTextureToStoreBoneMatrices(): boolean;
  13509. set useTextureToStoreBoneMatrices(value: boolean);
  13510. private _animationPropertiesOverride;
  13511. /**
  13512. * Gets or sets the animation properties override
  13513. */
  13514. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13515. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13516. /**
  13517. * List of inspectable custom properties (used by the Inspector)
  13518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13519. */
  13520. inspectableCustomProperties: IInspectable[];
  13521. /**
  13522. * An observable triggered before computing the skeleton's matrices
  13523. */
  13524. onBeforeComputeObservable: Observable<Skeleton>;
  13525. /**
  13526. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13527. */
  13528. get isUsingTextureForMatrices(): boolean;
  13529. /**
  13530. * Gets the unique ID of this skeleton
  13531. */
  13532. get uniqueId(): number;
  13533. /**
  13534. * Creates a new skeleton
  13535. * @param name defines the skeleton name
  13536. * @param id defines the skeleton Id
  13537. * @param scene defines the hosting scene
  13538. */
  13539. constructor(
  13540. /** defines the skeleton name */
  13541. name: string,
  13542. /** defines the skeleton Id */
  13543. id: string, scene: Scene);
  13544. /**
  13545. * Gets the current object class name.
  13546. * @return the class name
  13547. */
  13548. getClassName(): string;
  13549. /**
  13550. * Returns an array containing the root bones
  13551. * @returns an array containing the root bones
  13552. */
  13553. getChildren(): Array<Bone>;
  13554. /**
  13555. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13556. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13557. * @returns a Float32Array containing matrices data
  13558. */
  13559. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13560. /**
  13561. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13562. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13563. * @returns a raw texture containing the data
  13564. */
  13565. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13566. /**
  13567. * Gets the current hosting scene
  13568. * @returns a scene object
  13569. */
  13570. getScene(): Scene;
  13571. /**
  13572. * Gets a string representing the current skeleton data
  13573. * @param fullDetails defines a boolean indicating if we want a verbose version
  13574. * @returns a string representing the current skeleton data
  13575. */
  13576. toString(fullDetails?: boolean): string;
  13577. /**
  13578. * Get bone's index searching by name
  13579. * @param name defines bone's name to search for
  13580. * @return the indice of the bone. Returns -1 if not found
  13581. */
  13582. getBoneIndexByName(name: string): number;
  13583. /**
  13584. * Creater a new animation range
  13585. * @param name defines the name of the range
  13586. * @param from defines the start key
  13587. * @param to defines the end key
  13588. */
  13589. createAnimationRange(name: string, from: number, to: number): void;
  13590. /**
  13591. * Delete a specific animation range
  13592. * @param name defines the name of the range
  13593. * @param deleteFrames defines if frames must be removed as well
  13594. */
  13595. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13596. /**
  13597. * Gets a specific animation range
  13598. * @param name defines the name of the range to look for
  13599. * @returns the requested animation range or null if not found
  13600. */
  13601. getAnimationRange(name: string): Nullable<AnimationRange>;
  13602. /**
  13603. * Gets the list of all animation ranges defined on this skeleton
  13604. * @returns an array
  13605. */
  13606. getAnimationRanges(): Nullable<AnimationRange>[];
  13607. /**
  13608. * Copy animation range from a source skeleton.
  13609. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13610. * @param source defines the source skeleton
  13611. * @param name defines the name of the range to copy
  13612. * @param rescaleAsRequired defines if rescaling must be applied if required
  13613. * @returns true if operation was successful
  13614. */
  13615. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13616. /**
  13617. * Forces the skeleton to go to rest pose
  13618. */
  13619. returnToRest(): void;
  13620. private _getHighestAnimationFrame;
  13621. /**
  13622. * Begin a specific animation range
  13623. * @param name defines the name of the range to start
  13624. * @param loop defines if looping must be turned on (false by default)
  13625. * @param speedRatio defines the speed ratio to apply (1 by default)
  13626. * @param onAnimationEnd defines a callback which will be called when animation will end
  13627. * @returns a new animatable
  13628. */
  13629. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13630. /** @hidden */
  13631. _markAsDirty(): void;
  13632. /** @hidden */
  13633. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13634. /** @hidden */
  13635. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13636. private _computeTransformMatrices;
  13637. /**
  13638. * Build all resources required to render a skeleton
  13639. */
  13640. prepare(): void;
  13641. /**
  13642. * Gets the list of animatables currently running for this skeleton
  13643. * @returns an array of animatables
  13644. */
  13645. getAnimatables(): IAnimatable[];
  13646. /**
  13647. * Clone the current skeleton
  13648. * @param name defines the name of the new skeleton
  13649. * @param id defines the id of the new skeleton
  13650. * @returns the new skeleton
  13651. */
  13652. clone(name: string, id?: string): Skeleton;
  13653. /**
  13654. * Enable animation blending for this skeleton
  13655. * @param blendingSpeed defines the blending speed to apply
  13656. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13657. */
  13658. enableBlending(blendingSpeed?: number): void;
  13659. /**
  13660. * Releases all resources associated with the current skeleton
  13661. */
  13662. dispose(): void;
  13663. /**
  13664. * Serialize the skeleton in a JSON object
  13665. * @returns a JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Creates a new skeleton from serialized data
  13670. * @param parsedSkeleton defines the serialized data
  13671. * @param scene defines the hosting scene
  13672. * @returns a new skeleton
  13673. */
  13674. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13675. /**
  13676. * Compute all node absolute transforms
  13677. * @param forceUpdate defines if computation must be done even if cache is up to date
  13678. */
  13679. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13680. /**
  13681. * Gets the root pose matrix
  13682. * @returns a matrix
  13683. */
  13684. getPoseMatrix(): Nullable<Matrix>;
  13685. /**
  13686. * Sorts bones per internal index
  13687. */
  13688. sortBones(): void;
  13689. private _sortBones;
  13690. }
  13691. }
  13692. declare module BABYLON {
  13693. /**
  13694. * Class used to store bone information
  13695. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13696. */
  13697. export class Bone extends Node {
  13698. /**
  13699. * defines the bone name
  13700. */
  13701. name: string;
  13702. private static _tmpVecs;
  13703. private static _tmpQuat;
  13704. private static _tmpMats;
  13705. /**
  13706. * Gets the list of child bones
  13707. */
  13708. children: Bone[];
  13709. /** Gets the animations associated with this bone */
  13710. animations: Animation[];
  13711. /**
  13712. * Gets or sets bone length
  13713. */
  13714. length: number;
  13715. /**
  13716. * @hidden Internal only
  13717. * Set this value to map this bone to a different index in the transform matrices
  13718. * Set this value to -1 to exclude the bone from the transform matrices
  13719. */
  13720. _index: Nullable<number>;
  13721. private _skeleton;
  13722. private _localMatrix;
  13723. private _restPose;
  13724. private _baseMatrix;
  13725. private _absoluteTransform;
  13726. private _invertedAbsoluteTransform;
  13727. private _parent;
  13728. private _scalingDeterminant;
  13729. private _worldTransform;
  13730. private _localScaling;
  13731. private _localRotation;
  13732. private _localPosition;
  13733. private _needToDecompose;
  13734. private _needToCompose;
  13735. /** @hidden */
  13736. _linkedTransformNode: Nullable<TransformNode>;
  13737. /** @hidden */
  13738. _waitingTransformNodeId: Nullable<string>;
  13739. /** @hidden */
  13740. get _matrix(): Matrix;
  13741. /** @hidden */
  13742. set _matrix(value: Matrix);
  13743. /**
  13744. * Create a new bone
  13745. * @param name defines the bone name
  13746. * @param skeleton defines the parent skeleton
  13747. * @param parentBone defines the parent (can be null if the bone is the root)
  13748. * @param localMatrix defines the local matrix
  13749. * @param restPose defines the rest pose matrix
  13750. * @param baseMatrix defines the base matrix
  13751. * @param index defines index of the bone in the hiearchy
  13752. */
  13753. constructor(
  13754. /**
  13755. * defines the bone name
  13756. */
  13757. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13758. /**
  13759. * Gets the current object class name.
  13760. * @return the class name
  13761. */
  13762. getClassName(): string;
  13763. /**
  13764. * Gets the parent skeleton
  13765. * @returns a skeleton
  13766. */
  13767. getSkeleton(): Skeleton;
  13768. /**
  13769. * Gets parent bone
  13770. * @returns a bone or null if the bone is the root of the bone hierarchy
  13771. */
  13772. getParent(): Nullable<Bone>;
  13773. /**
  13774. * Returns an array containing the root bones
  13775. * @returns an array containing the root bones
  13776. */
  13777. getChildren(): Array<Bone>;
  13778. /**
  13779. * Gets the node index in matrix array generated for rendering
  13780. * @returns the node index
  13781. */
  13782. getIndex(): number;
  13783. /**
  13784. * Sets the parent bone
  13785. * @param parent defines the parent (can be null if the bone is the root)
  13786. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13787. */
  13788. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13789. /**
  13790. * Gets the local matrix
  13791. * @returns a matrix
  13792. */
  13793. getLocalMatrix(): Matrix;
  13794. /**
  13795. * Gets the base matrix (initial matrix which remains unchanged)
  13796. * @returns a matrix
  13797. */
  13798. getBaseMatrix(): Matrix;
  13799. /**
  13800. * Gets the rest pose matrix
  13801. * @returns a matrix
  13802. */
  13803. getRestPose(): Matrix;
  13804. /**
  13805. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13806. */
  13807. getWorldMatrix(): Matrix;
  13808. /**
  13809. * Sets the local matrix to rest pose matrix
  13810. */
  13811. returnToRest(): void;
  13812. /**
  13813. * Gets the inverse of the absolute transform matrix.
  13814. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13815. * @returns a matrix
  13816. */
  13817. getInvertedAbsoluteTransform(): Matrix;
  13818. /**
  13819. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13820. * @returns a matrix
  13821. */
  13822. getAbsoluteTransform(): Matrix;
  13823. /**
  13824. * Links with the given transform node.
  13825. * The local matrix of this bone is copied from the transform node every frame.
  13826. * @param transformNode defines the transform node to link to
  13827. */
  13828. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13829. /**
  13830. * Gets the node used to drive the bone's transformation
  13831. * @returns a transform node or null
  13832. */
  13833. getTransformNode(): Nullable<TransformNode>;
  13834. /** Gets or sets current position (in local space) */
  13835. get position(): Vector3;
  13836. set position(newPosition: Vector3);
  13837. /** Gets or sets current rotation (in local space) */
  13838. get rotation(): Vector3;
  13839. set rotation(newRotation: Vector3);
  13840. /** Gets or sets current rotation quaternion (in local space) */
  13841. get rotationQuaternion(): Quaternion;
  13842. set rotationQuaternion(newRotation: Quaternion);
  13843. /** Gets or sets current scaling (in local space) */
  13844. get scaling(): Vector3;
  13845. set scaling(newScaling: Vector3);
  13846. /**
  13847. * Gets the animation properties override
  13848. */
  13849. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13850. private _decompose;
  13851. private _compose;
  13852. /**
  13853. * Update the base and local matrices
  13854. * @param matrix defines the new base or local matrix
  13855. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13856. * @param updateLocalMatrix defines if the local matrix should be updated
  13857. */
  13858. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13859. /** @hidden */
  13860. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13861. /**
  13862. * Flag the bone as dirty (Forcing it to update everything)
  13863. */
  13864. markAsDirty(): void;
  13865. /** @hidden */
  13866. _markAsDirtyAndCompose(): void;
  13867. private _markAsDirtyAndDecompose;
  13868. /**
  13869. * Translate the bone in local or world space
  13870. * @param vec The amount to translate the bone
  13871. * @param space The space that the translation is in
  13872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13873. */
  13874. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13875. /**
  13876. * Set the postion of the bone in local or world space
  13877. * @param position The position to set the bone
  13878. * @param space The space that the position is in
  13879. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13880. */
  13881. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13882. /**
  13883. * Set the absolute position of the bone (world space)
  13884. * @param position The position to set the bone
  13885. * @param mesh The mesh that this bone is attached to
  13886. */
  13887. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13888. /**
  13889. * Scale the bone on the x, y and z axes (in local space)
  13890. * @param x The amount to scale the bone on the x axis
  13891. * @param y The amount to scale the bone on the y axis
  13892. * @param z The amount to scale the bone on the z axis
  13893. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13894. */
  13895. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13896. /**
  13897. * Set the bone scaling in local space
  13898. * @param scale defines the scaling vector
  13899. */
  13900. setScale(scale: Vector3): void;
  13901. /**
  13902. * Gets the current scaling in local space
  13903. * @returns the current scaling vector
  13904. */
  13905. getScale(): Vector3;
  13906. /**
  13907. * Gets the current scaling in local space and stores it in a target vector
  13908. * @param result defines the target vector
  13909. */
  13910. getScaleToRef(result: Vector3): void;
  13911. /**
  13912. * Set the yaw, pitch, and roll of the bone in local or world space
  13913. * @param yaw The rotation of the bone on the y axis
  13914. * @param pitch The rotation of the bone on the x axis
  13915. * @param roll The rotation of the bone on the z axis
  13916. * @param space The space that the axes of rotation are in
  13917. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13918. */
  13919. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13920. /**
  13921. * Add a rotation to the bone on an axis in local or world space
  13922. * @param axis The axis to rotate the bone on
  13923. * @param amount The amount to rotate the bone
  13924. * @param space The space that the axis is in
  13925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13926. */
  13927. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13928. /**
  13929. * Set the rotation of the bone to a particular axis angle in local or world space
  13930. * @param axis The axis to rotate the bone on
  13931. * @param angle The angle that the bone should be rotated to
  13932. * @param space The space that the axis is in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. */
  13935. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Set the euler rotation of the bone in local of world space
  13938. * @param rotation The euler rotation that the bone should be set to
  13939. * @param space The space that the rotation is in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. */
  13942. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13943. /**
  13944. * Set the quaternion rotation of the bone in local of world space
  13945. * @param quat The quaternion rotation that the bone should be set to
  13946. * @param space The space that the rotation is in
  13947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13948. */
  13949. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13950. /**
  13951. * Set the rotation matrix of the bone in local of world space
  13952. * @param rotMat The rotation matrix that the bone should be set to
  13953. * @param space The space that the rotation is in
  13954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13955. */
  13956. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13957. private _rotateWithMatrix;
  13958. private _getNegativeRotationToRef;
  13959. /**
  13960. * Get the position of the bone in local or world space
  13961. * @param space The space that the returned position is in
  13962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13963. * @returns The position of the bone
  13964. */
  13965. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13966. /**
  13967. * Copy the position of the bone to a vector3 in local or world space
  13968. * @param space The space that the returned position is in
  13969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13970. * @param result The vector3 to copy the position to
  13971. */
  13972. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13973. /**
  13974. * Get the absolute position of the bone (world space)
  13975. * @param mesh The mesh that this bone is attached to
  13976. * @returns The absolute position of the bone
  13977. */
  13978. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13979. /**
  13980. * Copy the absolute position of the bone (world space) to the result param
  13981. * @param mesh The mesh that this bone is attached to
  13982. * @param result The vector3 to copy the absolute position to
  13983. */
  13984. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13985. /**
  13986. * Compute the absolute transforms of this bone and its children
  13987. */
  13988. computeAbsoluteTransforms(): void;
  13989. /**
  13990. * Get the world direction from an axis that is in the local space of the bone
  13991. * @param localAxis The local direction that is used to compute the world direction
  13992. * @param mesh The mesh that this bone is attached to
  13993. * @returns The world direction
  13994. */
  13995. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13996. /**
  13997. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13998. * @param localAxis The local direction that is used to compute the world direction
  13999. * @param mesh The mesh that this bone is attached to
  14000. * @param result The vector3 that the world direction will be copied to
  14001. */
  14002. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14003. /**
  14004. * Get the euler rotation of the bone in local or world space
  14005. * @param space The space that the rotation should be in
  14006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14007. * @returns The euler rotation
  14008. */
  14009. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14010. /**
  14011. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14012. * @param space The space that the rotation should be in
  14013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14014. * @param result The vector3 that the rotation should be copied to
  14015. */
  14016. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14017. /**
  14018. * Get the quaternion rotation of the bone in either local or world space
  14019. * @param space The space that the rotation should be in
  14020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14021. * @returns The quaternion rotation
  14022. */
  14023. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14024. /**
  14025. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14026. * @param space The space that the rotation should be in
  14027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14028. * @param result The quaternion that the rotation should be copied to
  14029. */
  14030. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14031. /**
  14032. * Get the rotation matrix of the bone in local or world space
  14033. * @param space The space that the rotation should be in
  14034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14035. * @returns The rotation matrix
  14036. */
  14037. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14038. /**
  14039. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14040. * @param space The space that the rotation should be in
  14041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14042. * @param result The quaternion that the rotation should be copied to
  14043. */
  14044. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14045. /**
  14046. * Get the world position of a point that is in the local space of the bone
  14047. * @param position The local position
  14048. * @param mesh The mesh that this bone is attached to
  14049. * @returns The world position
  14050. */
  14051. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14052. /**
  14053. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14054. * @param position The local position
  14055. * @param mesh The mesh that this bone is attached to
  14056. * @param result The vector3 that the world position should be copied to
  14057. */
  14058. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14059. /**
  14060. * Get the local position of a point that is in world space
  14061. * @param position The world position
  14062. * @param mesh The mesh that this bone is attached to
  14063. * @returns The local position
  14064. */
  14065. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14066. /**
  14067. * Get the local position of a point that is in world space and copy it to the result param
  14068. * @param position The world position
  14069. * @param mesh The mesh that this bone is attached to
  14070. * @param result The vector3 that the local position should be copied to
  14071. */
  14072. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14073. }
  14074. }
  14075. declare module BABYLON {
  14076. /**
  14077. * 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.
  14078. * @see https://doc.babylonjs.com/how_to/transformnode
  14079. */
  14080. export class TransformNode extends Node {
  14081. /**
  14082. * Object will not rotate to face the camera
  14083. */
  14084. static BILLBOARDMODE_NONE: number;
  14085. /**
  14086. * Object will rotate to face the camera but only on the x axis
  14087. */
  14088. static BILLBOARDMODE_X: number;
  14089. /**
  14090. * Object will rotate to face the camera but only on the y axis
  14091. */
  14092. static BILLBOARDMODE_Y: number;
  14093. /**
  14094. * Object will rotate to face the camera but only on the z axis
  14095. */
  14096. static BILLBOARDMODE_Z: number;
  14097. /**
  14098. * Object will rotate to face the camera
  14099. */
  14100. static BILLBOARDMODE_ALL: number;
  14101. /**
  14102. * Object will rotate to face the camera's position instead of orientation
  14103. */
  14104. static BILLBOARDMODE_USE_POSITION: number;
  14105. private _forward;
  14106. private _forwardInverted;
  14107. private _up;
  14108. private _right;
  14109. private _rightInverted;
  14110. private _position;
  14111. private _rotation;
  14112. private _rotationQuaternion;
  14113. protected _scaling: Vector3;
  14114. protected _isDirty: boolean;
  14115. private _transformToBoneReferal;
  14116. private _isAbsoluteSynced;
  14117. private _billboardMode;
  14118. /**
  14119. * Gets or sets the billboard mode. Default is 0.
  14120. *
  14121. * | Value | Type | Description |
  14122. * | --- | --- | --- |
  14123. * | 0 | BILLBOARDMODE_NONE | |
  14124. * | 1 | BILLBOARDMODE_X | |
  14125. * | 2 | BILLBOARDMODE_Y | |
  14126. * | 4 | BILLBOARDMODE_Z | |
  14127. * | 7 | BILLBOARDMODE_ALL | |
  14128. *
  14129. */
  14130. get billboardMode(): number;
  14131. set billboardMode(value: number);
  14132. private _preserveParentRotationForBillboard;
  14133. /**
  14134. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14135. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14136. */
  14137. get preserveParentRotationForBillboard(): boolean;
  14138. set preserveParentRotationForBillboard(value: boolean);
  14139. /**
  14140. * 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
  14141. */
  14142. scalingDeterminant: number;
  14143. private _infiniteDistance;
  14144. /**
  14145. * Gets or sets the distance of the object to max, often used by skybox
  14146. */
  14147. get infiniteDistance(): boolean;
  14148. set infiniteDistance(value: boolean);
  14149. /**
  14150. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14151. * By default the system will update normals to compensate
  14152. */
  14153. ignoreNonUniformScaling: boolean;
  14154. /**
  14155. * 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
  14156. */
  14157. reIntegrateRotationIntoRotationQuaternion: boolean;
  14158. /** @hidden */
  14159. _poseMatrix: Nullable<Matrix>;
  14160. /** @hidden */
  14161. _localMatrix: Matrix;
  14162. private _usePivotMatrix;
  14163. private _absolutePosition;
  14164. private _absoluteScaling;
  14165. private _absoluteRotationQuaternion;
  14166. private _pivotMatrix;
  14167. private _pivotMatrixInverse;
  14168. protected _postMultiplyPivotMatrix: boolean;
  14169. protected _isWorldMatrixFrozen: boolean;
  14170. /** @hidden */
  14171. _indexInSceneTransformNodesArray: number;
  14172. /**
  14173. * An event triggered after the world matrix is updated
  14174. */
  14175. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14176. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14177. /**
  14178. * Gets a string identifying the name of the class
  14179. * @returns "TransformNode" string
  14180. */
  14181. getClassName(): string;
  14182. /**
  14183. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14184. */
  14185. get position(): Vector3;
  14186. set position(newPosition: Vector3);
  14187. /**
  14188. * 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)).
  14189. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14190. */
  14191. get rotation(): Vector3;
  14192. set rotation(newRotation: Vector3);
  14193. /**
  14194. * 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)).
  14195. */
  14196. get scaling(): Vector3;
  14197. set scaling(newScaling: Vector3);
  14198. /**
  14199. * 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).
  14200. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14201. */
  14202. get rotationQuaternion(): Nullable<Quaternion>;
  14203. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14204. /**
  14205. * The forward direction of that transform in world space.
  14206. */
  14207. get forward(): Vector3;
  14208. /**
  14209. * The up direction of that transform in world space.
  14210. */
  14211. get up(): Vector3;
  14212. /**
  14213. * The right direction of that transform in world space.
  14214. */
  14215. get right(): Vector3;
  14216. /**
  14217. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14218. * @param matrix the matrix to copy the pose from
  14219. * @returns this TransformNode.
  14220. */
  14221. updatePoseMatrix(matrix: Matrix): TransformNode;
  14222. /**
  14223. * Returns the mesh Pose matrix.
  14224. * @returns the pose matrix
  14225. */
  14226. getPoseMatrix(): Matrix;
  14227. /** @hidden */
  14228. _isSynchronized(): boolean;
  14229. /** @hidden */
  14230. _initCache(): void;
  14231. /**
  14232. * Flag the transform node as dirty (Forcing it to update everything)
  14233. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14234. * @returns this transform node
  14235. */
  14236. markAsDirty(property: string): TransformNode;
  14237. /**
  14238. * Returns the current mesh absolute position.
  14239. * Returns a Vector3.
  14240. */
  14241. get absolutePosition(): Vector3;
  14242. /**
  14243. * Returns the current mesh absolute scaling.
  14244. * Returns a Vector3.
  14245. */
  14246. get absoluteScaling(): Vector3;
  14247. /**
  14248. * Returns the current mesh absolute rotation.
  14249. * Returns a Quaternion.
  14250. */
  14251. get absoluteRotationQuaternion(): Quaternion;
  14252. /**
  14253. * Sets a new matrix to apply before all other transformation
  14254. * @param matrix defines the transform matrix
  14255. * @returns the current TransformNode
  14256. */
  14257. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14258. /**
  14259. * Sets a new pivot matrix to the current node
  14260. * @param matrix defines the new pivot matrix to use
  14261. * @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
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14265. /**
  14266. * Returns the mesh pivot matrix.
  14267. * Default : Identity.
  14268. * @returns the matrix
  14269. */
  14270. getPivotMatrix(): Matrix;
  14271. /**
  14272. * Instantiate (when possible) or clone that node with its hierarchy
  14273. * @param newParent defines the new parent to use for the instance (or clone)
  14274. * @param options defines options to configure how copy is done
  14275. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14276. * @returns an instance (or a clone) of the current node with its hiearchy
  14277. */
  14278. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14279. doNotInstantiate: boolean;
  14280. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14281. /**
  14282. * Prevents the World matrix to be computed any longer
  14283. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14284. * @returns the TransformNode.
  14285. */
  14286. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14287. /**
  14288. * Allows back the World matrix computation.
  14289. * @returns the TransformNode.
  14290. */
  14291. unfreezeWorldMatrix(): this;
  14292. /**
  14293. * True if the World matrix has been frozen.
  14294. */
  14295. get isWorldMatrixFrozen(): boolean;
  14296. /**
  14297. * Retuns the mesh absolute position in the World.
  14298. * @returns a Vector3.
  14299. */
  14300. getAbsolutePosition(): Vector3;
  14301. /**
  14302. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14303. * @param absolutePosition the absolute position to set
  14304. * @returns the TransformNode.
  14305. */
  14306. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14307. /**
  14308. * Sets the mesh position in its local space.
  14309. * @param vector3 the position to set in localspace
  14310. * @returns the TransformNode.
  14311. */
  14312. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14313. /**
  14314. * Returns the mesh position in the local space from the current World matrix values.
  14315. * @returns a new Vector3.
  14316. */
  14317. getPositionExpressedInLocalSpace(): Vector3;
  14318. /**
  14319. * Translates the mesh along the passed Vector3 in its local space.
  14320. * @param vector3 the distance to translate in localspace
  14321. * @returns the TransformNode.
  14322. */
  14323. locallyTranslate(vector3: Vector3): TransformNode;
  14324. private static _lookAtVectorCache;
  14325. /**
  14326. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14327. * @param targetPoint the position (must be in same space as current mesh) to look at
  14328. * @param yawCor optional yaw (y-axis) correction in radians
  14329. * @param pitchCor optional pitch (x-axis) correction in radians
  14330. * @param rollCor optional roll (z-axis) correction in radians
  14331. * @param space the choosen space of the target
  14332. * @returns the TransformNode.
  14333. */
  14334. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14335. /**
  14336. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14337. * This Vector3 is expressed in the World space.
  14338. * @param localAxis axis to rotate
  14339. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14340. */
  14341. getDirection(localAxis: Vector3): Vector3;
  14342. /**
  14343. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14344. * localAxis is expressed in the mesh local space.
  14345. * result is computed in the Wordl space from the mesh World matrix.
  14346. * @param localAxis axis to rotate
  14347. * @param result the resulting transformnode
  14348. * @returns this TransformNode.
  14349. */
  14350. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14351. /**
  14352. * Sets this transform node rotation to the given local axis.
  14353. * @param localAxis the axis in local space
  14354. * @param yawCor optional yaw (y-axis) correction in radians
  14355. * @param pitchCor optional pitch (x-axis) correction in radians
  14356. * @param rollCor optional roll (z-axis) correction in radians
  14357. * @returns this TransformNode
  14358. */
  14359. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14360. /**
  14361. * Sets a new pivot point to the current node
  14362. * @param point defines the new pivot point to use
  14363. * @param space defines if the point is in world or local space (local by default)
  14364. * @returns the current TransformNode
  14365. */
  14366. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14367. /**
  14368. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14369. * @returns the pivot point
  14370. */
  14371. getPivotPoint(): Vector3;
  14372. /**
  14373. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14374. * @param result the vector3 to store the result
  14375. * @returns this TransformNode.
  14376. */
  14377. getPivotPointToRef(result: Vector3): TransformNode;
  14378. /**
  14379. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14380. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14381. */
  14382. getAbsolutePivotPoint(): Vector3;
  14383. /**
  14384. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14385. * @param result vector3 to store the result
  14386. * @returns this TransformNode.
  14387. */
  14388. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14389. /**
  14390. * Defines the passed node as the parent of the current node.
  14391. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14392. * @see https://doc.babylonjs.com/how_to/parenting
  14393. * @param node the node ot set as the parent
  14394. * @returns this TransformNode.
  14395. */
  14396. setParent(node: Nullable<Node>): TransformNode;
  14397. private _nonUniformScaling;
  14398. /**
  14399. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14400. */
  14401. get nonUniformScaling(): boolean;
  14402. /** @hidden */
  14403. _updateNonUniformScalingState(value: boolean): boolean;
  14404. /**
  14405. * Attach the current TransformNode to another TransformNode associated with a bone
  14406. * @param bone Bone affecting the TransformNode
  14407. * @param affectedTransformNode TransformNode associated with the bone
  14408. * @returns this object
  14409. */
  14410. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14411. /**
  14412. * Detach the transform node if its associated with a bone
  14413. * @returns this object
  14414. */
  14415. detachFromBone(): TransformNode;
  14416. private static _rotationAxisCache;
  14417. /**
  14418. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14419. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14420. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14421. * The passed axis is also normalized.
  14422. * @param axis the axis to rotate around
  14423. * @param amount the amount to rotate in radians
  14424. * @param space Space to rotate in (Default: local)
  14425. * @returns the TransformNode.
  14426. */
  14427. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14428. /**
  14429. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14430. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14431. * The passed axis is also normalized. .
  14432. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14433. * @param point the point to rotate around
  14434. * @param axis the axis to rotate around
  14435. * @param amount the amount to rotate in radians
  14436. * @returns the TransformNode
  14437. */
  14438. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14439. /**
  14440. * Translates the mesh along the axis vector for the passed distance in the given space.
  14441. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14442. * @param axis the axis to translate in
  14443. * @param distance the distance to translate
  14444. * @param space Space to rotate in (Default: local)
  14445. * @returns the TransformNode.
  14446. */
  14447. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14448. /**
  14449. * Adds a rotation step to the mesh current rotation.
  14450. * x, y, z are Euler angles expressed in radians.
  14451. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14452. * This means this rotation is made in the mesh local space only.
  14453. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14454. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14455. * ```javascript
  14456. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14457. * ```
  14458. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14459. * 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.
  14460. * @param x Rotation to add
  14461. * @param y Rotation to add
  14462. * @param z Rotation to add
  14463. * @returns the TransformNode.
  14464. */
  14465. addRotation(x: number, y: number, z: number): TransformNode;
  14466. /**
  14467. * @hidden
  14468. */
  14469. protected _getEffectiveParent(): Nullable<Node>;
  14470. /**
  14471. * Computes the world matrix of the node
  14472. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14473. * @returns the world matrix
  14474. */
  14475. computeWorldMatrix(force?: boolean): Matrix;
  14476. protected _afterComputeWorldMatrix(): void;
  14477. /**
  14478. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14479. * @param func callback function to add
  14480. *
  14481. * @returns the TransformNode.
  14482. */
  14483. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14484. /**
  14485. * Removes a registered callback function.
  14486. * @param func callback function to remove
  14487. * @returns the TransformNode.
  14488. */
  14489. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14490. /**
  14491. * Gets the position of the current mesh in camera space
  14492. * @param camera defines the camera to use
  14493. * @returns a position
  14494. */
  14495. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14496. /**
  14497. * Returns the distance from the mesh to the active camera
  14498. * @param camera defines the camera to use
  14499. * @returns the distance
  14500. */
  14501. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14502. /**
  14503. * Clone the current transform node
  14504. * @param name Name of the new clone
  14505. * @param newParent New parent for the clone
  14506. * @param doNotCloneChildren Do not clone children hierarchy
  14507. * @returns the new transform node
  14508. */
  14509. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14510. /**
  14511. * Serializes the objects information.
  14512. * @param currentSerializationObject defines the object to serialize in
  14513. * @returns the serialized object
  14514. */
  14515. serialize(currentSerializationObject?: any): any;
  14516. /**
  14517. * Returns a new TransformNode object parsed from the source provided.
  14518. * @param parsedTransformNode is the source.
  14519. * @param scene the scne the object belongs to
  14520. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14521. * @returns a new TransformNode object parsed from the source provided.
  14522. */
  14523. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14524. /**
  14525. * Get all child-transformNodes of this node
  14526. * @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
  14527. * @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
  14528. * @returns an array of TransformNode
  14529. */
  14530. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14531. /**
  14532. * Releases resources associated with this transform node.
  14533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14535. */
  14536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14537. /**
  14538. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14539. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14540. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14541. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14542. * @returns the current mesh
  14543. */
  14544. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14545. private _syncAbsoluteScalingAndRotation;
  14546. }
  14547. }
  14548. declare module BABYLON {
  14549. /**
  14550. * Defines the types of pose enabled controllers that are supported
  14551. */
  14552. export enum PoseEnabledControllerType {
  14553. /**
  14554. * HTC Vive
  14555. */
  14556. VIVE = 0,
  14557. /**
  14558. * Oculus Rift
  14559. */
  14560. OCULUS = 1,
  14561. /**
  14562. * Windows mixed reality
  14563. */
  14564. WINDOWS = 2,
  14565. /**
  14566. * Samsung gear VR
  14567. */
  14568. GEAR_VR = 3,
  14569. /**
  14570. * Google Daydream
  14571. */
  14572. DAYDREAM = 4,
  14573. /**
  14574. * Generic
  14575. */
  14576. GENERIC = 5
  14577. }
  14578. /**
  14579. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14580. */
  14581. export interface MutableGamepadButton {
  14582. /**
  14583. * Value of the button/trigger
  14584. */
  14585. value: number;
  14586. /**
  14587. * If the button/trigger is currently touched
  14588. */
  14589. touched: boolean;
  14590. /**
  14591. * If the button/trigger is currently pressed
  14592. */
  14593. pressed: boolean;
  14594. }
  14595. /**
  14596. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14597. * @hidden
  14598. */
  14599. export interface ExtendedGamepadButton extends GamepadButton {
  14600. /**
  14601. * If the button/trigger is currently pressed
  14602. */
  14603. readonly pressed: boolean;
  14604. /**
  14605. * If the button/trigger is currently touched
  14606. */
  14607. readonly touched: boolean;
  14608. /**
  14609. * Value of the button/trigger
  14610. */
  14611. readonly value: number;
  14612. }
  14613. /** @hidden */
  14614. export interface _GamePadFactory {
  14615. /**
  14616. * Returns wether or not the current gamepad can be created for this type of controller.
  14617. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14618. * @returns true if it can be created, otherwise false
  14619. */
  14620. canCreate(gamepadInfo: any): boolean;
  14621. /**
  14622. * Creates a new instance of the Gamepad.
  14623. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14624. * @returns the new gamepad instance
  14625. */
  14626. create(gamepadInfo: any): Gamepad;
  14627. }
  14628. /**
  14629. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14630. */
  14631. export class PoseEnabledControllerHelper {
  14632. /** @hidden */
  14633. static _ControllerFactories: _GamePadFactory[];
  14634. /** @hidden */
  14635. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14636. /**
  14637. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14638. * @param vrGamepad the gamepad to initialized
  14639. * @returns a vr controller of the type the gamepad identified as
  14640. */
  14641. static InitiateController(vrGamepad: any): Gamepad;
  14642. }
  14643. /**
  14644. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14645. */
  14646. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14647. /**
  14648. * If the controller is used in a webXR session
  14649. */
  14650. isXR: boolean;
  14651. private _deviceRoomPosition;
  14652. private _deviceRoomRotationQuaternion;
  14653. /**
  14654. * The device position in babylon space
  14655. */
  14656. devicePosition: Vector3;
  14657. /**
  14658. * The device rotation in babylon space
  14659. */
  14660. deviceRotationQuaternion: Quaternion;
  14661. /**
  14662. * The scale factor of the device in babylon space
  14663. */
  14664. deviceScaleFactor: number;
  14665. /**
  14666. * (Likely devicePosition should be used instead) The device position in its room space
  14667. */
  14668. position: Vector3;
  14669. /**
  14670. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14671. */
  14672. rotationQuaternion: Quaternion;
  14673. /**
  14674. * The type of controller (Eg. Windows mixed reality)
  14675. */
  14676. controllerType: PoseEnabledControllerType;
  14677. protected _calculatedPosition: Vector3;
  14678. private _calculatedRotation;
  14679. /**
  14680. * The raw pose from the device
  14681. */
  14682. rawPose: DevicePose;
  14683. private _trackPosition;
  14684. private _maxRotationDistFromHeadset;
  14685. private _draggedRoomRotation;
  14686. /**
  14687. * @hidden
  14688. */
  14689. _disableTrackPosition(fixedPosition: Vector3): void;
  14690. /**
  14691. * Internal, the mesh attached to the controller
  14692. * @hidden
  14693. */
  14694. _mesh: Nullable<AbstractMesh>;
  14695. private _poseControlledCamera;
  14696. private _leftHandSystemQuaternion;
  14697. /**
  14698. * Internal, matrix used to convert room space to babylon space
  14699. * @hidden
  14700. */
  14701. _deviceToWorld: Matrix;
  14702. /**
  14703. * Node to be used when casting a ray from the controller
  14704. * @hidden
  14705. */
  14706. _pointingPoseNode: Nullable<TransformNode>;
  14707. /**
  14708. * Name of the child mesh that can be used to cast a ray from the controller
  14709. */
  14710. static readonly POINTING_POSE: string;
  14711. /**
  14712. * Creates a new PoseEnabledController from a gamepad
  14713. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14714. */
  14715. constructor(browserGamepad: any);
  14716. private _workingMatrix;
  14717. /**
  14718. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14719. */
  14720. update(): void;
  14721. /**
  14722. * Updates only the pose device and mesh without doing any button event checking
  14723. */
  14724. protected _updatePoseAndMesh(): void;
  14725. /**
  14726. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14727. * @param poseData raw pose fromthe device
  14728. */
  14729. updateFromDevice(poseData: DevicePose): void;
  14730. /**
  14731. * @hidden
  14732. */
  14733. _meshAttachedObservable: Observable<AbstractMesh>;
  14734. /**
  14735. * Attaches a mesh to the controller
  14736. * @param mesh the mesh to be attached
  14737. */
  14738. attachToMesh(mesh: AbstractMesh): void;
  14739. /**
  14740. * Attaches the controllers mesh to a camera
  14741. * @param camera the camera the mesh should be attached to
  14742. */
  14743. attachToPoseControlledCamera(camera: TargetCamera): void;
  14744. /**
  14745. * Disposes of the controller
  14746. */
  14747. dispose(): void;
  14748. /**
  14749. * The mesh that is attached to the controller
  14750. */
  14751. get mesh(): Nullable<AbstractMesh>;
  14752. /**
  14753. * Gets the ray of the controller in the direction the controller is pointing
  14754. * @param length the length the resulting ray should be
  14755. * @returns a ray in the direction the controller is pointing
  14756. */
  14757. getForwardRay(length?: number): Ray;
  14758. }
  14759. }
  14760. declare module BABYLON {
  14761. /**
  14762. * Defines the WebVRController object that represents controllers tracked in 3D space
  14763. */
  14764. export abstract class WebVRController extends PoseEnabledController {
  14765. /**
  14766. * Internal, the default controller model for the controller
  14767. */
  14768. protected _defaultModel: Nullable<AbstractMesh>;
  14769. /**
  14770. * Fired when the trigger state has changed
  14771. */
  14772. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14773. /**
  14774. * Fired when the main button state has changed
  14775. */
  14776. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14777. /**
  14778. * Fired when the secondary button state has changed
  14779. */
  14780. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14781. /**
  14782. * Fired when the pad state has changed
  14783. */
  14784. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14785. /**
  14786. * Fired when controllers stick values have changed
  14787. */
  14788. onPadValuesChangedObservable: Observable<StickValues>;
  14789. /**
  14790. * Array of button availible on the controller
  14791. */
  14792. protected _buttons: Array<MutableGamepadButton>;
  14793. private _onButtonStateChange;
  14794. /**
  14795. * Fired when a controller button's state has changed
  14796. * @param callback the callback containing the button that was modified
  14797. */
  14798. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14799. /**
  14800. * X and Y axis corresponding to the controllers joystick
  14801. */
  14802. pad: StickValues;
  14803. /**
  14804. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14805. */
  14806. hand: string;
  14807. /**
  14808. * The default controller model for the controller
  14809. */
  14810. get defaultModel(): Nullable<AbstractMesh>;
  14811. /**
  14812. * Creates a new WebVRController from a gamepad
  14813. * @param vrGamepad the gamepad that the WebVRController should be created from
  14814. */
  14815. constructor(vrGamepad: any);
  14816. /**
  14817. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14818. */
  14819. update(): void;
  14820. /**
  14821. * Function to be called when a button is modified
  14822. */
  14823. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14824. /**
  14825. * Loads a mesh and attaches it to the controller
  14826. * @param scene the scene the mesh should be added to
  14827. * @param meshLoaded callback for when the mesh has been loaded
  14828. */
  14829. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14830. private _setButtonValue;
  14831. private _changes;
  14832. private _checkChanges;
  14833. /**
  14834. * Disposes of th webVRCOntroller
  14835. */
  14836. dispose(): void;
  14837. }
  14838. }
  14839. declare module BABYLON {
  14840. /**
  14841. * The HemisphericLight simulates the ambient environment light,
  14842. * so the passed direction is the light reflection direction, not the incoming direction.
  14843. */
  14844. export class HemisphericLight extends Light {
  14845. /**
  14846. * The groundColor is the light in the opposite direction to the one specified during creation.
  14847. * 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.
  14848. */
  14849. groundColor: Color3;
  14850. /**
  14851. * The light reflection direction, not the incoming direction.
  14852. */
  14853. direction: Vector3;
  14854. /**
  14855. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14856. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14857. * The HemisphericLight can't cast shadows.
  14858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14859. * @param name The friendly name of the light
  14860. * @param direction The direction of the light reflection
  14861. * @param scene The scene the light belongs to
  14862. */
  14863. constructor(name: string, direction: Vector3, scene: Scene);
  14864. protected _buildUniformLayout(): void;
  14865. /**
  14866. * Returns the string "HemisphericLight".
  14867. * @return The class name
  14868. */
  14869. getClassName(): string;
  14870. /**
  14871. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14872. * Returns the updated direction.
  14873. * @param target The target the direction should point to
  14874. * @return The computed direction
  14875. */
  14876. setDirectionToTarget(target: Vector3): Vector3;
  14877. /**
  14878. * Returns the shadow generator associated to the light.
  14879. * @returns Always null for hemispheric lights because it does not support shadows.
  14880. */
  14881. getShadowGenerator(): Nullable<IShadowGenerator>;
  14882. /**
  14883. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14884. * @param effect The effect to update
  14885. * @param lightIndex The index of the light in the effect to update
  14886. * @returns The hemispheric light
  14887. */
  14888. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14889. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14890. /**
  14891. * Computes the world matrix of the node
  14892. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14893. * @param useWasUpdatedFlag defines a reserved property
  14894. * @returns the world matrix
  14895. */
  14896. computeWorldMatrix(): Matrix;
  14897. /**
  14898. * Returns the integer 3.
  14899. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14900. */
  14901. getTypeID(): number;
  14902. /**
  14903. * Prepares the list of defines specific to the light type.
  14904. * @param defines the list of defines
  14905. * @param lightIndex defines the index of the light for the effect
  14906. */
  14907. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14908. }
  14909. }
  14910. declare module BABYLON {
  14911. /** @hidden */
  14912. export var vrMultiviewToSingleviewPixelShader: {
  14913. name: string;
  14914. shader: string;
  14915. };
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * Renders to multiple views with a single draw call
  14920. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14921. */
  14922. export class MultiviewRenderTarget extends RenderTargetTexture {
  14923. /**
  14924. * Creates a multiview render target
  14925. * @param scene scene used with the render target
  14926. * @param size the size of the render target (used for each view)
  14927. */
  14928. constructor(scene: Scene, size?: number | {
  14929. width: number;
  14930. height: number;
  14931. } | {
  14932. ratio: number;
  14933. });
  14934. /**
  14935. * @hidden
  14936. * @param faceIndex the face index, if its a cube texture
  14937. */
  14938. _bindFrameBuffer(faceIndex?: number): void;
  14939. /**
  14940. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14941. * @returns the view count
  14942. */
  14943. getViewCount(): number;
  14944. }
  14945. }
  14946. declare module BABYLON {
  14947. /**
  14948. * Represents a camera frustum
  14949. */
  14950. export class Frustum {
  14951. /**
  14952. * Gets the planes representing the frustum
  14953. * @param transform matrix to be applied to the returned planes
  14954. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14955. */
  14956. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14957. /**
  14958. * Gets the near frustum plane transformed by the transform matrix
  14959. * @param transform transformation matrix to be applied to the resulting frustum plane
  14960. * @param frustumPlane the resuling frustum plane
  14961. */
  14962. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14963. /**
  14964. * Gets the far frustum plane transformed by the transform matrix
  14965. * @param transform transformation matrix to be applied to the resulting frustum plane
  14966. * @param frustumPlane the resuling frustum plane
  14967. */
  14968. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14969. /**
  14970. * Gets the left frustum plane transformed by the transform matrix
  14971. * @param transform transformation matrix to be applied to the resulting frustum plane
  14972. * @param frustumPlane the resuling frustum plane
  14973. */
  14974. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14975. /**
  14976. * Gets the right frustum plane transformed by the transform matrix
  14977. * @param transform transformation matrix to be applied to the resulting frustum plane
  14978. * @param frustumPlane the resuling frustum plane
  14979. */
  14980. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14981. /**
  14982. * Gets the top frustum plane transformed by the transform matrix
  14983. * @param transform transformation matrix to be applied to the resulting frustum plane
  14984. * @param frustumPlane the resuling frustum plane
  14985. */
  14986. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14987. /**
  14988. * Gets the bottom frustum plane transformed by the transform matrix
  14989. * @param transform transformation matrix to be applied to the resulting frustum plane
  14990. * @param frustumPlane the resuling frustum plane
  14991. */
  14992. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14993. /**
  14994. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14995. * @param transform transformation matrix to be applied to the resulting frustum planes
  14996. * @param frustumPlanes the resuling frustum planes
  14997. */
  14998. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14999. }
  15000. }
  15001. declare module BABYLON {
  15002. interface Engine {
  15003. /**
  15004. * Creates a new multiview render target
  15005. * @param width defines the width of the texture
  15006. * @param height defines the height of the texture
  15007. * @returns the created multiview texture
  15008. */
  15009. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15010. /**
  15011. * Binds a multiview framebuffer to be drawn to
  15012. * @param multiviewTexture texture to bind
  15013. */
  15014. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15015. }
  15016. interface Camera {
  15017. /**
  15018. * @hidden
  15019. * 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)
  15020. */
  15021. _useMultiviewToSingleView: boolean;
  15022. /**
  15023. * @hidden
  15024. * 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)
  15025. */
  15026. _multiviewTexture: Nullable<RenderTargetTexture>;
  15027. /**
  15028. * @hidden
  15029. * ensures the multiview texture of the camera exists and has the specified width/height
  15030. * @param width height to set on the multiview texture
  15031. * @param height width to set on the multiview texture
  15032. */
  15033. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15034. }
  15035. interface Scene {
  15036. /** @hidden */
  15037. _transformMatrixR: Matrix;
  15038. /** @hidden */
  15039. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15040. /** @hidden */
  15041. _createMultiviewUbo(): void;
  15042. /** @hidden */
  15043. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15044. /** @hidden */
  15045. _renderMultiviewToSingleView(camera: Camera): void;
  15046. }
  15047. }
  15048. declare module BABYLON {
  15049. /**
  15050. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15051. * This will not be used for webXR as it supports displaying texture arrays directly
  15052. */
  15053. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15054. /**
  15055. * Initializes a VRMultiviewToSingleview
  15056. * @param name name of the post process
  15057. * @param camera camera to be applied to
  15058. * @param scaleFactor scaling factor to the size of the output texture
  15059. */
  15060. constructor(name: string, camera: Camera, scaleFactor: number);
  15061. }
  15062. }
  15063. declare module BABYLON {
  15064. /**
  15065. * Interface used to define additional presentation attributes
  15066. */
  15067. export interface IVRPresentationAttributes {
  15068. /**
  15069. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15070. */
  15071. highRefreshRate: boolean;
  15072. /**
  15073. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15074. */
  15075. foveationLevel: number;
  15076. }
  15077. interface Engine {
  15078. /** @hidden */
  15079. _vrDisplay: any;
  15080. /** @hidden */
  15081. _vrSupported: boolean;
  15082. /** @hidden */
  15083. _oldSize: Size;
  15084. /** @hidden */
  15085. _oldHardwareScaleFactor: number;
  15086. /** @hidden */
  15087. _vrExclusivePointerMode: boolean;
  15088. /** @hidden */
  15089. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15090. /** @hidden */
  15091. _onVRDisplayPointerRestricted: () => void;
  15092. /** @hidden */
  15093. _onVRDisplayPointerUnrestricted: () => void;
  15094. /** @hidden */
  15095. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15096. /** @hidden */
  15097. _onVrDisplayDisconnect: Nullable<() => void>;
  15098. /** @hidden */
  15099. _onVrDisplayPresentChange: Nullable<() => void>;
  15100. /**
  15101. * Observable signaled when VR display mode changes
  15102. */
  15103. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15104. /**
  15105. * Observable signaled when VR request present is complete
  15106. */
  15107. onVRRequestPresentComplete: Observable<boolean>;
  15108. /**
  15109. * Observable signaled when VR request present starts
  15110. */
  15111. onVRRequestPresentStart: Observable<Engine>;
  15112. /**
  15113. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15114. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15115. */
  15116. isInVRExclusivePointerMode: boolean;
  15117. /**
  15118. * Gets a boolean indicating if a webVR device was detected
  15119. * @returns true if a webVR device was detected
  15120. */
  15121. isVRDevicePresent(): boolean;
  15122. /**
  15123. * Gets the current webVR device
  15124. * @returns the current webVR device (or null)
  15125. */
  15126. getVRDevice(): any;
  15127. /**
  15128. * Initializes a webVR display and starts listening to display change events
  15129. * The onVRDisplayChangedObservable will be notified upon these changes
  15130. * @returns A promise containing a VRDisplay and if vr is supported
  15131. */
  15132. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15133. /** @hidden */
  15134. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15135. /**
  15136. * Gets or sets the presentation attributes used to configure VR rendering
  15137. */
  15138. vrPresentationAttributes?: IVRPresentationAttributes;
  15139. /**
  15140. * Call this function to switch to webVR mode
  15141. * Will do nothing if webVR is not supported or if there is no webVR device
  15142. * @param options the webvr options provided to the camera. mainly used for multiview
  15143. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15144. */
  15145. enableVR(options: WebVROptions): void;
  15146. /** @hidden */
  15147. _onVRFullScreenTriggered(): void;
  15148. }
  15149. }
  15150. declare module BABYLON {
  15151. /**
  15152. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15153. * IMPORTANT!! The data is right-hand data.
  15154. * @export
  15155. * @interface DevicePose
  15156. */
  15157. export interface DevicePose {
  15158. /**
  15159. * The position of the device, values in array are [x,y,z].
  15160. */
  15161. readonly position: Nullable<Float32Array>;
  15162. /**
  15163. * The linearVelocity of the device, values in array are [x,y,z].
  15164. */
  15165. readonly linearVelocity: Nullable<Float32Array>;
  15166. /**
  15167. * The linearAcceleration of the device, values in array are [x,y,z].
  15168. */
  15169. readonly linearAcceleration: Nullable<Float32Array>;
  15170. /**
  15171. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15172. */
  15173. readonly orientation: Nullable<Float32Array>;
  15174. /**
  15175. * The angularVelocity of the device, values in array are [x,y,z].
  15176. */
  15177. readonly angularVelocity: Nullable<Float32Array>;
  15178. /**
  15179. * The angularAcceleration of the device, values in array are [x,y,z].
  15180. */
  15181. readonly angularAcceleration: Nullable<Float32Array>;
  15182. }
  15183. /**
  15184. * Interface representing a pose controlled object in Babylon.
  15185. * A pose controlled object has both regular pose values as well as pose values
  15186. * from an external device such as a VR head mounted display
  15187. */
  15188. export interface PoseControlled {
  15189. /**
  15190. * The position of the object in babylon space.
  15191. */
  15192. position: Vector3;
  15193. /**
  15194. * The rotation quaternion of the object in babylon space.
  15195. */
  15196. rotationQuaternion: Quaternion;
  15197. /**
  15198. * The position of the device in babylon space.
  15199. */
  15200. devicePosition?: Vector3;
  15201. /**
  15202. * The rotation quaternion of the device in babylon space.
  15203. */
  15204. deviceRotationQuaternion: Quaternion;
  15205. /**
  15206. * The raw pose coming from the device.
  15207. */
  15208. rawPose: Nullable<DevicePose>;
  15209. /**
  15210. * The scale of the device to be used when translating from device space to babylon space.
  15211. */
  15212. deviceScaleFactor: number;
  15213. /**
  15214. * Updates the poseControlled values based on the input device pose.
  15215. * @param poseData the pose data to update the object with
  15216. */
  15217. updateFromDevice(poseData: DevicePose): void;
  15218. }
  15219. /**
  15220. * Set of options to customize the webVRCamera
  15221. */
  15222. export interface WebVROptions {
  15223. /**
  15224. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15225. */
  15226. trackPosition?: boolean;
  15227. /**
  15228. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15229. */
  15230. positionScale?: number;
  15231. /**
  15232. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15233. */
  15234. displayName?: string;
  15235. /**
  15236. * Should the native controller meshes be initialized. (default: true)
  15237. */
  15238. controllerMeshes?: boolean;
  15239. /**
  15240. * Creating a default HemiLight only on controllers. (default: true)
  15241. */
  15242. defaultLightingOnControllers?: boolean;
  15243. /**
  15244. * If you don't want to use the default VR button of the helper. (default: false)
  15245. */
  15246. useCustomVRButton?: boolean;
  15247. /**
  15248. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15249. */
  15250. customVRButton?: HTMLButtonElement;
  15251. /**
  15252. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15253. */
  15254. rayLength?: number;
  15255. /**
  15256. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15257. */
  15258. defaultHeight?: number;
  15259. /**
  15260. * If multiview should be used if availible (default: false)
  15261. */
  15262. useMultiview?: boolean;
  15263. }
  15264. /**
  15265. * This represents a WebVR camera.
  15266. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15267. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15268. */
  15269. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15270. private webVROptions;
  15271. /**
  15272. * @hidden
  15273. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15274. */
  15275. _vrDevice: any;
  15276. /**
  15277. * The rawPose of the vrDevice.
  15278. */
  15279. rawPose: Nullable<DevicePose>;
  15280. private _onVREnabled;
  15281. private _specsVersion;
  15282. private _attached;
  15283. private _frameData;
  15284. protected _descendants: Array<Node>;
  15285. private _deviceRoomPosition;
  15286. /** @hidden */
  15287. _deviceRoomRotationQuaternion: Quaternion;
  15288. private _standingMatrix;
  15289. /**
  15290. * Represents device position in babylon space.
  15291. */
  15292. devicePosition: Vector3;
  15293. /**
  15294. * Represents device rotation in babylon space.
  15295. */
  15296. deviceRotationQuaternion: Quaternion;
  15297. /**
  15298. * The scale of the device to be used when translating from device space to babylon space.
  15299. */
  15300. deviceScaleFactor: number;
  15301. private _deviceToWorld;
  15302. private _worldToDevice;
  15303. /**
  15304. * References to the webVR controllers for the vrDevice.
  15305. */
  15306. controllers: Array<WebVRController>;
  15307. /**
  15308. * Emits an event when a controller is attached.
  15309. */
  15310. onControllersAttachedObservable: Observable<WebVRController[]>;
  15311. /**
  15312. * Emits an event when a controller's mesh has been loaded;
  15313. */
  15314. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15315. /**
  15316. * Emits an event when the HMD's pose has been updated.
  15317. */
  15318. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15319. private _poseSet;
  15320. /**
  15321. * If the rig cameras be used as parent instead of this camera.
  15322. */
  15323. rigParenting: boolean;
  15324. private _lightOnControllers;
  15325. private _defaultHeight?;
  15326. /**
  15327. * Instantiates a WebVRFreeCamera.
  15328. * @param name The name of the WebVRFreeCamera
  15329. * @param position The starting anchor position for the camera
  15330. * @param scene The scene the camera belongs to
  15331. * @param webVROptions a set of customizable options for the webVRCamera
  15332. */
  15333. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15334. /**
  15335. * Gets the device distance from the ground in meters.
  15336. * @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.
  15337. */
  15338. deviceDistanceToRoomGround(): number;
  15339. /**
  15340. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15341. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15342. */
  15343. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15344. /**
  15345. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15346. * @returns A promise with a boolean set to if the standing matrix is supported.
  15347. */
  15348. useStandingMatrixAsync(): Promise<boolean>;
  15349. /**
  15350. * Disposes the camera
  15351. */
  15352. dispose(): void;
  15353. /**
  15354. * Gets a vrController by name.
  15355. * @param name The name of the controller to retreive
  15356. * @returns the controller matching the name specified or null if not found
  15357. */
  15358. getControllerByName(name: string): Nullable<WebVRController>;
  15359. private _leftController;
  15360. /**
  15361. * The controller corresponding to the users left hand.
  15362. */
  15363. get leftController(): Nullable<WebVRController>;
  15364. private _rightController;
  15365. /**
  15366. * The controller corresponding to the users right hand.
  15367. */
  15368. get rightController(): Nullable<WebVRController>;
  15369. /**
  15370. * Casts a ray forward from the vrCamera's gaze.
  15371. * @param length Length of the ray (default: 100)
  15372. * @returns the ray corresponding to the gaze
  15373. */
  15374. getForwardRay(length?: number): Ray;
  15375. /**
  15376. * @hidden
  15377. * Updates the camera based on device's frame data
  15378. */
  15379. _checkInputs(): void;
  15380. /**
  15381. * Updates the poseControlled values based on the input device pose.
  15382. * @param poseData Pose coming from the device
  15383. */
  15384. updateFromDevice(poseData: DevicePose): void;
  15385. private _htmlElementAttached;
  15386. private _detachIfAttached;
  15387. /**
  15388. * WebVR's attach control will start broadcasting frames to the device.
  15389. * Note that in certain browsers (chrome for example) this function must be called
  15390. * within a user-interaction callback. Example:
  15391. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15392. *
  15393. * @param element html element to attach the vrDevice to
  15394. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15395. */
  15396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15397. /**
  15398. * Detaches the camera from the html element and disables VR
  15399. *
  15400. * @param element html element to detach from
  15401. */
  15402. detachControl(element: HTMLElement): void;
  15403. /**
  15404. * @returns the name of this class
  15405. */
  15406. getClassName(): string;
  15407. /**
  15408. * Calls resetPose on the vrDisplay
  15409. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15410. */
  15411. resetToCurrentRotation(): void;
  15412. /**
  15413. * @hidden
  15414. * Updates the rig cameras (left and right eye)
  15415. */
  15416. _updateRigCameras(): void;
  15417. private _workingVector;
  15418. private _oneVector;
  15419. private _workingMatrix;
  15420. private updateCacheCalled;
  15421. private _correctPositionIfNotTrackPosition;
  15422. /**
  15423. * @hidden
  15424. * Updates the cached values of the camera
  15425. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15426. */
  15427. _updateCache(ignoreParentClass?: boolean): void;
  15428. /**
  15429. * @hidden
  15430. * Get current device position in babylon world
  15431. */
  15432. _computeDevicePosition(): void;
  15433. /**
  15434. * Updates the current device position and rotation in the babylon world
  15435. */
  15436. update(): void;
  15437. /**
  15438. * @hidden
  15439. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15440. * @returns an identity matrix
  15441. */
  15442. _getViewMatrix(): Matrix;
  15443. private _tmpMatrix;
  15444. /**
  15445. * This function is called by the two RIG cameras.
  15446. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15447. * @hidden
  15448. */
  15449. _getWebVRViewMatrix(): Matrix;
  15450. /** @hidden */
  15451. _getWebVRProjectionMatrix(): Matrix;
  15452. private _onGamepadConnectedObserver;
  15453. private _onGamepadDisconnectedObserver;
  15454. private _updateCacheWhenTrackingDisabledObserver;
  15455. /**
  15456. * Initializes the controllers and their meshes
  15457. */
  15458. initControllers(): void;
  15459. }
  15460. }
  15461. declare module BABYLON {
  15462. /**
  15463. * Size options for a post process
  15464. */
  15465. export type PostProcessOptions = {
  15466. width: number;
  15467. height: number;
  15468. };
  15469. /**
  15470. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15471. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15472. */
  15473. export class PostProcess {
  15474. /** Name of the PostProcess. */
  15475. name: string;
  15476. /**
  15477. * Gets or sets the unique id of the post process
  15478. */
  15479. uniqueId: number;
  15480. /**
  15481. * Width of the texture to apply the post process on
  15482. */
  15483. width: number;
  15484. /**
  15485. * Height of the texture to apply the post process on
  15486. */
  15487. height: number;
  15488. /**
  15489. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15490. * @hidden
  15491. */
  15492. _outputTexture: Nullable<InternalTexture>;
  15493. /**
  15494. * Sampling mode used by the shader
  15495. * See https://doc.babylonjs.com/classes/3.1/texture
  15496. */
  15497. renderTargetSamplingMode: number;
  15498. /**
  15499. * Clear color to use when screen clearing
  15500. */
  15501. clearColor: Color4;
  15502. /**
  15503. * If the buffer needs to be cleared before applying the post process. (default: true)
  15504. * Should be set to false if shader will overwrite all previous pixels.
  15505. */
  15506. autoClear: boolean;
  15507. /**
  15508. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15509. */
  15510. alphaMode: number;
  15511. /**
  15512. * Sets the setAlphaBlendConstants of the babylon engine
  15513. */
  15514. alphaConstants: Color4;
  15515. /**
  15516. * Animations to be used for the post processing
  15517. */
  15518. animations: Animation[];
  15519. /**
  15520. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15521. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15522. */
  15523. enablePixelPerfectMode: boolean;
  15524. /**
  15525. * Force the postprocess to be applied without taking in account viewport
  15526. */
  15527. forceFullscreenViewport: boolean;
  15528. /**
  15529. * List of inspectable custom properties (used by the Inspector)
  15530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15531. */
  15532. inspectableCustomProperties: IInspectable[];
  15533. /**
  15534. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15535. *
  15536. * | Value | Type | Description |
  15537. * | ----- | ----------------------------------- | ----------- |
  15538. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15539. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15540. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15541. *
  15542. */
  15543. scaleMode: number;
  15544. /**
  15545. * Force textures to be a power of two (default: false)
  15546. */
  15547. alwaysForcePOT: boolean;
  15548. private _samples;
  15549. /**
  15550. * Number of sample textures (default: 1)
  15551. */
  15552. get samples(): number;
  15553. set samples(n: number);
  15554. /**
  15555. * Modify the scale of the post process to be the same as the viewport (default: false)
  15556. */
  15557. adaptScaleToCurrentViewport: boolean;
  15558. private _camera;
  15559. private _scene;
  15560. private _engine;
  15561. private _options;
  15562. private _reusable;
  15563. private _textureType;
  15564. /**
  15565. * Smart array of input and output textures for the post process.
  15566. * @hidden
  15567. */
  15568. _textures: SmartArray<InternalTexture>;
  15569. /**
  15570. * The index in _textures that corresponds to the output texture.
  15571. * @hidden
  15572. */
  15573. _currentRenderTextureInd: number;
  15574. private _effect;
  15575. private _samplers;
  15576. private _fragmentUrl;
  15577. private _vertexUrl;
  15578. private _parameters;
  15579. private _scaleRatio;
  15580. protected _indexParameters: any;
  15581. private _shareOutputWithPostProcess;
  15582. private _texelSize;
  15583. private _forcedOutputTexture;
  15584. /**
  15585. * Returns the fragment url or shader name used in the post process.
  15586. * @returns the fragment url or name in the shader store.
  15587. */
  15588. getEffectName(): string;
  15589. /**
  15590. * An event triggered when the postprocess is activated.
  15591. */
  15592. onActivateObservable: Observable<Camera>;
  15593. private _onActivateObserver;
  15594. /**
  15595. * A function that is added to the onActivateObservable
  15596. */
  15597. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15598. /**
  15599. * An event triggered when the postprocess changes its size.
  15600. */
  15601. onSizeChangedObservable: Observable<PostProcess>;
  15602. private _onSizeChangedObserver;
  15603. /**
  15604. * A function that is added to the onSizeChangedObservable
  15605. */
  15606. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15607. /**
  15608. * An event triggered when the postprocess applies its effect.
  15609. */
  15610. onApplyObservable: Observable<Effect>;
  15611. private _onApplyObserver;
  15612. /**
  15613. * A function that is added to the onApplyObservable
  15614. */
  15615. set onApply(callback: (effect: Effect) => void);
  15616. /**
  15617. * An event triggered before rendering the postprocess
  15618. */
  15619. onBeforeRenderObservable: Observable<Effect>;
  15620. private _onBeforeRenderObserver;
  15621. /**
  15622. * A function that is added to the onBeforeRenderObservable
  15623. */
  15624. set onBeforeRender(callback: (effect: Effect) => void);
  15625. /**
  15626. * An event triggered after rendering the postprocess
  15627. */
  15628. onAfterRenderObservable: Observable<Effect>;
  15629. private _onAfterRenderObserver;
  15630. /**
  15631. * A function that is added to the onAfterRenderObservable
  15632. */
  15633. set onAfterRender(callback: (efect: Effect) => void);
  15634. /**
  15635. * 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
  15636. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15637. */
  15638. get inputTexture(): InternalTexture;
  15639. set inputTexture(value: InternalTexture);
  15640. /**
  15641. * Gets the camera which post process is applied to.
  15642. * @returns The camera the post process is applied to.
  15643. */
  15644. getCamera(): Camera;
  15645. /**
  15646. * Gets the texel size of the postprocess.
  15647. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15648. */
  15649. get texelSize(): Vector2;
  15650. /**
  15651. * Creates a new instance PostProcess
  15652. * @param name The name of the PostProcess.
  15653. * @param fragmentUrl The url of the fragment shader to be used.
  15654. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15655. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15656. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15657. * @param camera The camera to apply the render pass to.
  15658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15659. * @param engine The engine which the post process will be applied. (default: current engine)
  15660. * @param reusable If the post process can be reused on the same frame. (default: false)
  15661. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15662. * @param textureType Type of textures used when performing the post process. (default: 0)
  15663. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15664. * @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
  15665. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15666. */
  15667. constructor(
  15668. /** Name of the PostProcess. */
  15669. 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);
  15670. /**
  15671. * Gets a string idenfifying the name of the class
  15672. * @returns "PostProcess" string
  15673. */
  15674. getClassName(): string;
  15675. /**
  15676. * Gets the engine which this post process belongs to.
  15677. * @returns The engine the post process was enabled with.
  15678. */
  15679. getEngine(): Engine;
  15680. /**
  15681. * The effect that is created when initializing the post process.
  15682. * @returns The created effect corresponding the the postprocess.
  15683. */
  15684. getEffect(): Effect;
  15685. /**
  15686. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15687. * @param postProcess The post process to share the output with.
  15688. * @returns This post process.
  15689. */
  15690. shareOutputWith(postProcess: PostProcess): PostProcess;
  15691. /**
  15692. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15693. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15694. */
  15695. useOwnOutput(): void;
  15696. /**
  15697. * Updates the effect with the current post process compile time values and recompiles the shader.
  15698. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15699. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15700. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15701. * @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
  15702. * @param onCompiled Called when the shader has been compiled.
  15703. * @param onError Called if there is an error when compiling a shader.
  15704. */
  15705. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15706. /**
  15707. * The post process is reusable if it can be used multiple times within one frame.
  15708. * @returns If the post process is reusable
  15709. */
  15710. isReusable(): boolean;
  15711. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15712. markTextureDirty(): void;
  15713. /**
  15714. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15715. * 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.
  15716. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15717. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15718. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15719. * @returns The target texture that was bound to be written to.
  15720. */
  15721. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15722. /**
  15723. * If the post process is supported.
  15724. */
  15725. get isSupported(): boolean;
  15726. /**
  15727. * The aspect ratio of the output texture.
  15728. */
  15729. get aspectRatio(): number;
  15730. /**
  15731. * Get a value indicating if the post-process is ready to be used
  15732. * @returns true if the post-process is ready (shader is compiled)
  15733. */
  15734. isReady(): boolean;
  15735. /**
  15736. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15737. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15738. */
  15739. apply(): Nullable<Effect>;
  15740. private _disposeTextures;
  15741. /**
  15742. * Disposes the post process.
  15743. * @param camera The camera to dispose the post process on.
  15744. */
  15745. dispose(camera?: Camera): void;
  15746. }
  15747. }
  15748. declare module BABYLON {
  15749. /** @hidden */
  15750. export var kernelBlurVaryingDeclaration: {
  15751. name: string;
  15752. shader: string;
  15753. };
  15754. }
  15755. declare module BABYLON {
  15756. /** @hidden */
  15757. export var kernelBlurFragment: {
  15758. name: string;
  15759. shader: string;
  15760. };
  15761. }
  15762. declare module BABYLON {
  15763. /** @hidden */
  15764. export var kernelBlurFragment2: {
  15765. name: string;
  15766. shader: string;
  15767. };
  15768. }
  15769. declare module BABYLON {
  15770. /** @hidden */
  15771. export var kernelBlurPixelShader: {
  15772. name: string;
  15773. shader: string;
  15774. };
  15775. }
  15776. declare module BABYLON {
  15777. /** @hidden */
  15778. export var kernelBlurVertex: {
  15779. name: string;
  15780. shader: string;
  15781. };
  15782. }
  15783. declare module BABYLON {
  15784. /** @hidden */
  15785. export var kernelBlurVertexShader: {
  15786. name: string;
  15787. shader: string;
  15788. };
  15789. }
  15790. declare module BABYLON {
  15791. /**
  15792. * The Blur Post Process which blurs an image based on a kernel and direction.
  15793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15794. */
  15795. export class BlurPostProcess extends PostProcess {
  15796. /** The direction in which to blur the image. */
  15797. direction: Vector2;
  15798. private blockCompilation;
  15799. protected _kernel: number;
  15800. protected _idealKernel: number;
  15801. protected _packedFloat: boolean;
  15802. private _staticDefines;
  15803. /**
  15804. * Sets the length in pixels of the blur sample region
  15805. */
  15806. set kernel(v: number);
  15807. /**
  15808. * Gets the length in pixels of the blur sample region
  15809. */
  15810. get kernel(): number;
  15811. /**
  15812. * Sets wether or not the blur needs to unpack/repack floats
  15813. */
  15814. set packedFloat(v: boolean);
  15815. /**
  15816. * Gets wether or not the blur is unpacking/repacking floats
  15817. */
  15818. get packedFloat(): boolean;
  15819. /**
  15820. * Creates a new instance BlurPostProcess
  15821. * @param name The name of the effect.
  15822. * @param direction The direction in which to blur the image.
  15823. * @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.
  15824. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15825. * @param camera The camera to apply the render pass to.
  15826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15827. * @param engine The engine which the post process will be applied. (default: current engine)
  15828. * @param reusable If the post process can be reused on the same frame. (default: false)
  15829. * @param textureType Type of textures used when performing the post process. (default: 0)
  15830. * @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)
  15831. */
  15832. constructor(name: string,
  15833. /** The direction in which to blur the image. */
  15834. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15835. /**
  15836. * Updates the effect with the current post process compile time values and recompiles the shader.
  15837. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15838. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15839. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15840. * @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
  15841. * @param onCompiled Called when the shader has been compiled.
  15842. * @param onError Called if there is an error when compiling a shader.
  15843. */
  15844. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15845. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15846. /**
  15847. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15848. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15849. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15850. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15851. * The gaps between physical kernels are compensated for in the weighting of the samples
  15852. * @param idealKernel Ideal blur kernel.
  15853. * @return Nearest best kernel.
  15854. */
  15855. protected _nearestBestKernel(idealKernel: number): number;
  15856. /**
  15857. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15858. * @param x The point on the Gaussian distribution to sample.
  15859. * @return the value of the Gaussian function at x.
  15860. */
  15861. protected _gaussianWeight(x: number): number;
  15862. /**
  15863. * Generates a string that can be used as a floating point number in GLSL.
  15864. * @param x Value to print.
  15865. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15866. * @return GLSL float string.
  15867. */
  15868. protected _glslFloat(x: number, decimalFigures?: number): string;
  15869. }
  15870. }
  15871. declare module BABYLON {
  15872. /**
  15873. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15874. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15875. * You can then easily use it as a reflectionTexture on a flat surface.
  15876. * In case the surface is not a plane, please consider relying on reflection probes.
  15877. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15878. */
  15879. export class MirrorTexture extends RenderTargetTexture {
  15880. private scene;
  15881. /**
  15882. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15883. * 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.
  15884. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15885. */
  15886. mirrorPlane: Plane;
  15887. /**
  15888. * Define the blur ratio used to blur the reflection if needed.
  15889. */
  15890. set blurRatio(value: number);
  15891. get blurRatio(): number;
  15892. /**
  15893. * Define the adaptive blur kernel used to blur the reflection if needed.
  15894. * This will autocompute the closest best match for the `blurKernel`
  15895. */
  15896. set adaptiveBlurKernel(value: number);
  15897. /**
  15898. * Define the blur kernel used to blur the reflection if needed.
  15899. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15900. */
  15901. set blurKernel(value: number);
  15902. /**
  15903. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15905. */
  15906. set blurKernelX(value: number);
  15907. get blurKernelX(): number;
  15908. /**
  15909. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15910. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15911. */
  15912. set blurKernelY(value: number);
  15913. get blurKernelY(): number;
  15914. private _autoComputeBlurKernel;
  15915. protected _onRatioRescale(): void;
  15916. private _updateGammaSpace;
  15917. private _imageProcessingConfigChangeObserver;
  15918. private _transformMatrix;
  15919. private _mirrorMatrix;
  15920. private _savedViewMatrix;
  15921. private _blurX;
  15922. private _blurY;
  15923. private _adaptiveBlurKernel;
  15924. private _blurKernelX;
  15925. private _blurKernelY;
  15926. private _blurRatio;
  15927. /**
  15928. * Instantiates a Mirror Texture.
  15929. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15930. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15931. * You can then easily use it as a reflectionTexture on a flat surface.
  15932. * In case the surface is not a plane, please consider relying on reflection probes.
  15933. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15934. * @param name
  15935. * @param size
  15936. * @param scene
  15937. * @param generateMipMaps
  15938. * @param type
  15939. * @param samplingMode
  15940. * @param generateDepthBuffer
  15941. */
  15942. constructor(name: string, size: number | {
  15943. width: number;
  15944. height: number;
  15945. } | {
  15946. ratio: number;
  15947. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15948. private _preparePostProcesses;
  15949. /**
  15950. * Clone the mirror texture.
  15951. * @returns the cloned texture
  15952. */
  15953. clone(): MirrorTexture;
  15954. /**
  15955. * Serialize the texture to a JSON representation you could use in Parse later on
  15956. * @returns the serialized JSON representation
  15957. */
  15958. serialize(): any;
  15959. /**
  15960. * Dispose the texture and release its associated resources.
  15961. */
  15962. dispose(): void;
  15963. }
  15964. }
  15965. declare module BABYLON {
  15966. /**
  15967. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15968. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15969. */
  15970. export class Texture extends BaseTexture {
  15971. /**
  15972. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15973. */
  15974. static SerializeBuffers: boolean;
  15975. /** @hidden */
  15976. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15977. /** @hidden */
  15978. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15979. /** @hidden */
  15980. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15981. /** nearest is mag = nearest and min = nearest and mip = linear */
  15982. static readonly NEAREST_SAMPLINGMODE: number;
  15983. /** nearest is mag = nearest and min = nearest and mip = linear */
  15984. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15985. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15986. static readonly BILINEAR_SAMPLINGMODE: number;
  15987. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15988. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15989. /** Trilinear is mag = linear and min = linear and mip = linear */
  15990. static readonly TRILINEAR_SAMPLINGMODE: number;
  15991. /** Trilinear is mag = linear and min = linear and mip = linear */
  15992. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15993. /** mag = nearest and min = nearest and mip = nearest */
  15994. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15995. /** mag = nearest and min = linear and mip = nearest */
  15996. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15997. /** mag = nearest and min = linear and mip = linear */
  15998. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15999. /** mag = nearest and min = linear and mip = none */
  16000. static readonly NEAREST_LINEAR: number;
  16001. /** mag = nearest and min = nearest and mip = none */
  16002. static readonly NEAREST_NEAREST: number;
  16003. /** mag = linear and min = nearest and mip = nearest */
  16004. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16005. /** mag = linear and min = nearest and mip = linear */
  16006. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16007. /** mag = linear and min = linear and mip = none */
  16008. static readonly LINEAR_LINEAR: number;
  16009. /** mag = linear and min = nearest and mip = none */
  16010. static readonly LINEAR_NEAREST: number;
  16011. /** Explicit coordinates mode */
  16012. static readonly EXPLICIT_MODE: number;
  16013. /** Spherical coordinates mode */
  16014. static readonly SPHERICAL_MODE: number;
  16015. /** Planar coordinates mode */
  16016. static readonly PLANAR_MODE: number;
  16017. /** Cubic coordinates mode */
  16018. static readonly CUBIC_MODE: number;
  16019. /** Projection coordinates mode */
  16020. static readonly PROJECTION_MODE: number;
  16021. /** Inverse Cubic coordinates mode */
  16022. static readonly SKYBOX_MODE: number;
  16023. /** Inverse Cubic coordinates mode */
  16024. static readonly INVCUBIC_MODE: number;
  16025. /** Equirectangular coordinates mode */
  16026. static readonly EQUIRECTANGULAR_MODE: number;
  16027. /** Equirectangular Fixed coordinates mode */
  16028. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16029. /** Equirectangular Fixed Mirrored coordinates mode */
  16030. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16031. /** Texture is not repeating outside of 0..1 UVs */
  16032. static readonly CLAMP_ADDRESSMODE: number;
  16033. /** Texture is repeating outside of 0..1 UVs */
  16034. static readonly WRAP_ADDRESSMODE: number;
  16035. /** Texture is repeating and mirrored */
  16036. static readonly MIRROR_ADDRESSMODE: number;
  16037. /**
  16038. * 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
  16039. */
  16040. static UseSerializedUrlIfAny: boolean;
  16041. /**
  16042. * Define the url of the texture.
  16043. */
  16044. url: Nullable<string>;
  16045. /**
  16046. * Define an offset on the texture to offset the u coordinates of the UVs
  16047. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16048. */
  16049. uOffset: number;
  16050. /**
  16051. * Define an offset on the texture to offset the v coordinates of the UVs
  16052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16053. */
  16054. vOffset: number;
  16055. /**
  16056. * Define an offset on the texture to scale the u coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16058. */
  16059. uScale: number;
  16060. /**
  16061. * Define an offset on the texture to scale the v coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16063. */
  16064. vScale: number;
  16065. /**
  16066. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials
  16068. */
  16069. uAng: number;
  16070. /**
  16071. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials
  16073. */
  16074. vAng: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. wAng: number;
  16080. /**
  16081. * Defines the center of rotation (U)
  16082. */
  16083. uRotationCenter: number;
  16084. /**
  16085. * Defines the center of rotation (V)
  16086. */
  16087. vRotationCenter: number;
  16088. /**
  16089. * Defines the center of rotation (W)
  16090. */
  16091. wRotationCenter: number;
  16092. /**
  16093. * Are mip maps generated for this texture or not.
  16094. */
  16095. get noMipmap(): boolean;
  16096. /**
  16097. * List of inspectable custom properties (used by the Inspector)
  16098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16099. */
  16100. inspectableCustomProperties: Nullable<IInspectable[]>;
  16101. private _noMipmap;
  16102. /** @hidden */
  16103. _invertY: boolean;
  16104. private _rowGenerationMatrix;
  16105. private _cachedTextureMatrix;
  16106. private _projectionModeMatrix;
  16107. private _t0;
  16108. private _t1;
  16109. private _t2;
  16110. private _cachedUOffset;
  16111. private _cachedVOffset;
  16112. private _cachedUScale;
  16113. private _cachedVScale;
  16114. private _cachedUAng;
  16115. private _cachedVAng;
  16116. private _cachedWAng;
  16117. private _cachedProjectionMatrixId;
  16118. private _cachedCoordinatesMode;
  16119. /** @hidden */
  16120. protected _initialSamplingMode: number;
  16121. /** @hidden */
  16122. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16123. private _deleteBuffer;
  16124. protected _format: Nullable<number>;
  16125. private _delayedOnLoad;
  16126. private _delayedOnError;
  16127. private _mimeType?;
  16128. /**
  16129. * Observable triggered once the texture has been loaded.
  16130. */
  16131. onLoadObservable: Observable<Texture>;
  16132. protected _isBlocking: boolean;
  16133. /**
  16134. * Is the texture preventing material to render while loading.
  16135. * If false, a default texture will be used instead of the loading one during the preparation step.
  16136. */
  16137. set isBlocking(value: boolean);
  16138. get isBlocking(): boolean;
  16139. /**
  16140. * Get the current sampling mode associated with the texture.
  16141. */
  16142. get samplingMode(): number;
  16143. /**
  16144. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16145. */
  16146. get invertY(): boolean;
  16147. /**
  16148. * Instantiates a new texture.
  16149. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16150. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16151. * @param url defines the url of the picture to load as a texture
  16152. * @param scene defines the scene or engine the texture will belong to
  16153. * @param noMipmap defines if the texture will require mip maps or not
  16154. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16155. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16156. * @param onLoad defines a callback triggered when the texture has been loaded
  16157. * @param onError defines a callback triggered when an error occurred during the loading session
  16158. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16159. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16160. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16161. * @param mimeType defines an optional mime type information
  16162. */
  16163. 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);
  16164. /**
  16165. * Update the url (and optional buffer) of this texture if url was null during construction.
  16166. * @param url the url of the texture
  16167. * @param buffer the buffer of the texture (defaults to null)
  16168. * @param onLoad callback called when the texture is loaded (defaults to null)
  16169. */
  16170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16171. /**
  16172. * Finish the loading sequence of a texture flagged as delayed load.
  16173. * @hidden
  16174. */
  16175. delayLoad(): void;
  16176. private _prepareRowForTextureGeneration;
  16177. /**
  16178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16179. * @returns the transform matrix of the texture.
  16180. */
  16181. getTextureMatrix(uBase?: number): Matrix;
  16182. /**
  16183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16184. * @returns The reflection texture transform
  16185. */
  16186. getReflectionTextureMatrix(): Matrix;
  16187. /**
  16188. * Clones the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): Texture;
  16192. /**
  16193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16194. * @returns The JSON representation of the texture
  16195. */
  16196. serialize(): any;
  16197. /**
  16198. * Get the current class name of the texture useful for serialization or dynamic coding.
  16199. * @returns "Texture"
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Dispose the texture and release its associated resources.
  16204. */
  16205. dispose(): void;
  16206. /**
  16207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16208. * @param parsedTexture Define the JSON representation of the texture
  16209. * @param scene Define the scene the parsed texture should be instantiated in
  16210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16211. * @returns The parsed texture if successful
  16212. */
  16213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16214. /**
  16215. * Creates a texture from its base 64 representation.
  16216. * @param data Define the base64 payload without the data: prefix
  16217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16218. * @param scene Define the scene the texture should belong to
  16219. * @param noMipmap Forces the texture to not create mip map information if true
  16220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad define a callback triggered when the texture has been loaded
  16223. * @param onError define a callback triggered when an error occurred during the loading session
  16224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16225. * @returns the created texture
  16226. */
  16227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16228. /**
  16229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16230. * @param data Define the base64 payload without the data: prefix
  16231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16233. * @param scene Define the scene the texture should belong to
  16234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16235. * @param noMipmap Forces the texture to not create mip map information if true
  16236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16238. * @param onLoad define a callback triggered when the texture has been loaded
  16239. * @param onError define a callback triggered when an error occurred during the loading session
  16240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16241. * @returns the created texture
  16242. */
  16243. 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;
  16244. }
  16245. }
  16246. declare module BABYLON {
  16247. /**
  16248. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16249. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16250. */
  16251. export class PostProcessManager {
  16252. private _scene;
  16253. private _indexBuffer;
  16254. private _vertexBuffers;
  16255. /**
  16256. * Creates a new instance PostProcess
  16257. * @param scene The scene that the post process is associated with.
  16258. */
  16259. constructor(scene: Scene);
  16260. private _prepareBuffers;
  16261. private _buildIndexBuffer;
  16262. /**
  16263. * Rebuilds the vertex buffers of the manager.
  16264. * @hidden
  16265. */
  16266. _rebuild(): void;
  16267. /**
  16268. * Prepares a frame to be run through a post process.
  16269. * @param sourceTexture The input texture to the post procesess. (default: null)
  16270. * @param postProcesses An array of post processes to be run. (default: null)
  16271. * @returns True if the post processes were able to be run.
  16272. * @hidden
  16273. */
  16274. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16275. /**
  16276. * Manually render a set of post processes to a texture.
  16277. * @param postProcesses An array of post processes to be run.
  16278. * @param targetTexture The target texture to render to.
  16279. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16280. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16281. * @param lodLevel defines which lod of the texture to render to
  16282. */
  16283. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16284. /**
  16285. * Finalize the result of the output of the postprocesses.
  16286. * @param doNotPresent If true the result will not be displayed to the screen.
  16287. * @param targetTexture The target texture to render to.
  16288. * @param faceIndex The index of the face to bind the target texture to.
  16289. * @param postProcesses The array of post processes to render.
  16290. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16291. * @hidden
  16292. */
  16293. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16294. /**
  16295. * Disposes of the post process manager.
  16296. */
  16297. dispose(): void;
  16298. }
  16299. }
  16300. declare module BABYLON {
  16301. /** Interface used by value gradients (color, factor, ...) */
  16302. export interface IValueGradient {
  16303. /**
  16304. * Gets or sets the gradient value (between 0 and 1)
  16305. */
  16306. gradient: number;
  16307. }
  16308. /** Class used to store color4 gradient */
  16309. export class ColorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated color
  16316. */
  16317. color1: Color4;
  16318. /**
  16319. * Gets or sets second associated color
  16320. */
  16321. color2?: Color4;
  16322. /**
  16323. * Will get a color picked randomly between color1 and color2.
  16324. * If color2 is undefined then color1 will be used
  16325. * @param result defines the target Color4 to store the result in
  16326. */
  16327. getColorToRef(result: Color4): void;
  16328. }
  16329. /** Class used to store color 3 gradient */
  16330. export class Color3Gradient implements IValueGradient {
  16331. /**
  16332. * Gets or sets the gradient value (between 0 and 1)
  16333. */
  16334. gradient: number;
  16335. /**
  16336. * Gets or sets the associated color
  16337. */
  16338. color: Color3;
  16339. }
  16340. /** Class used to store factor gradient */
  16341. export class FactorGradient implements IValueGradient {
  16342. /**
  16343. * Gets or sets the gradient value (between 0 and 1)
  16344. */
  16345. gradient: number;
  16346. /**
  16347. * Gets or sets first associated factor
  16348. */
  16349. factor1: number;
  16350. /**
  16351. * Gets or sets second associated factor
  16352. */
  16353. factor2?: number;
  16354. /**
  16355. * Will get a number picked randomly between factor1 and factor2.
  16356. * If factor2 is undefined then factor1 will be used
  16357. * @returns the picked number
  16358. */
  16359. getFactor(): number;
  16360. }
  16361. /**
  16362. * Helper used to simplify some generic gradient tasks
  16363. */
  16364. export class GradientHelper {
  16365. /**
  16366. * Gets the current gradient from an array of IValueGradient
  16367. * @param ratio defines the current ratio to get
  16368. * @param gradients defines the array of IValueGradient
  16369. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16370. */
  16371. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16372. }
  16373. }
  16374. declare module BABYLON {
  16375. interface ThinEngine {
  16376. /**
  16377. * Creates a dynamic texture
  16378. * @param width defines the width of the texture
  16379. * @param height defines the height of the texture
  16380. * @param generateMipMaps defines if the engine should generate the mip levels
  16381. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16382. * @returns the dynamic texture inside an InternalTexture
  16383. */
  16384. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16385. /**
  16386. * Update the content of a dynamic texture
  16387. * @param texture defines the texture to update
  16388. * @param canvas defines the canvas containing the source
  16389. * @param invertY defines if data must be stored with Y axis inverted
  16390. * @param premulAlpha defines if alpha is stored as premultiplied
  16391. * @param format defines the format of the data
  16392. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16393. */
  16394. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16395. }
  16396. }
  16397. declare module BABYLON {
  16398. /**
  16399. * Helper class used to generate a canvas to manipulate images
  16400. */
  16401. export class CanvasGenerator {
  16402. /**
  16403. * Create a new canvas (or offscreen canvas depending on the context)
  16404. * @param width defines the expected width
  16405. * @param height defines the expected height
  16406. * @return a new canvas or offscreen canvas
  16407. */
  16408. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16409. }
  16410. }
  16411. declare module BABYLON {
  16412. /**
  16413. * A class extending Texture allowing drawing on a texture
  16414. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16415. */
  16416. export class DynamicTexture extends Texture {
  16417. private _generateMipMaps;
  16418. private _canvas;
  16419. private _context;
  16420. private _engine;
  16421. /**
  16422. * Creates a DynamicTexture
  16423. * @param name defines the name of the texture
  16424. * @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
  16425. * @param scene defines the scene where you want the texture
  16426. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16427. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16428. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16429. */
  16430. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16431. /**
  16432. * Get the current class name of the texture useful for serialization or dynamic coding.
  16433. * @returns "DynamicTexture"
  16434. */
  16435. getClassName(): string;
  16436. /**
  16437. * Gets the current state of canRescale
  16438. */
  16439. get canRescale(): boolean;
  16440. private _recreate;
  16441. /**
  16442. * Scales the texture
  16443. * @param ratio the scale factor to apply to both width and height
  16444. */
  16445. scale(ratio: number): void;
  16446. /**
  16447. * Resizes the texture
  16448. * @param width the new width
  16449. * @param height the new height
  16450. */
  16451. scaleTo(width: number, height: number): void;
  16452. /**
  16453. * Gets the context of the canvas used by the texture
  16454. * @returns the canvas context of the dynamic texture
  16455. */
  16456. getContext(): CanvasRenderingContext2D;
  16457. /**
  16458. * Clears the texture
  16459. */
  16460. clear(): void;
  16461. /**
  16462. * Updates the texture
  16463. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16464. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16465. */
  16466. update(invertY?: boolean, premulAlpha?: boolean): void;
  16467. /**
  16468. * Draws text onto the texture
  16469. * @param text defines the text to be drawn
  16470. * @param x defines the placement of the text from the left
  16471. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16472. * @param font defines the font to be used with font-style, font-size, font-name
  16473. * @param color defines the color used for the text
  16474. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16475. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16476. * @param update defines whether texture is immediately update (default is true)
  16477. */
  16478. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16479. /**
  16480. * Clones the texture
  16481. * @returns the clone of the texture.
  16482. */
  16483. clone(): DynamicTexture;
  16484. /**
  16485. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16486. * @returns a serialized dynamic texture object
  16487. */
  16488. serialize(): any;
  16489. /** @hidden */
  16490. _rebuild(): void;
  16491. }
  16492. }
  16493. declare module BABYLON {
  16494. interface AbstractScene {
  16495. /**
  16496. * The list of procedural textures added to the scene
  16497. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16498. */
  16499. proceduralTextures: Array<ProceduralTexture>;
  16500. }
  16501. /**
  16502. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16503. * in a given scene.
  16504. */
  16505. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16506. /**
  16507. * The component name helpfull to identify the component in the list of scene components.
  16508. */
  16509. readonly name: string;
  16510. /**
  16511. * The scene the component belongs to.
  16512. */
  16513. scene: Scene;
  16514. /**
  16515. * Creates a new instance of the component for the given scene
  16516. * @param scene Defines the scene to register the component in
  16517. */
  16518. constructor(scene: Scene);
  16519. /**
  16520. * Registers the component in a given scene
  16521. */
  16522. register(): void;
  16523. /**
  16524. * Rebuilds the elements related to this component in case of
  16525. * context lost for instance.
  16526. */
  16527. rebuild(): void;
  16528. /**
  16529. * Disposes the component and the associated ressources.
  16530. */
  16531. dispose(): void;
  16532. private _beforeClear;
  16533. }
  16534. }
  16535. declare module BABYLON {
  16536. interface ThinEngine {
  16537. /**
  16538. * Creates a new render target cube texture
  16539. * @param size defines the size of the texture
  16540. * @param options defines the options used to create the texture
  16541. * @returns a new render target cube texture stored in an InternalTexture
  16542. */
  16543. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16544. }
  16545. }
  16546. declare module BABYLON {
  16547. /** @hidden */
  16548. export var proceduralVertexShader: {
  16549. name: string;
  16550. shader: string;
  16551. };
  16552. }
  16553. declare module BABYLON {
  16554. /**
  16555. * 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.
  16556. * This is the base class of any Procedural texture and contains most of the shareable code.
  16557. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16558. */
  16559. export class ProceduralTexture extends Texture {
  16560. isCube: boolean;
  16561. /**
  16562. * Define if the texture is enabled or not (disabled texture will not render)
  16563. */
  16564. isEnabled: boolean;
  16565. /**
  16566. * Define if the texture must be cleared before rendering (default is true)
  16567. */
  16568. autoClear: boolean;
  16569. /**
  16570. * Callback called when the texture is generated
  16571. */
  16572. onGenerated: () => void;
  16573. /**
  16574. * Event raised when the texture is generated
  16575. */
  16576. onGeneratedObservable: Observable<ProceduralTexture>;
  16577. /** @hidden */
  16578. _generateMipMaps: boolean;
  16579. /** @hidden **/
  16580. _effect: Effect;
  16581. /** @hidden */
  16582. _textures: {
  16583. [key: string]: Texture;
  16584. };
  16585. private _size;
  16586. private _currentRefreshId;
  16587. private _frameId;
  16588. private _refreshRate;
  16589. private _vertexBuffers;
  16590. private _indexBuffer;
  16591. private _uniforms;
  16592. private _samplers;
  16593. private _fragment;
  16594. private _floats;
  16595. private _ints;
  16596. private _floatsArrays;
  16597. private _colors3;
  16598. private _colors4;
  16599. private _vectors2;
  16600. private _vectors3;
  16601. private _matrices;
  16602. private _fallbackTexture;
  16603. private _fallbackTextureUsed;
  16604. private _engine;
  16605. private _cachedDefines;
  16606. private _contentUpdateId;
  16607. private _contentData;
  16608. /**
  16609. * Instantiates a new procedural texture.
  16610. * 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.
  16611. * This is the base class of any Procedural texture and contains most of the shareable code.
  16612. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16613. * @param name Define the name of the texture
  16614. * @param size Define the size of the texture to create
  16615. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16616. * @param scene Define the scene the texture belongs to
  16617. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16618. * @param generateMipMaps Define if the texture should creates mip maps or not
  16619. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16620. */
  16621. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16622. /**
  16623. * The effect that is created when initializing the post process.
  16624. * @returns The created effect corresponding the the postprocess.
  16625. */
  16626. getEffect(): Effect;
  16627. /**
  16628. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16629. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16630. */
  16631. getContent(): Nullable<ArrayBufferView>;
  16632. private _createIndexBuffer;
  16633. /** @hidden */
  16634. _rebuild(): void;
  16635. /**
  16636. * Resets the texture in order to recreate its associated resources.
  16637. * This can be called in case of context loss
  16638. */
  16639. reset(): void;
  16640. protected _getDefines(): string;
  16641. /**
  16642. * Is the texture ready to be used ? (rendered at least once)
  16643. * @returns true if ready, otherwise, false.
  16644. */
  16645. isReady(): boolean;
  16646. /**
  16647. * Resets the refresh counter of the texture and start bak from scratch.
  16648. * Could be useful to regenerate the texture if it is setup to render only once.
  16649. */
  16650. resetRefreshCounter(): void;
  16651. /**
  16652. * Set the fragment shader to use in order to render the texture.
  16653. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16654. */
  16655. setFragment(fragment: any): void;
  16656. /**
  16657. * Define the refresh rate of the texture or the rendering frequency.
  16658. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16659. */
  16660. get refreshRate(): number;
  16661. set refreshRate(value: number);
  16662. /** @hidden */
  16663. _shouldRender(): boolean;
  16664. /**
  16665. * Get the size the texture is rendering at.
  16666. * @returns the size (texture is always squared)
  16667. */
  16668. getRenderSize(): number;
  16669. /**
  16670. * Resize the texture to new value.
  16671. * @param size Define the new size the texture should have
  16672. * @param generateMipMaps Define whether the new texture should create mip maps
  16673. */
  16674. resize(size: number, generateMipMaps: boolean): void;
  16675. private _checkUniform;
  16676. /**
  16677. * Set a texture in the shader program used to render.
  16678. * @param name Define the name of the uniform samplers as defined in the shader
  16679. * @param texture Define the texture to bind to this sampler
  16680. * @return the texture itself allowing "fluent" like uniform updates
  16681. */
  16682. setTexture(name: string, texture: Texture): ProceduralTexture;
  16683. /**
  16684. * Set a float in the shader.
  16685. * @param name Define the name of the uniform as defined in the shader
  16686. * @param value Define the value to give to the uniform
  16687. * @return the texture itself allowing "fluent" like uniform updates
  16688. */
  16689. setFloat(name: string, value: number): ProceduralTexture;
  16690. /**
  16691. * Set a int in the shader.
  16692. * @param name Define the name of the uniform as defined in the shader
  16693. * @param value Define the value to give to the uniform
  16694. * @return the texture itself allowing "fluent" like uniform updates
  16695. */
  16696. setInt(name: string, value: number): ProceduralTexture;
  16697. /**
  16698. * Set an array of floats in the shader.
  16699. * @param name Define the name of the uniform as defined in the shader
  16700. * @param value Define the value to give to the uniform
  16701. * @return the texture itself allowing "fluent" like uniform updates
  16702. */
  16703. setFloats(name: string, value: number[]): ProceduralTexture;
  16704. /**
  16705. * Set a vec3 in the shader from a Color3.
  16706. * @param name Define the name of the uniform as defined in the shader
  16707. * @param value Define the value to give to the uniform
  16708. * @return the texture itself allowing "fluent" like uniform updates
  16709. */
  16710. setColor3(name: string, value: Color3): ProceduralTexture;
  16711. /**
  16712. * Set a vec4 in the shader from a Color4.
  16713. * @param name Define the name of the uniform as defined in the shader
  16714. * @param value Define the value to give to the uniform
  16715. * @return the texture itself allowing "fluent" like uniform updates
  16716. */
  16717. setColor4(name: string, value: Color4): ProceduralTexture;
  16718. /**
  16719. * Set a vec2 in the shader from a Vector2.
  16720. * @param name Define the name of the uniform as defined in the shader
  16721. * @param value Define the value to give to the uniform
  16722. * @return the texture itself allowing "fluent" like uniform updates
  16723. */
  16724. setVector2(name: string, value: Vector2): ProceduralTexture;
  16725. /**
  16726. * Set a vec3 in the shader from a Vector3.
  16727. * @param name Define the name of the uniform as defined in the shader
  16728. * @param value Define the value to give to the uniform
  16729. * @return the texture itself allowing "fluent" like uniform updates
  16730. */
  16731. setVector3(name: string, value: Vector3): ProceduralTexture;
  16732. /**
  16733. * Set a mat4 in the shader from a MAtrix.
  16734. * @param name Define the name of the uniform as defined in the shader
  16735. * @param value Define the value to give to the uniform
  16736. * @return the texture itself allowing "fluent" like uniform updates
  16737. */
  16738. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16739. /**
  16740. * Render the texture to its associated render target.
  16741. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16742. */
  16743. render(useCameraPostProcess?: boolean): void;
  16744. /**
  16745. * Clone the texture.
  16746. * @returns the cloned texture
  16747. */
  16748. clone(): ProceduralTexture;
  16749. /**
  16750. * Dispose the texture and release its asoociated resources.
  16751. */
  16752. dispose(): void;
  16753. }
  16754. }
  16755. declare module BABYLON {
  16756. /**
  16757. * This represents the base class for particle system in Babylon.
  16758. * 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.
  16759. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16760. * @example https://doc.babylonjs.com/babylon101/particles
  16761. */
  16762. export class BaseParticleSystem {
  16763. /**
  16764. * Source color is added to the destination color without alpha affecting the result
  16765. */
  16766. static BLENDMODE_ONEONE: number;
  16767. /**
  16768. * Blend current color and particle color using particle’s alpha
  16769. */
  16770. static BLENDMODE_STANDARD: number;
  16771. /**
  16772. * Add current color and particle color multiplied by particle’s alpha
  16773. */
  16774. static BLENDMODE_ADD: number;
  16775. /**
  16776. * Multiply current color with particle color
  16777. */
  16778. static BLENDMODE_MULTIPLY: number;
  16779. /**
  16780. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16781. */
  16782. static BLENDMODE_MULTIPLYADD: number;
  16783. /**
  16784. * List of animations used by the particle system.
  16785. */
  16786. animations: Animation[];
  16787. /**
  16788. * The id of the Particle system.
  16789. */
  16790. id: string;
  16791. /**
  16792. * The friendly name of the Particle system.
  16793. */
  16794. name: string;
  16795. /**
  16796. * The rendering group used by the Particle system to chose when to render.
  16797. */
  16798. renderingGroupId: number;
  16799. /**
  16800. * The emitter represents the Mesh or position we are attaching the particle system to.
  16801. */
  16802. emitter: Nullable<AbstractMesh | Vector3>;
  16803. /**
  16804. * The maximum number of particles to emit per frame
  16805. */
  16806. emitRate: number;
  16807. /**
  16808. * If you want to launch only a few particles at once, that can be done, as well.
  16809. */
  16810. manualEmitCount: number;
  16811. /**
  16812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16813. */
  16814. updateSpeed: number;
  16815. /**
  16816. * The amount of time the particle system is running (depends of the overall update speed).
  16817. */
  16818. targetStopDuration: number;
  16819. /**
  16820. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16821. */
  16822. disposeOnStop: boolean;
  16823. /**
  16824. * Minimum power of emitting particles.
  16825. */
  16826. minEmitPower: number;
  16827. /**
  16828. * Maximum power of emitting particles.
  16829. */
  16830. maxEmitPower: number;
  16831. /**
  16832. * Minimum life time of emitting particles.
  16833. */
  16834. minLifeTime: number;
  16835. /**
  16836. * Maximum life time of emitting particles.
  16837. */
  16838. maxLifeTime: number;
  16839. /**
  16840. * Minimum Size of emitting particles.
  16841. */
  16842. minSize: number;
  16843. /**
  16844. * Maximum Size of emitting particles.
  16845. */
  16846. maxSize: number;
  16847. /**
  16848. * Minimum scale of emitting particles on X axis.
  16849. */
  16850. minScaleX: number;
  16851. /**
  16852. * Maximum scale of emitting particles on X axis.
  16853. */
  16854. maxScaleX: number;
  16855. /**
  16856. * Minimum scale of emitting particles on Y axis.
  16857. */
  16858. minScaleY: number;
  16859. /**
  16860. * Maximum scale of emitting particles on Y axis.
  16861. */
  16862. maxScaleY: number;
  16863. /**
  16864. * Gets or sets the minimal initial rotation in radians.
  16865. */
  16866. minInitialRotation: number;
  16867. /**
  16868. * Gets or sets the maximal initial rotation in radians.
  16869. */
  16870. maxInitialRotation: number;
  16871. /**
  16872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16873. */
  16874. minAngularSpeed: number;
  16875. /**
  16876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16877. */
  16878. maxAngularSpeed: number;
  16879. /**
  16880. * The texture used to render each particle. (this can be a spritesheet)
  16881. */
  16882. particleTexture: Nullable<Texture>;
  16883. /**
  16884. * The layer mask we are rendering the particles through.
  16885. */
  16886. layerMask: number;
  16887. /**
  16888. * This can help using your own shader to render the particle system.
  16889. * The according effect will be created
  16890. */
  16891. customShader: any;
  16892. /**
  16893. * By default particle system starts as soon as they are created. This prevents the
  16894. * automatic start to happen and let you decide when to start emitting particles.
  16895. */
  16896. preventAutoStart: boolean;
  16897. private _noiseTexture;
  16898. /**
  16899. * Gets or sets a texture used to add random noise to particle positions
  16900. */
  16901. get noiseTexture(): Nullable<ProceduralTexture>;
  16902. set noiseTexture(value: Nullable<ProceduralTexture>);
  16903. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16904. noiseStrength: Vector3;
  16905. /**
  16906. * Callback triggered when the particle animation is ending.
  16907. */
  16908. onAnimationEnd: Nullable<() => void>;
  16909. /**
  16910. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16911. */
  16912. blendMode: number;
  16913. /**
  16914. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16915. * to override the particles.
  16916. */
  16917. forceDepthWrite: boolean;
  16918. /** 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 */
  16919. preWarmCycles: number;
  16920. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16921. preWarmStepOffset: number;
  16922. /**
  16923. * 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)
  16924. */
  16925. spriteCellChangeSpeed: number;
  16926. /**
  16927. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16928. */
  16929. startSpriteCellID: number;
  16930. /**
  16931. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16932. */
  16933. endSpriteCellID: number;
  16934. /**
  16935. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16936. */
  16937. spriteCellWidth: number;
  16938. /**
  16939. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16940. */
  16941. spriteCellHeight: number;
  16942. /**
  16943. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16944. */
  16945. spriteRandomStartCell: boolean;
  16946. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16947. translationPivot: Vector2;
  16948. /** @hidden */
  16949. protected _isAnimationSheetEnabled: boolean;
  16950. /**
  16951. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16952. */
  16953. beginAnimationOnStart: boolean;
  16954. /**
  16955. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16956. */
  16957. beginAnimationFrom: number;
  16958. /**
  16959. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16960. */
  16961. beginAnimationTo: number;
  16962. /**
  16963. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16964. */
  16965. beginAnimationLoop: boolean;
  16966. /**
  16967. * Gets or sets a world offset applied to all particles
  16968. */
  16969. worldOffset: Vector3;
  16970. /**
  16971. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16972. */
  16973. get isAnimationSheetEnabled(): boolean;
  16974. set isAnimationSheetEnabled(value: boolean);
  16975. /**
  16976. * Get hosting scene
  16977. * @returns the scene
  16978. */
  16979. getScene(): Scene;
  16980. /**
  16981. * You can use gravity if you want to give an orientation to your particles.
  16982. */
  16983. gravity: Vector3;
  16984. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16985. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16986. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16987. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16988. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16989. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16990. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16991. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16992. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16993. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16994. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16995. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16996. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16997. /**
  16998. * Defines the delay in milliseconds before starting the system (0 by default)
  16999. */
  17000. startDelay: number;
  17001. /**
  17002. * Gets the current list of drag gradients.
  17003. * You must use addDragGradient and removeDragGradient to udpate this list
  17004. * @returns the list of drag gradients
  17005. */
  17006. getDragGradients(): Nullable<Array<FactorGradient>>;
  17007. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17008. limitVelocityDamping: number;
  17009. /**
  17010. * Gets the current list of limit velocity gradients.
  17011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17012. * @returns the list of limit velocity gradients
  17013. */
  17014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17015. /**
  17016. * Gets the current list of color gradients.
  17017. * You must use addColorGradient and removeColorGradient to udpate this list
  17018. * @returns the list of color gradients
  17019. */
  17020. getColorGradients(): Nullable<Array<ColorGradient>>;
  17021. /**
  17022. * Gets the current list of size gradients.
  17023. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17024. * @returns the list of size gradients
  17025. */
  17026. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17027. /**
  17028. * Gets the current list of color remap gradients.
  17029. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17030. * @returns the list of color remap gradients
  17031. */
  17032. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17033. /**
  17034. * Gets the current list of alpha remap gradients.
  17035. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17036. * @returns the list of alpha remap gradients
  17037. */
  17038. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17039. /**
  17040. * Gets the current list of life time gradients.
  17041. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17042. * @returns the list of life time gradients
  17043. */
  17044. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17045. /**
  17046. * Gets the current list of angular speed gradients.
  17047. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17048. * @returns the list of angular speed gradients
  17049. */
  17050. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17051. /**
  17052. * Gets the current list of velocity gradients.
  17053. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17054. * @returns the list of velocity gradients
  17055. */
  17056. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17057. /**
  17058. * Gets the current list of start size gradients.
  17059. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17060. * @returns the list of start size gradients
  17061. */
  17062. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17063. /**
  17064. * Gets the current list of emit rate gradients.
  17065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17066. * @returns the list of emit rate gradients
  17067. */
  17068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17069. /**
  17070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17072. */
  17073. get direction1(): Vector3;
  17074. set direction1(value: Vector3);
  17075. /**
  17076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17077. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17078. */
  17079. get direction2(): Vector3;
  17080. set direction2(value: Vector3);
  17081. /**
  17082. * 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.
  17083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17084. */
  17085. get minEmitBox(): Vector3;
  17086. set minEmitBox(value: Vector3);
  17087. /**
  17088. * 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.
  17089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17090. */
  17091. get maxEmitBox(): Vector3;
  17092. set maxEmitBox(value: Vector3);
  17093. /**
  17094. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17095. */
  17096. color1: Color4;
  17097. /**
  17098. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17099. */
  17100. color2: Color4;
  17101. /**
  17102. * Color the particle will have at the end of its lifetime
  17103. */
  17104. colorDead: Color4;
  17105. /**
  17106. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17107. */
  17108. textureMask: Color4;
  17109. /**
  17110. * The particle emitter type defines the emitter used by the particle system.
  17111. * It can be for example box, sphere, or cone...
  17112. */
  17113. particleEmitterType: IParticleEmitterType;
  17114. /** @hidden */
  17115. _isSubEmitter: boolean;
  17116. /**
  17117. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17118. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17119. */
  17120. billboardMode: number;
  17121. protected _isBillboardBased: boolean;
  17122. /**
  17123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17124. */
  17125. get isBillboardBased(): boolean;
  17126. set isBillboardBased(value: boolean);
  17127. /**
  17128. * The scene the particle system belongs to.
  17129. */
  17130. protected _scene: Scene;
  17131. /**
  17132. * Local cache of defines for image processing.
  17133. */
  17134. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17135. /**
  17136. * Default configuration related to image processing available in the standard Material.
  17137. */
  17138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17139. /**
  17140. * Gets the image processing configuration used either in this material.
  17141. */
  17142. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17143. /**
  17144. * Sets the Default image processing configuration used either in the this material.
  17145. *
  17146. * If sets to null, the scene one is in use.
  17147. */
  17148. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17149. /**
  17150. * Attaches a new image processing configuration to the Standard Material.
  17151. * @param configuration
  17152. */
  17153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17154. /** @hidden */
  17155. protected _reset(): void;
  17156. /** @hidden */
  17157. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17158. /**
  17159. * Instantiates a particle system.
  17160. * 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.
  17161. * @param name The name of the particle system
  17162. */
  17163. constructor(name: string);
  17164. /**
  17165. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17168. * @returns the emitter
  17169. */
  17170. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17171. /**
  17172. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17173. * @param radius The radius of the hemisphere to emit from
  17174. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17175. * @returns the emitter
  17176. */
  17177. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17178. /**
  17179. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17180. * @param radius The radius of the sphere to emit from
  17181. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17182. * @returns the emitter
  17183. */
  17184. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17185. /**
  17186. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17187. * @param radius The radius of the sphere to emit from
  17188. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17189. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17190. * @returns the emitter
  17191. */
  17192. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17193. /**
  17194. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17195. * @param radius The radius of the emission cylinder
  17196. * @param height The height of the emission cylinder
  17197. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17198. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17199. * @returns the emitter
  17200. */
  17201. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17202. /**
  17203. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17204. * @param radius The radius of the cylinder to emit from
  17205. * @param height The height of the emission cylinder
  17206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17209. * @returns the emitter
  17210. */
  17211. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17212. /**
  17213. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17214. * @param radius The radius of the cone to emit from
  17215. * @param angle The base angle of the cone
  17216. * @returns the emitter
  17217. */
  17218. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17219. /**
  17220. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17223. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17224. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17225. * @returns the emitter
  17226. */
  17227. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17228. }
  17229. }
  17230. declare module BABYLON {
  17231. /**
  17232. * Type of sub emitter
  17233. */
  17234. export enum SubEmitterType {
  17235. /**
  17236. * Attached to the particle over it's lifetime
  17237. */
  17238. ATTACHED = 0,
  17239. /**
  17240. * Created when the particle dies
  17241. */
  17242. END = 1
  17243. }
  17244. /**
  17245. * Sub emitter class used to emit particles from an existing particle
  17246. */
  17247. export class SubEmitter {
  17248. /**
  17249. * the particle system to be used by the sub emitter
  17250. */
  17251. particleSystem: ParticleSystem;
  17252. /**
  17253. * Type of the submitter (Default: END)
  17254. */
  17255. type: SubEmitterType;
  17256. /**
  17257. * 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)
  17258. * Note: This only is supported when using an emitter of type Mesh
  17259. */
  17260. inheritDirection: boolean;
  17261. /**
  17262. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17263. */
  17264. inheritedVelocityAmount: number;
  17265. /**
  17266. * Creates a sub emitter
  17267. * @param particleSystem the particle system to be used by the sub emitter
  17268. */
  17269. constructor(
  17270. /**
  17271. * the particle system to be used by the sub emitter
  17272. */
  17273. particleSystem: ParticleSystem);
  17274. /**
  17275. * Clones the sub emitter
  17276. * @returns the cloned sub emitter
  17277. */
  17278. clone(): SubEmitter;
  17279. /**
  17280. * Serialize current object to a JSON object
  17281. * @returns the serialized object
  17282. */
  17283. serialize(): any;
  17284. /** @hidden */
  17285. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17286. /**
  17287. * Creates a new SubEmitter from a serialized JSON version
  17288. * @param serializationObject defines the JSON object to read from
  17289. * @param scene defines the hosting scene
  17290. * @param rootUrl defines the rootUrl for data loading
  17291. * @returns a new SubEmitter
  17292. */
  17293. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17294. /** Release associated resources */
  17295. dispose(): void;
  17296. }
  17297. }
  17298. declare module BABYLON {
  17299. /** @hidden */
  17300. export var clipPlaneFragmentDeclaration: {
  17301. name: string;
  17302. shader: string;
  17303. };
  17304. }
  17305. declare module BABYLON {
  17306. /** @hidden */
  17307. export var imageProcessingDeclaration: {
  17308. name: string;
  17309. shader: string;
  17310. };
  17311. }
  17312. declare module BABYLON {
  17313. /** @hidden */
  17314. export var imageProcessingFunctions: {
  17315. name: string;
  17316. shader: string;
  17317. };
  17318. }
  17319. declare module BABYLON {
  17320. /** @hidden */
  17321. export var clipPlaneFragment: {
  17322. name: string;
  17323. shader: string;
  17324. };
  17325. }
  17326. declare module BABYLON {
  17327. /** @hidden */
  17328. export var particlesPixelShader: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module BABYLON {
  17334. /** @hidden */
  17335. export var clipPlaneVertexDeclaration: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module BABYLON {
  17341. /** @hidden */
  17342. export var clipPlaneVertex: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module BABYLON {
  17348. /** @hidden */
  17349. export var particlesVertexShader: {
  17350. name: string;
  17351. shader: string;
  17352. };
  17353. }
  17354. declare module BABYLON {
  17355. /**
  17356. * This represents a particle system in Babylon.
  17357. * 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.
  17358. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17359. * @example https://doc.babylonjs.com/babylon101/particles
  17360. */
  17361. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17362. /**
  17363. * Billboard mode will only apply to Y axis
  17364. */
  17365. static readonly BILLBOARDMODE_Y: number;
  17366. /**
  17367. * Billboard mode will apply to all axes
  17368. */
  17369. static readonly BILLBOARDMODE_ALL: number;
  17370. /**
  17371. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17372. */
  17373. static readonly BILLBOARDMODE_STRETCHED: number;
  17374. /**
  17375. * This function can be defined to provide custom update for active particles.
  17376. * This function will be called instead of regular update (age, position, color, etc.).
  17377. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17378. */
  17379. updateFunction: (particles: Particle[]) => void;
  17380. private _emitterWorldMatrix;
  17381. /**
  17382. * This function can be defined to specify initial direction for every new particle.
  17383. * It by default use the emitterType defined function
  17384. */
  17385. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17386. /**
  17387. * This function can be defined to specify initial position for every new particle.
  17388. * It by default use the emitterType defined function
  17389. */
  17390. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17391. /**
  17392. * @hidden
  17393. */
  17394. _inheritedVelocityOffset: Vector3;
  17395. /**
  17396. * An event triggered when the system is disposed
  17397. */
  17398. onDisposeObservable: Observable<ParticleSystem>;
  17399. private _onDisposeObserver;
  17400. /**
  17401. * Sets a callback that will be triggered when the system is disposed
  17402. */
  17403. set onDispose(callback: () => void);
  17404. private _particles;
  17405. private _epsilon;
  17406. private _capacity;
  17407. private _stockParticles;
  17408. private _newPartsExcess;
  17409. private _vertexData;
  17410. private _vertexBuffer;
  17411. private _vertexBuffers;
  17412. private _spriteBuffer;
  17413. private _indexBuffer;
  17414. private _effect;
  17415. private _customEffect;
  17416. private _cachedDefines;
  17417. private _scaledColorStep;
  17418. private _colorDiff;
  17419. private _scaledDirection;
  17420. private _scaledGravity;
  17421. private _currentRenderId;
  17422. private _alive;
  17423. private _useInstancing;
  17424. private _started;
  17425. private _stopped;
  17426. private _actualFrame;
  17427. private _scaledUpdateSpeed;
  17428. private _vertexBufferSize;
  17429. /** @hidden */
  17430. _currentEmitRateGradient: Nullable<FactorGradient>;
  17431. /** @hidden */
  17432. _currentEmitRate1: number;
  17433. /** @hidden */
  17434. _currentEmitRate2: number;
  17435. /** @hidden */
  17436. _currentStartSizeGradient: Nullable<FactorGradient>;
  17437. /** @hidden */
  17438. _currentStartSize1: number;
  17439. /** @hidden */
  17440. _currentStartSize2: number;
  17441. private readonly _rawTextureWidth;
  17442. private _rampGradientsTexture;
  17443. private _useRampGradients;
  17444. /** Gets or sets a boolean indicating that ramp gradients must be used
  17445. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17446. */
  17447. get useRampGradients(): boolean;
  17448. set useRampGradients(value: boolean);
  17449. /**
  17450. * 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.
  17451. * 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: [])
  17452. */
  17453. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17454. private _subEmitters;
  17455. /**
  17456. * @hidden
  17457. * If the particle systems emitter should be disposed when the particle system is disposed
  17458. */
  17459. _disposeEmitterOnDispose: boolean;
  17460. /**
  17461. * The current active Sub-systems, this property is used by the root particle system only.
  17462. */
  17463. activeSubSystems: Array<ParticleSystem>;
  17464. private _rootParticleSystem;
  17465. /**
  17466. * Gets the current list of active particles
  17467. */
  17468. get particles(): Particle[];
  17469. /**
  17470. * Returns the string "ParticleSystem"
  17471. * @returns a string containing the class name
  17472. */
  17473. getClassName(): string;
  17474. /**
  17475. * Instantiates a particle system.
  17476. * 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.
  17477. * @param name The name of the particle system
  17478. * @param capacity The max number of particles alive at the same time
  17479. * @param scene The scene the particle system belongs to
  17480. * @param customEffect a custom effect used to change the way particles are rendered by default
  17481. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17482. * @param epsilon Offset used to render the particles
  17483. */
  17484. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17485. private _addFactorGradient;
  17486. private _removeFactorGradient;
  17487. /**
  17488. * Adds a new life time gradient
  17489. * @param gradient defines the gradient to use (between 0 and 1)
  17490. * @param factor defines the life time factor to affect to the specified gradient
  17491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17492. * @returns the current particle system
  17493. */
  17494. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17495. /**
  17496. * Remove a specific life time gradient
  17497. * @param gradient defines the gradient to remove
  17498. * @returns the current particle system
  17499. */
  17500. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17501. /**
  17502. * Adds a new size gradient
  17503. * @param gradient defines the gradient to use (between 0 and 1)
  17504. * @param factor defines the size factor to affect to the specified gradient
  17505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17506. * @returns the current particle system
  17507. */
  17508. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17509. /**
  17510. * Remove a specific size gradient
  17511. * @param gradient defines the gradient to remove
  17512. * @returns the current particle system
  17513. */
  17514. removeSizeGradient(gradient: number): IParticleSystem;
  17515. /**
  17516. * Adds a new color remap gradient
  17517. * @param gradient defines the gradient to use (between 0 and 1)
  17518. * @param min defines the color remap minimal range
  17519. * @param max defines the color remap maximal range
  17520. * @returns the current particle system
  17521. */
  17522. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17523. /**
  17524. * Remove a specific color remap gradient
  17525. * @param gradient defines the gradient to remove
  17526. * @returns the current particle system
  17527. */
  17528. removeColorRemapGradient(gradient: number): IParticleSystem;
  17529. /**
  17530. * Adds a new alpha remap gradient
  17531. * @param gradient defines the gradient to use (between 0 and 1)
  17532. * @param min defines the alpha remap minimal range
  17533. * @param max defines the alpha remap maximal range
  17534. * @returns the current particle system
  17535. */
  17536. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17537. /**
  17538. * Remove a specific alpha remap gradient
  17539. * @param gradient defines the gradient to remove
  17540. * @returns the current particle system
  17541. */
  17542. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17543. /**
  17544. * Adds a new angular speed gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param factor defines the angular speed to affect to the specified gradient
  17547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17548. * @returns the current particle system
  17549. */
  17550. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17551. /**
  17552. * Remove a specific angular speed gradient
  17553. * @param gradient defines the gradient to remove
  17554. * @returns the current particle system
  17555. */
  17556. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17557. /**
  17558. * Adds a new velocity gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param factor defines the velocity to affect to the specified gradient
  17561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17562. * @returns the current particle system
  17563. */
  17564. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17565. /**
  17566. * Remove a specific velocity gradient
  17567. * @param gradient defines the gradient to remove
  17568. * @returns the current particle system
  17569. */
  17570. removeVelocityGradient(gradient: number): IParticleSystem;
  17571. /**
  17572. * Adds a new limit velocity gradient
  17573. * @param gradient defines the gradient to use (between 0 and 1)
  17574. * @param factor defines the limit velocity value to affect to the specified gradient
  17575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17576. * @returns the current particle system
  17577. */
  17578. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17579. /**
  17580. * Remove a specific limit velocity gradient
  17581. * @param gradient defines the gradient to remove
  17582. * @returns the current particle system
  17583. */
  17584. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17585. /**
  17586. * Adds a new drag gradient
  17587. * @param gradient defines the gradient to use (between 0 and 1)
  17588. * @param factor defines the drag value to affect to the specified gradient
  17589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17590. * @returns the current particle system
  17591. */
  17592. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17593. /**
  17594. * Remove a specific drag gradient
  17595. * @param gradient defines the gradient to remove
  17596. * @returns the current particle system
  17597. */
  17598. removeDragGradient(gradient: number): IParticleSystem;
  17599. /**
  17600. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17601. * @param gradient defines the gradient to use (between 0 and 1)
  17602. * @param factor defines the emit rate value to affect to the specified gradient
  17603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17604. * @returns the current particle system
  17605. */
  17606. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17607. /**
  17608. * Remove a specific emit rate gradient
  17609. * @param gradient defines the gradient to remove
  17610. * @returns the current particle system
  17611. */
  17612. removeEmitRateGradient(gradient: number): IParticleSystem;
  17613. /**
  17614. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17615. * @param gradient defines the gradient to use (between 0 and 1)
  17616. * @param factor defines the start size value to affect to the specified gradient
  17617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17618. * @returns the current particle system
  17619. */
  17620. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17621. /**
  17622. * Remove a specific start size gradient
  17623. * @param gradient defines the gradient to remove
  17624. * @returns the current particle system
  17625. */
  17626. removeStartSizeGradient(gradient: number): IParticleSystem;
  17627. private _createRampGradientTexture;
  17628. /**
  17629. * Gets the current list of ramp gradients.
  17630. * You must use addRampGradient and removeRampGradient to udpate this list
  17631. * @returns the list of ramp gradients
  17632. */
  17633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17634. /**
  17635. * Adds a new ramp gradient used to remap particle colors
  17636. * @param gradient defines the gradient to use (between 0 and 1)
  17637. * @param color defines the color to affect to the specified gradient
  17638. * @returns the current particle system
  17639. */
  17640. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17641. /**
  17642. * Remove a specific ramp gradient
  17643. * @param gradient defines the gradient to remove
  17644. * @returns the current particle system
  17645. */
  17646. removeRampGradient(gradient: number): ParticleSystem;
  17647. /**
  17648. * Adds a new color gradient
  17649. * @param gradient defines the gradient to use (between 0 and 1)
  17650. * @param color1 defines the color to affect to the specified gradient
  17651. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17652. * @returns this particle system
  17653. */
  17654. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17655. /**
  17656. * Remove a specific color gradient
  17657. * @param gradient defines the gradient to remove
  17658. * @returns this particle system
  17659. */
  17660. removeColorGradient(gradient: number): IParticleSystem;
  17661. private _fetchR;
  17662. protected _reset(): void;
  17663. private _resetEffect;
  17664. private _createVertexBuffers;
  17665. private _createIndexBuffer;
  17666. /**
  17667. * Gets the maximum number of particles active at the same time.
  17668. * @returns The max number of active particles.
  17669. */
  17670. getCapacity(): number;
  17671. /**
  17672. * Gets whether there are still active particles in the system.
  17673. * @returns True if it is alive, otherwise false.
  17674. */
  17675. isAlive(): boolean;
  17676. /**
  17677. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17678. * @returns True if it has been started, otherwise false.
  17679. */
  17680. isStarted(): boolean;
  17681. private _prepareSubEmitterInternalArray;
  17682. /**
  17683. * Starts the particle system and begins to emit
  17684. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17685. */
  17686. start(delay?: number): void;
  17687. /**
  17688. * Stops the particle system.
  17689. * @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.
  17690. */
  17691. stop(stopSubEmitters?: boolean): void;
  17692. /**
  17693. * Remove all active particles
  17694. */
  17695. reset(): void;
  17696. /**
  17697. * @hidden (for internal use only)
  17698. */
  17699. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17700. /**
  17701. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17702. * Its lifetime will start back at 0.
  17703. */
  17704. recycleParticle: (particle: Particle) => void;
  17705. private _stopSubEmitters;
  17706. private _createParticle;
  17707. private _removeFromRoot;
  17708. private _emitFromParticle;
  17709. private _update;
  17710. /** @hidden */
  17711. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17712. /** @hidden */
  17713. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17714. /** @hidden */
  17715. private _getEffect;
  17716. /**
  17717. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17718. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17719. */
  17720. animate(preWarmOnly?: boolean): void;
  17721. private _appendParticleVertices;
  17722. /**
  17723. * Rebuilds the particle system.
  17724. */
  17725. rebuild(): void;
  17726. /**
  17727. * Is this system ready to be used/rendered
  17728. * @return true if the system is ready
  17729. */
  17730. isReady(): boolean;
  17731. private _render;
  17732. /**
  17733. * Renders the particle system in its current state.
  17734. * @returns the current number of particles
  17735. */
  17736. render(): number;
  17737. /**
  17738. * Disposes the particle system and free the associated resources
  17739. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17740. */
  17741. dispose(disposeTexture?: boolean): void;
  17742. /**
  17743. * Clones the particle system.
  17744. * @param name The name of the cloned object
  17745. * @param newEmitter The new emitter to use
  17746. * @returns the cloned particle system
  17747. */
  17748. clone(name: string, newEmitter: any): ParticleSystem;
  17749. /**
  17750. * Serializes the particle system to a JSON object.
  17751. * @returns the JSON object
  17752. */
  17753. serialize(): any;
  17754. /** @hidden */
  17755. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17756. /** @hidden */
  17757. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17758. /**
  17759. * Parses a JSON object to create a particle system.
  17760. * @param parsedParticleSystem The JSON object to parse
  17761. * @param scene The scene to create the particle system in
  17762. * @param rootUrl The root url to use to load external dependencies like texture
  17763. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17764. * @returns the Parsed particle system
  17765. */
  17766. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17767. }
  17768. }
  17769. declare module BABYLON {
  17770. /**
  17771. * A particle represents one of the element emitted by a particle system.
  17772. * This is mainly define by its coordinates, direction, velocity and age.
  17773. */
  17774. export class Particle {
  17775. /**
  17776. * The particle system the particle belongs to.
  17777. */
  17778. particleSystem: ParticleSystem;
  17779. private static _Count;
  17780. /**
  17781. * Unique ID of the particle
  17782. */
  17783. id: number;
  17784. /**
  17785. * The world position of the particle in the scene.
  17786. */
  17787. position: Vector3;
  17788. /**
  17789. * The world direction of the particle in the scene.
  17790. */
  17791. direction: Vector3;
  17792. /**
  17793. * The color of the particle.
  17794. */
  17795. color: Color4;
  17796. /**
  17797. * The color change of the particle per step.
  17798. */
  17799. colorStep: Color4;
  17800. /**
  17801. * Defines how long will the life of the particle be.
  17802. */
  17803. lifeTime: number;
  17804. /**
  17805. * The current age of the particle.
  17806. */
  17807. age: number;
  17808. /**
  17809. * The current size of the particle.
  17810. */
  17811. size: number;
  17812. /**
  17813. * The current scale of the particle.
  17814. */
  17815. scale: Vector2;
  17816. /**
  17817. * The current angle of the particle.
  17818. */
  17819. angle: number;
  17820. /**
  17821. * Defines how fast is the angle changing.
  17822. */
  17823. angularSpeed: number;
  17824. /**
  17825. * Defines the cell index used by the particle to be rendered from a sprite.
  17826. */
  17827. cellIndex: number;
  17828. /**
  17829. * The information required to support color remapping
  17830. */
  17831. remapData: Vector4;
  17832. /** @hidden */
  17833. _randomCellOffset?: number;
  17834. /** @hidden */
  17835. _initialDirection: Nullable<Vector3>;
  17836. /** @hidden */
  17837. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17838. /** @hidden */
  17839. _initialStartSpriteCellID: number;
  17840. /** @hidden */
  17841. _initialEndSpriteCellID: number;
  17842. /** @hidden */
  17843. _currentColorGradient: Nullable<ColorGradient>;
  17844. /** @hidden */
  17845. _currentColor1: Color4;
  17846. /** @hidden */
  17847. _currentColor2: Color4;
  17848. /** @hidden */
  17849. _currentSizeGradient: Nullable<FactorGradient>;
  17850. /** @hidden */
  17851. _currentSize1: number;
  17852. /** @hidden */
  17853. _currentSize2: number;
  17854. /** @hidden */
  17855. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17856. /** @hidden */
  17857. _currentAngularSpeed1: number;
  17858. /** @hidden */
  17859. _currentAngularSpeed2: number;
  17860. /** @hidden */
  17861. _currentVelocityGradient: Nullable<FactorGradient>;
  17862. /** @hidden */
  17863. _currentVelocity1: number;
  17864. /** @hidden */
  17865. _currentVelocity2: number;
  17866. /** @hidden */
  17867. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17868. /** @hidden */
  17869. _currentLimitVelocity1: number;
  17870. /** @hidden */
  17871. _currentLimitVelocity2: number;
  17872. /** @hidden */
  17873. _currentDragGradient: Nullable<FactorGradient>;
  17874. /** @hidden */
  17875. _currentDrag1: number;
  17876. /** @hidden */
  17877. _currentDrag2: number;
  17878. /** @hidden */
  17879. _randomNoiseCoordinates1: Vector3;
  17880. /** @hidden */
  17881. _randomNoiseCoordinates2: Vector3;
  17882. /**
  17883. * Creates a new instance Particle
  17884. * @param particleSystem the particle system the particle belongs to
  17885. */
  17886. constructor(
  17887. /**
  17888. * The particle system the particle belongs to.
  17889. */
  17890. particleSystem: ParticleSystem);
  17891. private updateCellInfoFromSystem;
  17892. /**
  17893. * Defines how the sprite cell index is updated for the particle
  17894. */
  17895. updateCellIndex(): void;
  17896. /** @hidden */
  17897. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17898. /** @hidden */
  17899. _inheritParticleInfoToSubEmitters(): void;
  17900. /** @hidden */
  17901. _reset(): void;
  17902. /**
  17903. * Copy the properties of particle to another one.
  17904. * @param other the particle to copy the information to.
  17905. */
  17906. copyTo(other: Particle): void;
  17907. }
  17908. }
  17909. declare module BABYLON {
  17910. /**
  17911. * Particle emitter represents a volume emitting particles.
  17912. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17913. */
  17914. export interface IParticleEmitterType {
  17915. /**
  17916. * Called by the particle System when the direction is computed for the created particle.
  17917. * @param worldMatrix is the world matrix of the particle system
  17918. * @param directionToUpdate is the direction vector to update with the result
  17919. * @param particle is the particle we are computed the direction for
  17920. */
  17921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17922. /**
  17923. * Called by the particle System when the position is computed for the created particle.
  17924. * @param worldMatrix is the world matrix of the particle system
  17925. * @param positionToUpdate is the position vector to update with the result
  17926. * @param particle is the particle we are computed the position for
  17927. */
  17928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17929. /**
  17930. * Clones the current emitter and returns a copy of it
  17931. * @returns the new emitter
  17932. */
  17933. clone(): IParticleEmitterType;
  17934. /**
  17935. * Called by the GPUParticleSystem to setup the update shader
  17936. * @param effect defines the update shader
  17937. */
  17938. applyToShader(effect: Effect): void;
  17939. /**
  17940. * Returns a string to use to update the GPU particles update shader
  17941. * @returns the effect defines string
  17942. */
  17943. getEffectDefines(): string;
  17944. /**
  17945. * Returns a string representing the class name
  17946. * @returns a string containing the class name
  17947. */
  17948. getClassName(): string;
  17949. /**
  17950. * Serializes the particle system to a JSON object.
  17951. * @returns the JSON object
  17952. */
  17953. serialize(): any;
  17954. /**
  17955. * Parse properties from a JSON object
  17956. * @param serializationObject defines the JSON object
  17957. */
  17958. parse(serializationObject: any): void;
  17959. }
  17960. }
  17961. declare module BABYLON {
  17962. /**
  17963. * Particle emitter emitting particles from the inside of a box.
  17964. * It emits the particles randomly between 2 given directions.
  17965. */
  17966. export class BoxParticleEmitter implements IParticleEmitterType {
  17967. /**
  17968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17969. */
  17970. direction1: Vector3;
  17971. /**
  17972. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17973. */
  17974. direction2: Vector3;
  17975. /**
  17976. * 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.
  17977. */
  17978. minEmitBox: Vector3;
  17979. /**
  17980. * 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.
  17981. */
  17982. maxEmitBox: Vector3;
  17983. /**
  17984. * Creates a new instance BoxParticleEmitter
  17985. */
  17986. constructor();
  17987. /**
  17988. * Called by the particle System when the direction is computed for the created particle.
  17989. * @param worldMatrix is the world matrix of the particle system
  17990. * @param directionToUpdate is the direction vector to update with the result
  17991. * @param particle is the particle we are computed the direction for
  17992. */
  17993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17994. /**
  17995. * Called by the particle System when the position is computed for the created particle.
  17996. * @param worldMatrix is the world matrix of the particle system
  17997. * @param positionToUpdate is the position vector to update with the result
  17998. * @param particle is the particle we are computed the position for
  17999. */
  18000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18001. /**
  18002. * Clones the current emitter and returns a copy of it
  18003. * @returns the new emitter
  18004. */
  18005. clone(): BoxParticleEmitter;
  18006. /**
  18007. * Called by the GPUParticleSystem to setup the update shader
  18008. * @param effect defines the update shader
  18009. */
  18010. applyToShader(effect: Effect): void;
  18011. /**
  18012. * Returns a string to use to update the GPU particles update shader
  18013. * @returns a string containng the defines string
  18014. */
  18015. getEffectDefines(): string;
  18016. /**
  18017. * Returns the string "BoxParticleEmitter"
  18018. * @returns a string containing the class name
  18019. */
  18020. getClassName(): string;
  18021. /**
  18022. * Serializes the particle system to a JSON object.
  18023. * @returns the JSON object
  18024. */
  18025. serialize(): any;
  18026. /**
  18027. * Parse properties from a JSON object
  18028. * @param serializationObject defines the JSON object
  18029. */
  18030. parse(serializationObject: any): void;
  18031. }
  18032. }
  18033. declare module BABYLON {
  18034. /**
  18035. * Particle emitter emitting particles from the inside of a cone.
  18036. * It emits the particles alongside the cone volume from the base to the particle.
  18037. * The emission direction might be randomized.
  18038. */
  18039. export class ConeParticleEmitter implements IParticleEmitterType {
  18040. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18041. directionRandomizer: number;
  18042. private _radius;
  18043. private _angle;
  18044. private _height;
  18045. /**
  18046. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18047. */
  18048. radiusRange: number;
  18049. /**
  18050. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18051. */
  18052. heightRange: number;
  18053. /**
  18054. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18055. */
  18056. emitFromSpawnPointOnly: boolean;
  18057. /**
  18058. * Gets or sets the radius of the emission cone
  18059. */
  18060. get radius(): number;
  18061. set radius(value: number);
  18062. /**
  18063. * Gets or sets the angle of the emission cone
  18064. */
  18065. get angle(): number;
  18066. set angle(value: number);
  18067. private _buildHeight;
  18068. /**
  18069. * Creates a new instance ConeParticleEmitter
  18070. * @param radius the radius of the emission cone (1 by default)
  18071. * @param angle the cone base angle (PI by default)
  18072. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18073. */
  18074. constructor(radius?: number, angle?: number,
  18075. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18076. directionRandomizer?: number);
  18077. /**
  18078. * Called by the particle System when the direction is computed for the created particle.
  18079. * @param worldMatrix is the world matrix of the particle system
  18080. * @param directionToUpdate is the direction vector to update with the result
  18081. * @param particle is the particle we are computed the direction for
  18082. */
  18083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18084. /**
  18085. * Called by the particle System when the position is computed for the created particle.
  18086. * @param worldMatrix is the world matrix of the particle system
  18087. * @param positionToUpdate is the position vector to update with the result
  18088. * @param particle is the particle we are computed the position for
  18089. */
  18090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18091. /**
  18092. * Clones the current emitter and returns a copy of it
  18093. * @returns the new emitter
  18094. */
  18095. clone(): ConeParticleEmitter;
  18096. /**
  18097. * Called by the GPUParticleSystem to setup the update shader
  18098. * @param effect defines the update shader
  18099. */
  18100. applyToShader(effect: Effect): void;
  18101. /**
  18102. * Returns a string to use to update the GPU particles update shader
  18103. * @returns a string containng the defines string
  18104. */
  18105. getEffectDefines(): string;
  18106. /**
  18107. * Returns the string "ConeParticleEmitter"
  18108. * @returns a string containing the class name
  18109. */
  18110. getClassName(): string;
  18111. /**
  18112. * Serializes the particle system to a JSON object.
  18113. * @returns the JSON object
  18114. */
  18115. serialize(): any;
  18116. /**
  18117. * Parse properties from a JSON object
  18118. * @param serializationObject defines the JSON object
  18119. */
  18120. parse(serializationObject: any): void;
  18121. }
  18122. }
  18123. declare module BABYLON {
  18124. /**
  18125. * Particle emitter emitting particles from the inside of a cylinder.
  18126. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18127. */
  18128. export class CylinderParticleEmitter implements IParticleEmitterType {
  18129. /**
  18130. * The radius of the emission cylinder.
  18131. */
  18132. radius: number;
  18133. /**
  18134. * The height of the emission cylinder.
  18135. */
  18136. height: number;
  18137. /**
  18138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18139. */
  18140. radiusRange: number;
  18141. /**
  18142. * How much to randomize the particle direction [0-1].
  18143. */
  18144. directionRandomizer: number;
  18145. /**
  18146. * Creates a new instance CylinderParticleEmitter
  18147. * @param radius the radius of the emission cylinder (1 by default)
  18148. * @param height the height of the emission cylinder (1 by default)
  18149. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18150. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18151. */
  18152. constructor(
  18153. /**
  18154. * The radius of the emission cylinder.
  18155. */
  18156. radius?: number,
  18157. /**
  18158. * The height of the emission cylinder.
  18159. */
  18160. height?: number,
  18161. /**
  18162. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18163. */
  18164. radiusRange?: number,
  18165. /**
  18166. * How much to randomize the particle direction [0-1].
  18167. */
  18168. directionRandomizer?: number);
  18169. /**
  18170. * Called by the particle System when the direction is computed for the created particle.
  18171. * @param worldMatrix is the world matrix of the particle system
  18172. * @param directionToUpdate is the direction vector to update with the result
  18173. * @param particle is the particle we are computed the direction for
  18174. */
  18175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18176. /**
  18177. * Called by the particle System when the position is computed for the created particle.
  18178. * @param worldMatrix is the world matrix of the particle system
  18179. * @param positionToUpdate is the position vector to update with the result
  18180. * @param particle is the particle we are computed the position for
  18181. */
  18182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18183. /**
  18184. * Clones the current emitter and returns a copy of it
  18185. * @returns the new emitter
  18186. */
  18187. clone(): CylinderParticleEmitter;
  18188. /**
  18189. * Called by the GPUParticleSystem to setup the update shader
  18190. * @param effect defines the update shader
  18191. */
  18192. applyToShader(effect: Effect): void;
  18193. /**
  18194. * Returns a string to use to update the GPU particles update shader
  18195. * @returns a string containng the defines string
  18196. */
  18197. getEffectDefines(): string;
  18198. /**
  18199. * Returns the string "CylinderParticleEmitter"
  18200. * @returns a string containing the class name
  18201. */
  18202. getClassName(): string;
  18203. /**
  18204. * Serializes the particle system to a JSON object.
  18205. * @returns the JSON object
  18206. */
  18207. serialize(): any;
  18208. /**
  18209. * Parse properties from a JSON object
  18210. * @param serializationObject defines the JSON object
  18211. */
  18212. parse(serializationObject: any): void;
  18213. }
  18214. /**
  18215. * Particle emitter emitting particles from the inside of a cylinder.
  18216. * It emits the particles randomly between two vectors.
  18217. */
  18218. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18219. /**
  18220. * The min limit of the emission direction.
  18221. */
  18222. direction1: Vector3;
  18223. /**
  18224. * The max limit of the emission direction.
  18225. */
  18226. direction2: Vector3;
  18227. /**
  18228. * Creates a new instance CylinderDirectedParticleEmitter
  18229. * @param radius the radius of the emission cylinder (1 by default)
  18230. * @param height the height of the emission cylinder (1 by default)
  18231. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18232. * @param direction1 the min limit of the emission direction (up vector by default)
  18233. * @param direction2 the max limit of the emission direction (up vector by default)
  18234. */
  18235. constructor(radius?: number, height?: number, radiusRange?: number,
  18236. /**
  18237. * The min limit of the emission direction.
  18238. */
  18239. direction1?: Vector3,
  18240. /**
  18241. * The max limit of the emission direction.
  18242. */
  18243. direction2?: Vector3);
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Clones the current emitter and returns a copy of it
  18253. * @returns the new emitter
  18254. */
  18255. clone(): CylinderDirectedParticleEmitter;
  18256. /**
  18257. * Called by the GPUParticleSystem to setup the update shader
  18258. * @param effect defines the update shader
  18259. */
  18260. applyToShader(effect: Effect): void;
  18261. /**
  18262. * Returns a string to use to update the GPU particles update shader
  18263. * @returns a string containng the defines string
  18264. */
  18265. getEffectDefines(): string;
  18266. /**
  18267. * Returns the string "CylinderDirectedParticleEmitter"
  18268. * @returns a string containing the class name
  18269. */
  18270. getClassName(): string;
  18271. /**
  18272. * Serializes the particle system to a JSON object.
  18273. * @returns the JSON object
  18274. */
  18275. serialize(): any;
  18276. /**
  18277. * Parse properties from a JSON object
  18278. * @param serializationObject defines the JSON object
  18279. */
  18280. parse(serializationObject: any): void;
  18281. }
  18282. }
  18283. declare module BABYLON {
  18284. /**
  18285. * Particle emitter emitting particles from the inside of a hemisphere.
  18286. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18287. */
  18288. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18289. /**
  18290. * The radius of the emission hemisphere.
  18291. */
  18292. radius: number;
  18293. /**
  18294. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18295. */
  18296. radiusRange: number;
  18297. /**
  18298. * How much to randomize the particle direction [0-1].
  18299. */
  18300. directionRandomizer: number;
  18301. /**
  18302. * Creates a new instance HemisphericParticleEmitter
  18303. * @param radius the radius of the emission hemisphere (1 by default)
  18304. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18305. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18306. */
  18307. constructor(
  18308. /**
  18309. * The radius of the emission hemisphere.
  18310. */
  18311. radius?: number,
  18312. /**
  18313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18314. */
  18315. radiusRange?: number,
  18316. /**
  18317. * How much to randomize the particle direction [0-1].
  18318. */
  18319. directionRandomizer?: number);
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): HemisphericParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "HemisphericParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. }
  18366. declare module BABYLON {
  18367. /**
  18368. * Particle emitter emitting particles from a point.
  18369. * It emits the particles randomly between 2 given directions.
  18370. */
  18371. export class PointParticleEmitter implements IParticleEmitterType {
  18372. /**
  18373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18374. */
  18375. direction1: Vector3;
  18376. /**
  18377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18378. */
  18379. direction2: Vector3;
  18380. /**
  18381. * Creates a new instance PointParticleEmitter
  18382. */
  18383. constructor();
  18384. /**
  18385. * Called by the particle System when the direction is computed for the created particle.
  18386. * @param worldMatrix is the world matrix of the particle system
  18387. * @param directionToUpdate is the direction vector to update with the result
  18388. * @param particle is the particle we are computed the direction for
  18389. */
  18390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18391. /**
  18392. * Called by the particle System when the position is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param positionToUpdate is the position vector to update with the result
  18395. * @param particle is the particle we are computed the position for
  18396. */
  18397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): PointParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "PointParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module BABYLON {
  18431. /**
  18432. * Particle emitter emitting particles from the inside of a sphere.
  18433. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18434. */
  18435. export class SphereParticleEmitter implements IParticleEmitterType {
  18436. /**
  18437. * The radius of the emission sphere.
  18438. */
  18439. radius: number;
  18440. /**
  18441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18442. */
  18443. radiusRange: number;
  18444. /**
  18445. * How much to randomize the particle direction [0-1].
  18446. */
  18447. directionRandomizer: number;
  18448. /**
  18449. * Creates a new instance SphereParticleEmitter
  18450. * @param radius the radius of the emission sphere (1 by default)
  18451. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18453. */
  18454. constructor(
  18455. /**
  18456. * The radius of the emission sphere.
  18457. */
  18458. radius?: number,
  18459. /**
  18460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18461. */
  18462. radiusRange?: number,
  18463. /**
  18464. * How much to randomize the particle direction [0-1].
  18465. */
  18466. directionRandomizer?: number);
  18467. /**
  18468. * Called by the particle System when the direction is computed for the created particle.
  18469. * @param worldMatrix is the world matrix of the particle system
  18470. * @param directionToUpdate is the direction vector to update with the result
  18471. * @param particle is the particle we are computed the direction for
  18472. */
  18473. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18474. /**
  18475. * Called by the particle System when the position is computed for the created particle.
  18476. * @param worldMatrix is the world matrix of the particle system
  18477. * @param positionToUpdate is the position vector to update with the result
  18478. * @param particle is the particle we are computed the position for
  18479. */
  18480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18481. /**
  18482. * Clones the current emitter and returns a copy of it
  18483. * @returns the new emitter
  18484. */
  18485. clone(): SphereParticleEmitter;
  18486. /**
  18487. * Called by the GPUParticleSystem to setup the update shader
  18488. * @param effect defines the update shader
  18489. */
  18490. applyToShader(effect: Effect): void;
  18491. /**
  18492. * Returns a string to use to update the GPU particles update shader
  18493. * @returns a string containng the defines string
  18494. */
  18495. getEffectDefines(): string;
  18496. /**
  18497. * Returns the string "SphereParticleEmitter"
  18498. * @returns a string containing the class name
  18499. */
  18500. getClassName(): string;
  18501. /**
  18502. * Serializes the particle system to a JSON object.
  18503. * @returns the JSON object
  18504. */
  18505. serialize(): any;
  18506. /**
  18507. * Parse properties from a JSON object
  18508. * @param serializationObject defines the JSON object
  18509. */
  18510. parse(serializationObject: any): void;
  18511. }
  18512. /**
  18513. * Particle emitter emitting particles from the inside of a sphere.
  18514. * It emits the particles randomly between two vectors.
  18515. */
  18516. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18517. /**
  18518. * The min limit of the emission direction.
  18519. */
  18520. direction1: Vector3;
  18521. /**
  18522. * The max limit of the emission direction.
  18523. */
  18524. direction2: Vector3;
  18525. /**
  18526. * Creates a new instance SphereDirectedParticleEmitter
  18527. * @param radius the radius of the emission sphere (1 by default)
  18528. * @param direction1 the min limit of the emission direction (up vector by default)
  18529. * @param direction2 the max limit of the emission direction (up vector by default)
  18530. */
  18531. constructor(radius?: number,
  18532. /**
  18533. * The min limit of the emission direction.
  18534. */
  18535. direction1?: Vector3,
  18536. /**
  18537. * The max limit of the emission direction.
  18538. */
  18539. direction2?: Vector3);
  18540. /**
  18541. * Called by the particle System when the direction is computed for the created particle.
  18542. * @param worldMatrix is the world matrix of the particle system
  18543. * @param directionToUpdate is the direction vector to update with the result
  18544. * @param particle is the particle we are computed the direction for
  18545. */
  18546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18547. /**
  18548. * Clones the current emitter and returns a copy of it
  18549. * @returns the new emitter
  18550. */
  18551. clone(): SphereDirectedParticleEmitter;
  18552. /**
  18553. * Called by the GPUParticleSystem to setup the update shader
  18554. * @param effect defines the update shader
  18555. */
  18556. applyToShader(effect: Effect): void;
  18557. /**
  18558. * Returns a string to use to update the GPU particles update shader
  18559. * @returns a string containng the defines string
  18560. */
  18561. getEffectDefines(): string;
  18562. /**
  18563. * Returns the string "SphereDirectedParticleEmitter"
  18564. * @returns a string containing the class name
  18565. */
  18566. getClassName(): string;
  18567. /**
  18568. * Serializes the particle system to a JSON object.
  18569. * @returns the JSON object
  18570. */
  18571. serialize(): any;
  18572. /**
  18573. * Parse properties from a JSON object
  18574. * @param serializationObject defines the JSON object
  18575. */
  18576. parse(serializationObject: any): void;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Interface representing a particle system in Babylon.js.
  18582. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18583. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18584. */
  18585. export interface IParticleSystem {
  18586. /**
  18587. * List of animations used by the particle system.
  18588. */
  18589. animations: Animation[];
  18590. /**
  18591. * The id of the Particle system.
  18592. */
  18593. id: string;
  18594. /**
  18595. * The name of the Particle system.
  18596. */
  18597. name: string;
  18598. /**
  18599. * The emitter represents the Mesh or position we are attaching the particle system to.
  18600. */
  18601. emitter: Nullable<AbstractMesh | Vector3>;
  18602. /**
  18603. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18604. */
  18605. isBillboardBased: boolean;
  18606. /**
  18607. * The rendering group used by the Particle system to chose when to render.
  18608. */
  18609. renderingGroupId: number;
  18610. /**
  18611. * The layer mask we are rendering the particles through.
  18612. */
  18613. layerMask: number;
  18614. /**
  18615. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18616. */
  18617. updateSpeed: number;
  18618. /**
  18619. * The amount of time the particle system is running (depends of the overall update speed).
  18620. */
  18621. targetStopDuration: number;
  18622. /**
  18623. * The texture used to render each particle. (this can be a spritesheet)
  18624. */
  18625. particleTexture: Nullable<Texture>;
  18626. /**
  18627. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18628. */
  18629. blendMode: number;
  18630. /**
  18631. * Minimum life time of emitting particles.
  18632. */
  18633. minLifeTime: number;
  18634. /**
  18635. * Maximum life time of emitting particles.
  18636. */
  18637. maxLifeTime: number;
  18638. /**
  18639. * Minimum Size of emitting particles.
  18640. */
  18641. minSize: number;
  18642. /**
  18643. * Maximum Size of emitting particles.
  18644. */
  18645. maxSize: number;
  18646. /**
  18647. * Minimum scale of emitting particles on X axis.
  18648. */
  18649. minScaleX: number;
  18650. /**
  18651. * Maximum scale of emitting particles on X axis.
  18652. */
  18653. maxScaleX: number;
  18654. /**
  18655. * Minimum scale of emitting particles on Y axis.
  18656. */
  18657. minScaleY: number;
  18658. /**
  18659. * Maximum scale of emitting particles on Y axis.
  18660. */
  18661. maxScaleY: number;
  18662. /**
  18663. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18664. */
  18665. color1: Color4;
  18666. /**
  18667. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18668. */
  18669. color2: Color4;
  18670. /**
  18671. * Color the particle will have at the end of its lifetime.
  18672. */
  18673. colorDead: Color4;
  18674. /**
  18675. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18676. */
  18677. emitRate: number;
  18678. /**
  18679. * You can use gravity if you want to give an orientation to your particles.
  18680. */
  18681. gravity: Vector3;
  18682. /**
  18683. * Minimum power of emitting particles.
  18684. */
  18685. minEmitPower: number;
  18686. /**
  18687. * Maximum power of emitting particles.
  18688. */
  18689. maxEmitPower: number;
  18690. /**
  18691. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18692. */
  18693. minAngularSpeed: number;
  18694. /**
  18695. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18696. */
  18697. maxAngularSpeed: number;
  18698. /**
  18699. * Gets or sets the minimal initial rotation in radians.
  18700. */
  18701. minInitialRotation: number;
  18702. /**
  18703. * Gets or sets the maximal initial rotation in radians.
  18704. */
  18705. maxInitialRotation: number;
  18706. /**
  18707. * The particle emitter type defines the emitter used by the particle system.
  18708. * It can be for example box, sphere, or cone...
  18709. */
  18710. particleEmitterType: Nullable<IParticleEmitterType>;
  18711. /**
  18712. * Defines the delay in milliseconds before starting the system (0 by default)
  18713. */
  18714. startDelay: number;
  18715. /**
  18716. * 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
  18717. */
  18718. preWarmCycles: number;
  18719. /**
  18720. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18721. */
  18722. preWarmStepOffset: number;
  18723. /**
  18724. * 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)
  18725. */
  18726. spriteCellChangeSpeed: number;
  18727. /**
  18728. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18729. */
  18730. startSpriteCellID: number;
  18731. /**
  18732. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18733. */
  18734. endSpriteCellID: number;
  18735. /**
  18736. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18737. */
  18738. spriteCellWidth: number;
  18739. /**
  18740. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18741. */
  18742. spriteCellHeight: number;
  18743. /**
  18744. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18745. */
  18746. spriteRandomStartCell: boolean;
  18747. /**
  18748. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18749. */
  18750. isAnimationSheetEnabled: boolean;
  18751. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18752. translationPivot: Vector2;
  18753. /**
  18754. * Gets or sets a texture used to add random noise to particle positions
  18755. */
  18756. noiseTexture: Nullable<BaseTexture>;
  18757. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18758. noiseStrength: Vector3;
  18759. /**
  18760. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18761. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18762. */
  18763. billboardMode: number;
  18764. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18765. limitVelocityDamping: number;
  18766. /**
  18767. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18768. */
  18769. beginAnimationOnStart: boolean;
  18770. /**
  18771. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18772. */
  18773. beginAnimationFrom: number;
  18774. /**
  18775. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18776. */
  18777. beginAnimationTo: number;
  18778. /**
  18779. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18780. */
  18781. beginAnimationLoop: boolean;
  18782. /**
  18783. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18784. */
  18785. disposeOnStop: boolean;
  18786. /**
  18787. * Gets the maximum number of particles active at the same time.
  18788. * @returns The max number of active particles.
  18789. */
  18790. getCapacity(): number;
  18791. /**
  18792. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18793. * @returns True if it has been started, otherwise false.
  18794. */
  18795. isStarted(): boolean;
  18796. /**
  18797. * Animates the particle system for this frame.
  18798. */
  18799. animate(): void;
  18800. /**
  18801. * Renders the particle system in its current state.
  18802. * @returns the current number of particles
  18803. */
  18804. render(): number;
  18805. /**
  18806. * Dispose the particle system and frees its associated resources.
  18807. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18808. */
  18809. dispose(disposeTexture?: boolean): void;
  18810. /**
  18811. * Clones the particle system.
  18812. * @param name The name of the cloned object
  18813. * @param newEmitter The new emitter to use
  18814. * @returns the cloned particle system
  18815. */
  18816. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18817. /**
  18818. * Serializes the particle system to a JSON object.
  18819. * @returns the JSON object
  18820. */
  18821. serialize(): any;
  18822. /**
  18823. * Rebuild the particle system
  18824. */
  18825. rebuild(): void;
  18826. /**
  18827. * Starts the particle system and begins to emit
  18828. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18829. */
  18830. start(delay?: number): void;
  18831. /**
  18832. * Stops the particle system.
  18833. */
  18834. stop(): void;
  18835. /**
  18836. * Remove all active particles
  18837. */
  18838. reset(): void;
  18839. /**
  18840. * Is this system ready to be used/rendered
  18841. * @return true if the system is ready
  18842. */
  18843. isReady(): boolean;
  18844. /**
  18845. * Adds a new color gradient
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param color1 defines the color to affect to the specified gradient
  18848. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18849. * @returns the current particle system
  18850. */
  18851. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18852. /**
  18853. * Remove a specific color gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeColorGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Adds a new size gradient
  18860. * @param gradient defines the gradient to use (between 0 and 1)
  18861. * @param factor defines the size factor to affect to the specified gradient
  18862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18863. * @returns the current particle system
  18864. */
  18865. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18866. /**
  18867. * Remove a specific size gradient
  18868. * @param gradient defines the gradient to remove
  18869. * @returns the current particle system
  18870. */
  18871. removeSizeGradient(gradient: number): IParticleSystem;
  18872. /**
  18873. * Gets the current list of color gradients.
  18874. * You must use addColorGradient and removeColorGradient to udpate this list
  18875. * @returns the list of color gradients
  18876. */
  18877. getColorGradients(): Nullable<Array<ColorGradient>>;
  18878. /**
  18879. * Gets the current list of size gradients.
  18880. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18881. * @returns the list of size gradients
  18882. */
  18883. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Gets the current list of angular speed gradients.
  18886. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18887. * @returns the list of angular speed gradients
  18888. */
  18889. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18890. /**
  18891. * Adds a new angular speed gradient
  18892. * @param gradient defines the gradient to use (between 0 and 1)
  18893. * @param factor defines the angular speed to affect to the specified gradient
  18894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18895. * @returns the current particle system
  18896. */
  18897. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18898. /**
  18899. * Remove a specific angular speed gradient
  18900. * @param gradient defines the gradient to remove
  18901. * @returns the current particle system
  18902. */
  18903. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18904. /**
  18905. * Gets the current list of velocity gradients.
  18906. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18907. * @returns the list of velocity gradients
  18908. */
  18909. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18910. /**
  18911. * Adds a new velocity gradient
  18912. * @param gradient defines the gradient to use (between 0 and 1)
  18913. * @param factor defines the velocity to affect to the specified gradient
  18914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18915. * @returns the current particle system
  18916. */
  18917. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18918. /**
  18919. * Remove a specific velocity gradient
  18920. * @param gradient defines the gradient to remove
  18921. * @returns the current particle system
  18922. */
  18923. removeVelocityGradient(gradient: number): IParticleSystem;
  18924. /**
  18925. * Gets the current list of limit velocity gradients.
  18926. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18927. * @returns the list of limit velocity gradients
  18928. */
  18929. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18930. /**
  18931. * Adds a new limit velocity gradient
  18932. * @param gradient defines the gradient to use (between 0 and 1)
  18933. * @param factor defines the limit velocity to affect to the specified gradient
  18934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18935. * @returns the current particle system
  18936. */
  18937. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18938. /**
  18939. * Remove a specific limit velocity gradient
  18940. * @param gradient defines the gradient to remove
  18941. * @returns the current particle system
  18942. */
  18943. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18944. /**
  18945. * Adds a new drag gradient
  18946. * @param gradient defines the gradient to use (between 0 and 1)
  18947. * @param factor defines the drag to affect to the specified gradient
  18948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18949. * @returns the current particle system
  18950. */
  18951. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18952. /**
  18953. * Remove a specific drag gradient
  18954. * @param gradient defines the gradient to remove
  18955. * @returns the current particle system
  18956. */
  18957. removeDragGradient(gradient: number): IParticleSystem;
  18958. /**
  18959. * Gets the current list of drag gradients.
  18960. * You must use addDragGradient and removeDragGradient to udpate this list
  18961. * @returns the list of drag gradients
  18962. */
  18963. getDragGradients(): Nullable<Array<FactorGradient>>;
  18964. /**
  18965. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18966. * @param gradient defines the gradient to use (between 0 and 1)
  18967. * @param factor defines the emit rate to affect to the specified gradient
  18968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18969. * @returns the current particle system
  18970. */
  18971. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18972. /**
  18973. * Remove a specific emit rate gradient
  18974. * @param gradient defines the gradient to remove
  18975. * @returns the current particle system
  18976. */
  18977. removeEmitRateGradient(gradient: number): IParticleSystem;
  18978. /**
  18979. * Gets the current list of emit rate gradients.
  18980. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18981. * @returns the list of emit rate gradients
  18982. */
  18983. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18984. /**
  18985. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18986. * @param gradient defines the gradient to use (between 0 and 1)
  18987. * @param factor defines the start size to affect to the specified gradient
  18988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18989. * @returns the current particle system
  18990. */
  18991. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18992. /**
  18993. * Remove a specific start size gradient
  18994. * @param gradient defines the gradient to remove
  18995. * @returns the current particle system
  18996. */
  18997. removeStartSizeGradient(gradient: number): IParticleSystem;
  18998. /**
  18999. * Gets the current list of start size gradients.
  19000. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19001. * @returns the list of start size gradients
  19002. */
  19003. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19004. /**
  19005. * Adds a new life time gradient
  19006. * @param gradient defines the gradient to use (between 0 and 1)
  19007. * @param factor defines the life time factor to affect to the specified gradient
  19008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19009. * @returns the current particle system
  19010. */
  19011. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19012. /**
  19013. * Remove a specific life time gradient
  19014. * @param gradient defines the gradient to remove
  19015. * @returns the current particle system
  19016. */
  19017. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19018. /**
  19019. * Gets the current list of life time gradients.
  19020. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19021. * @returns the list of life time gradients
  19022. */
  19023. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19024. /**
  19025. * Gets the current list of color gradients.
  19026. * You must use addColorGradient and removeColorGradient to udpate this list
  19027. * @returns the list of color gradients
  19028. */
  19029. getColorGradients(): Nullable<Array<ColorGradient>>;
  19030. /**
  19031. * Adds a new ramp gradient used to remap particle colors
  19032. * @param gradient defines the gradient to use (between 0 and 1)
  19033. * @param color defines the color to affect to the specified gradient
  19034. * @returns the current particle system
  19035. */
  19036. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19037. /**
  19038. * Gets the current list of ramp gradients.
  19039. * You must use addRampGradient and removeRampGradient to udpate this list
  19040. * @returns the list of ramp gradients
  19041. */
  19042. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19043. /** Gets or sets a boolean indicating that ramp gradients must be used
  19044. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19045. */
  19046. useRampGradients: boolean;
  19047. /**
  19048. * Adds a new color remap gradient
  19049. * @param gradient defines the gradient to use (between 0 and 1)
  19050. * @param min defines the color remap minimal range
  19051. * @param max defines the color remap maximal range
  19052. * @returns the current particle system
  19053. */
  19054. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19055. /**
  19056. * Gets the current list of color remap gradients.
  19057. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19058. * @returns the list of color remap gradients
  19059. */
  19060. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19061. /**
  19062. * Adds a new alpha remap gradient
  19063. * @param gradient defines the gradient to use (between 0 and 1)
  19064. * @param min defines the alpha remap minimal range
  19065. * @param max defines the alpha remap maximal range
  19066. * @returns the current particle system
  19067. */
  19068. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19069. /**
  19070. * Gets the current list of alpha remap gradients.
  19071. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19072. * @returns the list of alpha remap gradients
  19073. */
  19074. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19075. /**
  19076. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19077. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19078. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19079. * @returns the emitter
  19080. */
  19081. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19082. /**
  19083. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19084. * @param radius The radius of the hemisphere to emit from
  19085. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19086. * @returns the emitter
  19087. */
  19088. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19089. /**
  19090. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19091. * @param radius The radius of the sphere to emit from
  19092. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19093. * @returns the emitter
  19094. */
  19095. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19096. /**
  19097. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19098. * @param radius The radius of the sphere to emit from
  19099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19101. * @returns the emitter
  19102. */
  19103. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19104. /**
  19105. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19106. * @param radius The radius of the emission cylinder
  19107. * @param height The height of the emission cylinder
  19108. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19109. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19110. * @returns the emitter
  19111. */
  19112. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19113. /**
  19114. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19115. * @param radius The radius of the cylinder to emit from
  19116. * @param height The height of the emission cylinder
  19117. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19118. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19119. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19120. * @returns the emitter
  19121. */
  19122. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19123. /**
  19124. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19125. * @param radius The radius of the cone to emit from
  19126. * @param angle The base angle of the cone
  19127. * @returns the emitter
  19128. */
  19129. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19130. /**
  19131. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19134. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19135. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19136. * @returns the emitter
  19137. */
  19138. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19139. /**
  19140. * Get hosting scene
  19141. * @returns the scene
  19142. */
  19143. getScene(): Scene;
  19144. }
  19145. }
  19146. declare module BABYLON {
  19147. /**
  19148. * Creates an instance based on a source mesh.
  19149. */
  19150. export class InstancedMesh extends AbstractMesh {
  19151. private _sourceMesh;
  19152. private _currentLOD;
  19153. /** @hidden */
  19154. _indexInSourceMeshInstanceArray: number;
  19155. constructor(name: string, source: Mesh);
  19156. /**
  19157. * Returns the string "InstancedMesh".
  19158. */
  19159. getClassName(): string;
  19160. /** Gets the list of lights affecting that mesh */
  19161. get lightSources(): Light[];
  19162. _resyncLightSources(): void;
  19163. _resyncLightSource(light: Light): void;
  19164. _removeLightSource(light: Light, dispose: boolean): void;
  19165. /**
  19166. * If the source mesh receives shadows
  19167. */
  19168. get receiveShadows(): boolean;
  19169. /**
  19170. * The material of the source mesh
  19171. */
  19172. get material(): Nullable<Material>;
  19173. /**
  19174. * Visibility of the source mesh
  19175. */
  19176. get visibility(): number;
  19177. /**
  19178. * Skeleton of the source mesh
  19179. */
  19180. get skeleton(): Nullable<Skeleton>;
  19181. /**
  19182. * Rendering ground id of the source mesh
  19183. */
  19184. get renderingGroupId(): number;
  19185. set renderingGroupId(value: number);
  19186. /**
  19187. * Returns the total number of vertices (integer).
  19188. */
  19189. getTotalVertices(): number;
  19190. /**
  19191. * Returns a positive integer : the total number of indices in this mesh geometry.
  19192. * @returns the numner of indices or zero if the mesh has no geometry.
  19193. */
  19194. getTotalIndices(): number;
  19195. /**
  19196. * The source mesh of the instance
  19197. */
  19198. get sourceMesh(): Mesh;
  19199. /**
  19200. * Is this node ready to be used/rendered
  19201. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19202. * @return {boolean} is it ready
  19203. */
  19204. isReady(completeCheck?: boolean): boolean;
  19205. /**
  19206. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19207. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19208. * @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.
  19209. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19210. */
  19211. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19212. /**
  19213. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19214. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19215. * The `data` are either a numeric array either a Float32Array.
  19216. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19217. * 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).
  19218. * Note that a new underlying VertexBuffer object is created each call.
  19219. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19220. *
  19221. * Possible `kind` values :
  19222. * - VertexBuffer.PositionKind
  19223. * - VertexBuffer.UVKind
  19224. * - VertexBuffer.UV2Kind
  19225. * - VertexBuffer.UV3Kind
  19226. * - VertexBuffer.UV4Kind
  19227. * - VertexBuffer.UV5Kind
  19228. * - VertexBuffer.UV6Kind
  19229. * - VertexBuffer.ColorKind
  19230. * - VertexBuffer.MatricesIndicesKind
  19231. * - VertexBuffer.MatricesIndicesExtraKind
  19232. * - VertexBuffer.MatricesWeightsKind
  19233. * - VertexBuffer.MatricesWeightsExtraKind
  19234. *
  19235. * Returns the Mesh.
  19236. */
  19237. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19238. /**
  19239. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19240. * If the mesh has no geometry, it is simply returned as it is.
  19241. * The `data` are either a numeric array either a Float32Array.
  19242. * No new underlying VertexBuffer object is created.
  19243. * 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.
  19244. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19245. *
  19246. * Possible `kind` values :
  19247. * - VertexBuffer.PositionKind
  19248. * - VertexBuffer.UVKind
  19249. * - VertexBuffer.UV2Kind
  19250. * - VertexBuffer.UV3Kind
  19251. * - VertexBuffer.UV4Kind
  19252. * - VertexBuffer.UV5Kind
  19253. * - VertexBuffer.UV6Kind
  19254. * - VertexBuffer.ColorKind
  19255. * - VertexBuffer.MatricesIndicesKind
  19256. * - VertexBuffer.MatricesIndicesExtraKind
  19257. * - VertexBuffer.MatricesWeightsKind
  19258. * - VertexBuffer.MatricesWeightsExtraKind
  19259. *
  19260. * Returns the Mesh.
  19261. */
  19262. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19263. /**
  19264. * Sets the mesh indices.
  19265. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19266. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19267. * This method creates a new index buffer each call.
  19268. * Returns the Mesh.
  19269. */
  19270. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19271. /**
  19272. * Boolean : True if the mesh owns the requested kind of data.
  19273. */
  19274. isVerticesDataPresent(kind: string): boolean;
  19275. /**
  19276. * Returns an array of indices (IndicesArray).
  19277. */
  19278. getIndices(): Nullable<IndicesArray>;
  19279. get _positions(): Nullable<Vector3[]>;
  19280. /**
  19281. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19282. * This means the mesh underlying bounding box and sphere are recomputed.
  19283. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19284. * @returns the current mesh
  19285. */
  19286. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19287. /** @hidden */
  19288. _preActivate(): InstancedMesh;
  19289. /** @hidden */
  19290. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19291. /** @hidden */
  19292. _postActivate(): void;
  19293. getWorldMatrix(): Matrix;
  19294. get isAnInstance(): boolean;
  19295. /**
  19296. * Returns the current associated LOD AbstractMesh.
  19297. */
  19298. getLOD(camera: Camera): AbstractMesh;
  19299. /** @hidden */
  19300. _syncSubMeshes(): InstancedMesh;
  19301. /** @hidden */
  19302. _generatePointsArray(): boolean;
  19303. /**
  19304. * Creates a new InstancedMesh from the current mesh.
  19305. * - name (string) : the cloned mesh name
  19306. * - newParent (optional Node) : the optional Node to parent the clone to.
  19307. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19308. *
  19309. * Returns the clone.
  19310. */
  19311. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19312. /**
  19313. * Disposes the InstancedMesh.
  19314. * Returns nothing.
  19315. */
  19316. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19317. }
  19318. interface Mesh {
  19319. /**
  19320. * Register a custom buffer that will be instanced
  19321. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19322. * @param kind defines the buffer kind
  19323. * @param stride defines the stride in floats
  19324. */
  19325. registerInstancedBuffer(kind: string, stride: number): void;
  19326. /** @hidden */
  19327. _userInstancedBuffersStorage: {
  19328. data: {
  19329. [key: string]: Float32Array;
  19330. };
  19331. sizes: {
  19332. [key: string]: number;
  19333. };
  19334. vertexBuffers: {
  19335. [key: string]: Nullable<VertexBuffer>;
  19336. };
  19337. strides: {
  19338. [key: string]: number;
  19339. };
  19340. };
  19341. }
  19342. interface AbstractMesh {
  19343. /**
  19344. * Object used to store instanced buffers defined by user
  19345. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19346. */
  19347. instancedBuffers: {
  19348. [key: string]: any;
  19349. };
  19350. }
  19351. }
  19352. declare module BABYLON {
  19353. /**
  19354. * Defines the options associated with the creation of a shader material.
  19355. */
  19356. export interface IShaderMaterialOptions {
  19357. /**
  19358. * Does the material work in alpha blend mode
  19359. */
  19360. needAlphaBlending: boolean;
  19361. /**
  19362. * Does the material work in alpha test mode
  19363. */
  19364. needAlphaTesting: boolean;
  19365. /**
  19366. * The list of attribute names used in the shader
  19367. */
  19368. attributes: string[];
  19369. /**
  19370. * The list of unifrom names used in the shader
  19371. */
  19372. uniforms: string[];
  19373. /**
  19374. * The list of UBO names used in the shader
  19375. */
  19376. uniformBuffers: string[];
  19377. /**
  19378. * The list of sampler names used in the shader
  19379. */
  19380. samplers: string[];
  19381. /**
  19382. * The list of defines used in the shader
  19383. */
  19384. defines: string[];
  19385. }
  19386. /**
  19387. * 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.
  19388. *
  19389. * This returned material effects how the mesh will look based on the code in the shaders.
  19390. *
  19391. * @see http://doc.babylonjs.com/how_to/shader_material
  19392. */
  19393. export class ShaderMaterial extends Material {
  19394. private _shaderPath;
  19395. private _options;
  19396. private _textures;
  19397. private _textureArrays;
  19398. private _floats;
  19399. private _ints;
  19400. private _floatsArrays;
  19401. private _colors3;
  19402. private _colors3Arrays;
  19403. private _colors4;
  19404. private _colors4Arrays;
  19405. private _vectors2;
  19406. private _vectors3;
  19407. private _vectors4;
  19408. private _matrices;
  19409. private _matrixArrays;
  19410. private _matrices3x3;
  19411. private _matrices2x2;
  19412. private _vectors2Arrays;
  19413. private _vectors3Arrays;
  19414. private _vectors4Arrays;
  19415. private _cachedWorldViewMatrix;
  19416. private _cachedWorldViewProjectionMatrix;
  19417. private _renderId;
  19418. private _multiview;
  19419. /**
  19420. * Instantiate a new shader material.
  19421. * 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.
  19422. * This returned material effects how the mesh will look based on the code in the shaders.
  19423. * @see http://doc.babylonjs.com/how_to/shader_material
  19424. * @param name Define the name of the material in the scene
  19425. * @param scene Define the scene the material belongs to
  19426. * @param shaderPath Defines the route to the shader code in one of three ways:
  19427. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19428. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19429. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19430. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19431. * @param options Define the options used to create the shader
  19432. */
  19433. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19434. /**
  19435. * Gets the shader path used to define the shader code
  19436. * It can be modified to trigger a new compilation
  19437. */
  19438. get shaderPath(): any;
  19439. /**
  19440. * Sets the shader path used to define the shader code
  19441. * It can be modified to trigger a new compilation
  19442. */
  19443. set shaderPath(shaderPath: any);
  19444. /**
  19445. * Gets the options used to compile the shader.
  19446. * They can be modified to trigger a new compilation
  19447. */
  19448. get options(): IShaderMaterialOptions;
  19449. /**
  19450. * Gets the current class name of the material e.g. "ShaderMaterial"
  19451. * Mainly use in serialization.
  19452. * @returns the class name
  19453. */
  19454. getClassName(): string;
  19455. /**
  19456. * Specifies if the material will require alpha blending
  19457. * @returns a boolean specifying if alpha blending is needed
  19458. */
  19459. needAlphaBlending(): boolean;
  19460. /**
  19461. * Specifies if this material should be rendered in alpha test mode
  19462. * @returns a boolean specifying if an alpha test is needed.
  19463. */
  19464. needAlphaTesting(): boolean;
  19465. private _checkUniform;
  19466. /**
  19467. * Set a texture in the shader.
  19468. * @param name Define the name of the uniform samplers as defined in the shader
  19469. * @param texture Define the texture to bind to this sampler
  19470. * @return the material itself allowing "fluent" like uniform updates
  19471. */
  19472. setTexture(name: string, texture: Texture): ShaderMaterial;
  19473. /**
  19474. * Set a texture array in the shader.
  19475. * @param name Define the name of the uniform sampler array as defined in the shader
  19476. * @param textures Define the list of textures to bind to this sampler
  19477. * @return the material itself allowing "fluent" like uniform updates
  19478. */
  19479. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19480. /**
  19481. * Set a float in the shader.
  19482. * @param name Define the name of the uniform as defined in the shader
  19483. * @param value Define the value to give to the uniform
  19484. * @return the material itself allowing "fluent" like uniform updates
  19485. */
  19486. setFloat(name: string, value: number): ShaderMaterial;
  19487. /**
  19488. * Set a int in the shader.
  19489. * @param name Define the name of the uniform as defined in the shader
  19490. * @param value Define the value to give to the uniform
  19491. * @return the material itself allowing "fluent" like uniform updates
  19492. */
  19493. setInt(name: string, value: number): ShaderMaterial;
  19494. /**
  19495. * Set an array of floats in the shader.
  19496. * @param name Define the name of the uniform as defined in the shader
  19497. * @param value Define the value to give to the uniform
  19498. * @return the material itself allowing "fluent" like uniform updates
  19499. */
  19500. setFloats(name: string, value: number[]): ShaderMaterial;
  19501. /**
  19502. * Set a vec3 in the shader from a Color3.
  19503. * @param name Define the name of the uniform as defined in the shader
  19504. * @param value Define the value to give to the uniform
  19505. * @return the material itself allowing "fluent" like uniform updates
  19506. */
  19507. setColor3(name: string, value: Color3): ShaderMaterial;
  19508. /**
  19509. * Set a vec3 array in the shader from a Color3 array.
  19510. * @param name Define the name of the uniform as defined in the shader
  19511. * @param value Define the value to give to the uniform
  19512. * @return the material itself allowing "fluent" like uniform updates
  19513. */
  19514. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19515. /**
  19516. * Set a vec4 in the shader from a Color4.
  19517. * @param name Define the name of the uniform as defined in the shader
  19518. * @param value Define the value to give to the uniform
  19519. * @return the material itself allowing "fluent" like uniform updates
  19520. */
  19521. setColor4(name: string, value: Color4): ShaderMaterial;
  19522. /**
  19523. * Set a vec4 array in the shader from a Color4 array.
  19524. * @param name Define the name of the uniform as defined in the shader
  19525. * @param value Define the value to give to the uniform
  19526. * @return the material itself allowing "fluent" like uniform updates
  19527. */
  19528. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19529. /**
  19530. * Set a vec2 in the shader from a Vector2.
  19531. * @param name Define the name of the uniform as defined in the shader
  19532. * @param value Define the value to give to the uniform
  19533. * @return the material itself allowing "fluent" like uniform updates
  19534. */
  19535. setVector2(name: string, value: Vector2): ShaderMaterial;
  19536. /**
  19537. * Set a vec3 in the shader from a Vector3.
  19538. * @param name Define the name of the uniform as defined in the shader
  19539. * @param value Define the value to give to the uniform
  19540. * @return the material itself allowing "fluent" like uniform updates
  19541. */
  19542. setVector3(name: string, value: Vector3): ShaderMaterial;
  19543. /**
  19544. * Set a vec4 in the shader from a Vector4.
  19545. * @param name Define the name of the uniform as defined in the shader
  19546. * @param value Define the value to give to the uniform
  19547. * @return the material itself allowing "fluent" like uniform updates
  19548. */
  19549. setVector4(name: string, value: Vector4): ShaderMaterial;
  19550. /**
  19551. * Set a mat4 in the shader from a Matrix.
  19552. * @param name Define the name of the uniform as defined in the shader
  19553. * @param value Define the value to give to the uniform
  19554. * @return the material itself allowing "fluent" like uniform updates
  19555. */
  19556. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19557. /**
  19558. * Set a float32Array in the shader from a matrix array.
  19559. * @param name Define the name of the uniform as defined in the shader
  19560. * @param value Define the value to give to the uniform
  19561. * @return the material itself allowing "fluent" like uniform updates
  19562. */
  19563. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19564. /**
  19565. * Set a mat3 in the shader from a Float32Array.
  19566. * @param name Define the name of the uniform as defined in the shader
  19567. * @param value Define the value to give to the uniform
  19568. * @return the material itself allowing "fluent" like uniform updates
  19569. */
  19570. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19571. /**
  19572. * Set a mat2 in the shader from a Float32Array.
  19573. * @param name Define the name of the uniform as defined in the shader
  19574. * @param value Define the value to give to the uniform
  19575. * @return the material itself allowing "fluent" like uniform updates
  19576. */
  19577. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19578. /**
  19579. * Set a vec2 array in the shader from a number array.
  19580. * @param name Define the name of the uniform as defined in the shader
  19581. * @param value Define the value to give to the uniform
  19582. * @return the material itself allowing "fluent" like uniform updates
  19583. */
  19584. setArray2(name: string, value: number[]): ShaderMaterial;
  19585. /**
  19586. * Set a vec3 array in the shader from a number array.
  19587. * @param name Define the name of the uniform as defined in the shader
  19588. * @param value Define the value to give to the uniform
  19589. * @return the material itself allowing "fluent" like uniform updates
  19590. */
  19591. setArray3(name: string, value: number[]): ShaderMaterial;
  19592. /**
  19593. * Set a vec4 array in the shader from a number array.
  19594. * @param name Define the name of the uniform as defined in the shader
  19595. * @param value Define the value to give to the uniform
  19596. * @return the material itself allowing "fluent" like uniform updates
  19597. */
  19598. setArray4(name: string, value: number[]): ShaderMaterial;
  19599. private _checkCache;
  19600. /**
  19601. * Specifies that the submesh is ready to be used
  19602. * @param mesh defines the mesh to check
  19603. * @param subMesh defines which submesh to check
  19604. * @param useInstances specifies that instances should be used
  19605. * @returns a boolean indicating that the submesh is ready or not
  19606. */
  19607. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19608. /**
  19609. * Checks if the material is ready to render the requested mesh
  19610. * @param mesh Define the mesh to render
  19611. * @param useInstances Define whether or not the material is used with instances
  19612. * @returns true if ready, otherwise false
  19613. */
  19614. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19615. /**
  19616. * Binds the world matrix to the material
  19617. * @param world defines the world transformation matrix
  19618. */
  19619. bindOnlyWorldMatrix(world: Matrix): void;
  19620. /**
  19621. * Binds the material to the mesh
  19622. * @param world defines the world transformation matrix
  19623. * @param mesh defines the mesh to bind the material to
  19624. */
  19625. bind(world: Matrix, mesh?: Mesh): void;
  19626. /**
  19627. * Gets the active textures from the material
  19628. * @returns an array of textures
  19629. */
  19630. getActiveTextures(): BaseTexture[];
  19631. /**
  19632. * Specifies if the material uses a texture
  19633. * @param texture defines the texture to check against the material
  19634. * @returns a boolean specifying if the material uses the texture
  19635. */
  19636. hasTexture(texture: BaseTexture): boolean;
  19637. /**
  19638. * Makes a duplicate of the material, and gives it a new name
  19639. * @param name defines the new name for the duplicated material
  19640. * @returns the cloned material
  19641. */
  19642. clone(name: string): ShaderMaterial;
  19643. /**
  19644. * Disposes the material
  19645. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19646. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19647. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19648. */
  19649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19650. /**
  19651. * Serializes this material in a JSON representation
  19652. * @returns the serialized material object
  19653. */
  19654. serialize(): any;
  19655. /**
  19656. * Creates a shader material from parsed shader material data
  19657. * @param source defines the JSON represnetation of the material
  19658. * @param scene defines the hosting scene
  19659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19660. * @returns a new material
  19661. */
  19662. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19663. }
  19664. }
  19665. declare module BABYLON {
  19666. /** @hidden */
  19667. export var colorPixelShader: {
  19668. name: string;
  19669. shader: string;
  19670. };
  19671. }
  19672. declare module BABYLON {
  19673. /** @hidden */
  19674. export var colorVertexShader: {
  19675. name: string;
  19676. shader: string;
  19677. };
  19678. }
  19679. declare module BABYLON {
  19680. /**
  19681. * Line mesh
  19682. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19683. */
  19684. export class LinesMesh extends Mesh {
  19685. /**
  19686. * If vertex color should be applied to the mesh
  19687. */
  19688. readonly useVertexColor?: boolean | undefined;
  19689. /**
  19690. * If vertex alpha should be applied to the mesh
  19691. */
  19692. readonly useVertexAlpha?: boolean | undefined;
  19693. /**
  19694. * Color of the line (Default: White)
  19695. */
  19696. color: Color3;
  19697. /**
  19698. * Alpha of the line (Default: 1)
  19699. */
  19700. alpha: number;
  19701. /**
  19702. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19703. * This margin is expressed in world space coordinates, so its value may vary.
  19704. * Default value is 0.1
  19705. */
  19706. intersectionThreshold: number;
  19707. private _colorShader;
  19708. private color4;
  19709. /**
  19710. * Creates a new LinesMesh
  19711. * @param name defines the name
  19712. * @param scene defines the hosting scene
  19713. * @param parent defines the parent mesh if any
  19714. * @param source defines the optional source LinesMesh used to clone data from
  19715. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19716. * When false, achieved by calling a clone(), also passing False.
  19717. * This will make creation of children, recursive.
  19718. * @param useVertexColor defines if this LinesMesh supports vertex color
  19719. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19720. */
  19721. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19722. /**
  19723. * If vertex color should be applied to the mesh
  19724. */
  19725. useVertexColor?: boolean | undefined,
  19726. /**
  19727. * If vertex alpha should be applied to the mesh
  19728. */
  19729. useVertexAlpha?: boolean | undefined);
  19730. private _addClipPlaneDefine;
  19731. private _removeClipPlaneDefine;
  19732. isReady(): boolean;
  19733. /**
  19734. * Returns the string "LineMesh"
  19735. */
  19736. getClassName(): string;
  19737. /**
  19738. * @hidden
  19739. */
  19740. get material(): Material;
  19741. /**
  19742. * @hidden
  19743. */
  19744. set material(value: Material);
  19745. /**
  19746. * @hidden
  19747. */
  19748. get checkCollisions(): boolean;
  19749. /** @hidden */
  19750. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19751. /** @hidden */
  19752. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19753. /**
  19754. * Disposes of the line mesh
  19755. * @param doNotRecurse If children should be disposed
  19756. */
  19757. dispose(doNotRecurse?: boolean): void;
  19758. /**
  19759. * Returns a new LineMesh object cloned from the current one.
  19760. */
  19761. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19762. /**
  19763. * Creates a new InstancedLinesMesh object from the mesh model.
  19764. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19765. * @param name defines the name of the new instance
  19766. * @returns a new InstancedLinesMesh
  19767. */
  19768. createInstance(name: string): InstancedLinesMesh;
  19769. }
  19770. /**
  19771. * Creates an instance based on a source LinesMesh
  19772. */
  19773. export class InstancedLinesMesh extends InstancedMesh {
  19774. /**
  19775. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19776. * This margin is expressed in world space coordinates, so its value may vary.
  19777. * Initilized with the intersectionThreshold value of the source LinesMesh
  19778. */
  19779. intersectionThreshold: number;
  19780. constructor(name: string, source: LinesMesh);
  19781. /**
  19782. * Returns the string "InstancedLinesMesh".
  19783. */
  19784. getClassName(): string;
  19785. }
  19786. }
  19787. declare module BABYLON {
  19788. /** @hidden */
  19789. export var linePixelShader: {
  19790. name: string;
  19791. shader: string;
  19792. };
  19793. }
  19794. declare module BABYLON {
  19795. /** @hidden */
  19796. export var lineVertexShader: {
  19797. name: string;
  19798. shader: string;
  19799. };
  19800. }
  19801. declare module BABYLON {
  19802. interface AbstractMesh {
  19803. /**
  19804. * Gets the edgesRenderer associated with the mesh
  19805. */
  19806. edgesRenderer: Nullable<EdgesRenderer>;
  19807. }
  19808. interface LinesMesh {
  19809. /**
  19810. * Enables the edge rendering mode on the mesh.
  19811. * This mode makes the mesh edges visible
  19812. * @param epsilon defines the maximal distance between two angles to detect a face
  19813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19814. * @returns the currentAbstractMesh
  19815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19816. */
  19817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19818. }
  19819. interface InstancedLinesMesh {
  19820. /**
  19821. * Enables the edge rendering mode on the mesh.
  19822. * This mode makes the mesh edges visible
  19823. * @param epsilon defines the maximal distance between two angles to detect a face
  19824. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19825. * @returns the current InstancedLinesMesh
  19826. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19827. */
  19828. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19829. }
  19830. /**
  19831. * Defines the minimum contract an Edges renderer should follow.
  19832. */
  19833. export interface IEdgesRenderer extends IDisposable {
  19834. /**
  19835. * Gets or sets a boolean indicating if the edgesRenderer is active
  19836. */
  19837. isEnabled: boolean;
  19838. /**
  19839. * Renders the edges of the attached mesh,
  19840. */
  19841. render(): void;
  19842. /**
  19843. * Checks wether or not the edges renderer is ready to render.
  19844. * @return true if ready, otherwise false.
  19845. */
  19846. isReady(): boolean;
  19847. }
  19848. /**
  19849. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19850. */
  19851. export class EdgesRenderer implements IEdgesRenderer {
  19852. /**
  19853. * Define the size of the edges with an orthographic camera
  19854. */
  19855. edgesWidthScalerForOrthographic: number;
  19856. /**
  19857. * Define the size of the edges with a perspective camera
  19858. */
  19859. edgesWidthScalerForPerspective: number;
  19860. protected _source: AbstractMesh;
  19861. protected _linesPositions: number[];
  19862. protected _linesNormals: number[];
  19863. protected _linesIndices: number[];
  19864. protected _epsilon: number;
  19865. protected _indicesCount: number;
  19866. protected _lineShader: ShaderMaterial;
  19867. protected _ib: DataBuffer;
  19868. protected _buffers: {
  19869. [key: string]: Nullable<VertexBuffer>;
  19870. };
  19871. protected _checkVerticesInsteadOfIndices: boolean;
  19872. private _meshRebuildObserver;
  19873. private _meshDisposeObserver;
  19874. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19875. isEnabled: boolean;
  19876. /**
  19877. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19878. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19879. * @param source Mesh used to create edges
  19880. * @param epsilon sum of angles in adjacency to check for edge
  19881. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19882. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19883. */
  19884. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19885. protected _prepareRessources(): void;
  19886. /** @hidden */
  19887. _rebuild(): void;
  19888. /**
  19889. * Releases the required resources for the edges renderer
  19890. */
  19891. dispose(): void;
  19892. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19893. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19894. /**
  19895. * Checks if the pair of p0 and p1 is en edge
  19896. * @param faceIndex
  19897. * @param edge
  19898. * @param faceNormals
  19899. * @param p0
  19900. * @param p1
  19901. * @private
  19902. */
  19903. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19904. /**
  19905. * push line into the position, normal and index buffer
  19906. * @protected
  19907. */
  19908. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19909. /**
  19910. * Generates lines edges from adjacencjes
  19911. * @private
  19912. */
  19913. _generateEdgesLines(): void;
  19914. /**
  19915. * Checks wether or not the edges renderer is ready to render.
  19916. * @return true if ready, otherwise false.
  19917. */
  19918. isReady(): boolean;
  19919. /**
  19920. * Renders the edges of the attached mesh,
  19921. */
  19922. render(): void;
  19923. }
  19924. /**
  19925. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19926. */
  19927. export class LineEdgesRenderer extends EdgesRenderer {
  19928. /**
  19929. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19930. * @param source LineMesh used to generate edges
  19931. * @param epsilon not important (specified angle for edge detection)
  19932. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19933. */
  19934. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19935. /**
  19936. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19937. */
  19938. _generateEdgesLines(): void;
  19939. }
  19940. }
  19941. declare module BABYLON {
  19942. /**
  19943. * This represents the object necessary to create a rendering group.
  19944. * This is exclusively used and created by the rendering manager.
  19945. * To modify the behavior, you use the available helpers in your scene or meshes.
  19946. * @hidden
  19947. */
  19948. export class RenderingGroup {
  19949. index: number;
  19950. private static _zeroVector;
  19951. private _scene;
  19952. private _opaqueSubMeshes;
  19953. private _transparentSubMeshes;
  19954. private _alphaTestSubMeshes;
  19955. private _depthOnlySubMeshes;
  19956. private _particleSystems;
  19957. private _spriteManagers;
  19958. private _opaqueSortCompareFn;
  19959. private _alphaTestSortCompareFn;
  19960. private _transparentSortCompareFn;
  19961. private _renderOpaque;
  19962. private _renderAlphaTest;
  19963. private _renderTransparent;
  19964. /** @hidden */
  19965. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19966. onBeforeTransparentRendering: () => void;
  19967. /**
  19968. * Set the opaque sort comparison function.
  19969. * If null the sub meshes will be render in the order they were created
  19970. */
  19971. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19972. /**
  19973. * Set the alpha test sort comparison function.
  19974. * If null the sub meshes will be render in the order they were created
  19975. */
  19976. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19977. /**
  19978. * Set the transparent sort comparison function.
  19979. * If null the sub meshes will be render in the order they were created
  19980. */
  19981. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19982. /**
  19983. * Creates a new rendering group.
  19984. * @param index The rendering group index
  19985. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19986. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19987. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19988. */
  19989. 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>);
  19990. /**
  19991. * Render all the sub meshes contained in the group.
  19992. * @param customRenderFunction Used to override the default render behaviour of the group.
  19993. * @returns true if rendered some submeshes.
  19994. */
  19995. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19996. /**
  19997. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19998. * @param subMeshes The submeshes to render
  19999. */
  20000. private renderOpaqueSorted;
  20001. /**
  20002. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20003. * @param subMeshes The submeshes to render
  20004. */
  20005. private renderAlphaTestSorted;
  20006. /**
  20007. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20008. * @param subMeshes The submeshes to render
  20009. */
  20010. private renderTransparentSorted;
  20011. /**
  20012. * Renders the submeshes in a specified order.
  20013. * @param subMeshes The submeshes to sort before render
  20014. * @param sortCompareFn The comparison function use to sort
  20015. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20016. * @param transparent Specifies to activate blending if true
  20017. */
  20018. private static renderSorted;
  20019. /**
  20020. * Renders the submeshes in the order they were dispatched (no sort applied).
  20021. * @param subMeshes The submeshes to render
  20022. */
  20023. private static renderUnsorted;
  20024. /**
  20025. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20026. * are rendered back to front if in the same alpha index.
  20027. *
  20028. * @param a The first submesh
  20029. * @param b The second submesh
  20030. * @returns The result of the comparison
  20031. */
  20032. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20033. /**
  20034. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20035. * are rendered back to front.
  20036. *
  20037. * @param a The first submesh
  20038. * @param b The second submesh
  20039. * @returns The result of the comparison
  20040. */
  20041. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20042. /**
  20043. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20044. * are rendered front to back (prevent overdraw).
  20045. *
  20046. * @param a The first submesh
  20047. * @param b The second submesh
  20048. * @returns The result of the comparison
  20049. */
  20050. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20051. /**
  20052. * Resets the different lists of submeshes to prepare a new frame.
  20053. */
  20054. prepare(): void;
  20055. dispose(): void;
  20056. /**
  20057. * Inserts the submesh in its correct queue depending on its material.
  20058. * @param subMesh The submesh to dispatch
  20059. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20060. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20061. */
  20062. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20063. dispatchSprites(spriteManager: ISpriteManager): void;
  20064. dispatchParticles(particleSystem: IParticleSystem): void;
  20065. private _renderParticles;
  20066. private _renderSprites;
  20067. }
  20068. }
  20069. declare module BABYLON {
  20070. /**
  20071. * Interface describing the different options available in the rendering manager
  20072. * regarding Auto Clear between groups.
  20073. */
  20074. export interface IRenderingManagerAutoClearSetup {
  20075. /**
  20076. * Defines whether or not autoclear is enable.
  20077. */
  20078. autoClear: boolean;
  20079. /**
  20080. * Defines whether or not to autoclear the depth buffer.
  20081. */
  20082. depth: boolean;
  20083. /**
  20084. * Defines whether or not to autoclear the stencil buffer.
  20085. */
  20086. stencil: boolean;
  20087. }
  20088. /**
  20089. * This class is used by the onRenderingGroupObservable
  20090. */
  20091. export class RenderingGroupInfo {
  20092. /**
  20093. * The Scene that being rendered
  20094. */
  20095. scene: Scene;
  20096. /**
  20097. * The camera currently used for the rendering pass
  20098. */
  20099. camera: Nullable<Camera>;
  20100. /**
  20101. * The ID of the renderingGroup being processed
  20102. */
  20103. renderingGroupId: number;
  20104. }
  20105. /**
  20106. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20107. * It is enable to manage the different groups as well as the different necessary sort functions.
  20108. * This should not be used directly aside of the few static configurations
  20109. */
  20110. export class RenderingManager {
  20111. /**
  20112. * The max id used for rendering groups (not included)
  20113. */
  20114. static MAX_RENDERINGGROUPS: number;
  20115. /**
  20116. * The min id used for rendering groups (included)
  20117. */
  20118. static MIN_RENDERINGGROUPS: number;
  20119. /**
  20120. * Used to globally prevent autoclearing scenes.
  20121. */
  20122. static AUTOCLEAR: boolean;
  20123. /**
  20124. * @hidden
  20125. */
  20126. _useSceneAutoClearSetup: boolean;
  20127. private _scene;
  20128. private _renderingGroups;
  20129. private _depthStencilBufferAlreadyCleaned;
  20130. private _autoClearDepthStencil;
  20131. private _customOpaqueSortCompareFn;
  20132. private _customAlphaTestSortCompareFn;
  20133. private _customTransparentSortCompareFn;
  20134. private _renderingGroupInfo;
  20135. /**
  20136. * Instantiates a new rendering group for a particular scene
  20137. * @param scene Defines the scene the groups belongs to
  20138. */
  20139. constructor(scene: Scene);
  20140. private _clearDepthStencilBuffer;
  20141. /**
  20142. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20143. * @hidden
  20144. */
  20145. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20146. /**
  20147. * Resets the different information of the group to prepare a new frame
  20148. * @hidden
  20149. */
  20150. reset(): void;
  20151. /**
  20152. * Dispose and release the group and its associated resources.
  20153. * @hidden
  20154. */
  20155. dispose(): void;
  20156. /**
  20157. * Clear the info related to rendering groups preventing retention points during dispose.
  20158. */
  20159. freeRenderingGroups(): void;
  20160. private _prepareRenderingGroup;
  20161. /**
  20162. * Add a sprite manager to the rendering manager in order to render it this frame.
  20163. * @param spriteManager Define the sprite manager to render
  20164. */
  20165. dispatchSprites(spriteManager: ISpriteManager): void;
  20166. /**
  20167. * Add a particle system to the rendering manager in order to render it this frame.
  20168. * @param particleSystem Define the particle system to render
  20169. */
  20170. dispatchParticles(particleSystem: IParticleSystem): void;
  20171. /**
  20172. * Add a submesh to the manager in order to render it this frame
  20173. * @param subMesh The submesh to dispatch
  20174. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20175. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20176. */
  20177. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20178. /**
  20179. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20180. * This allowed control for front to back rendering or reversly depending of the special needs.
  20181. *
  20182. * @param renderingGroupId The rendering group id corresponding to its index
  20183. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20184. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20185. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20186. */
  20187. 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;
  20188. /**
  20189. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20190. *
  20191. * @param renderingGroupId The rendering group id corresponding to its index
  20192. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20193. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20194. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20195. */
  20196. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20197. /**
  20198. * Gets the current auto clear configuration for one rendering group of the rendering
  20199. * manager.
  20200. * @param index the rendering group index to get the information for
  20201. * @returns The auto clear setup for the requested rendering group
  20202. */
  20203. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20204. }
  20205. }
  20206. declare module BABYLON {
  20207. /**
  20208. * This Helps creating a texture that will be created from a camera in your scene.
  20209. * It is basically a dynamic texture that could be used to create special effects for instance.
  20210. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20211. */
  20212. export class RenderTargetTexture extends Texture {
  20213. isCube: boolean;
  20214. /**
  20215. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20216. */
  20217. static readonly REFRESHRATE_RENDER_ONCE: number;
  20218. /**
  20219. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20220. */
  20221. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20222. /**
  20223. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20224. * the central point of your effect and can save a lot of performances.
  20225. */
  20226. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20227. /**
  20228. * Use this predicate to dynamically define the list of mesh you want to render.
  20229. * If set, the renderList property will be overwritten.
  20230. */
  20231. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20232. private _renderList;
  20233. /**
  20234. * Use this list to define the list of mesh you want to render.
  20235. */
  20236. get renderList(): Nullable<Array<AbstractMesh>>;
  20237. set renderList(value: Nullable<Array<AbstractMesh>>);
  20238. private _hookArray;
  20239. /**
  20240. * Define if particles should be rendered in your texture.
  20241. */
  20242. renderParticles: boolean;
  20243. /**
  20244. * Define if sprites should be rendered in your texture.
  20245. */
  20246. renderSprites: boolean;
  20247. /**
  20248. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20249. */
  20250. coordinatesMode: number;
  20251. /**
  20252. * Define the camera used to render the texture.
  20253. */
  20254. activeCamera: Nullable<Camera>;
  20255. /**
  20256. * Override the render function of the texture with your own one.
  20257. */
  20258. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20259. /**
  20260. * Define if camera post processes should be use while rendering the texture.
  20261. */
  20262. useCameraPostProcesses: boolean;
  20263. /**
  20264. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20265. */
  20266. ignoreCameraViewport: boolean;
  20267. private _postProcessManager;
  20268. private _postProcesses;
  20269. private _resizeObserver;
  20270. /**
  20271. * An event triggered when the texture is unbind.
  20272. */
  20273. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20274. /**
  20275. * An event triggered when the texture is unbind.
  20276. */
  20277. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20278. private _onAfterUnbindObserver;
  20279. /**
  20280. * Set a after unbind callback in the texture.
  20281. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20282. */
  20283. set onAfterUnbind(callback: () => void);
  20284. /**
  20285. * An event triggered before rendering the texture
  20286. */
  20287. onBeforeRenderObservable: Observable<number>;
  20288. private _onBeforeRenderObserver;
  20289. /**
  20290. * Set a before render callback in the texture.
  20291. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20292. */
  20293. set onBeforeRender(callback: (faceIndex: number) => void);
  20294. /**
  20295. * An event triggered after rendering the texture
  20296. */
  20297. onAfterRenderObservable: Observable<number>;
  20298. private _onAfterRenderObserver;
  20299. /**
  20300. * Set a after render callback in the texture.
  20301. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20302. */
  20303. set onAfterRender(callback: (faceIndex: number) => void);
  20304. /**
  20305. * An event triggered after the texture clear
  20306. */
  20307. onClearObservable: Observable<Engine>;
  20308. private _onClearObserver;
  20309. /**
  20310. * Set a clear callback in the texture.
  20311. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20312. */
  20313. set onClear(callback: (Engine: Engine) => void);
  20314. /**
  20315. * An event triggered when the texture is resized.
  20316. */
  20317. onResizeObservable: Observable<RenderTargetTexture>;
  20318. /**
  20319. * Define the clear color of the Render Target if it should be different from the scene.
  20320. */
  20321. clearColor: Color4;
  20322. protected _size: number | {
  20323. width: number;
  20324. height: number;
  20325. };
  20326. protected _initialSizeParameter: number | {
  20327. width: number;
  20328. height: number;
  20329. } | {
  20330. ratio: number;
  20331. };
  20332. protected _sizeRatio: Nullable<number>;
  20333. /** @hidden */
  20334. _generateMipMaps: boolean;
  20335. protected _renderingManager: RenderingManager;
  20336. /** @hidden */
  20337. _waitingRenderList: string[];
  20338. protected _doNotChangeAspectRatio: boolean;
  20339. protected _currentRefreshId: number;
  20340. protected _refreshRate: number;
  20341. protected _textureMatrix: Matrix;
  20342. protected _samples: number;
  20343. protected _renderTargetOptions: RenderTargetCreationOptions;
  20344. /**
  20345. * Gets render target creation options that were used.
  20346. */
  20347. get renderTargetOptions(): RenderTargetCreationOptions;
  20348. protected _engine: Engine;
  20349. protected _onRatioRescale(): void;
  20350. /**
  20351. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20352. * It must define where the camera used to render the texture is set
  20353. */
  20354. boundingBoxPosition: Vector3;
  20355. private _boundingBoxSize;
  20356. /**
  20357. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20358. * When defined, the cubemap will switch to local mode
  20359. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20360. * @example https://www.babylonjs-playground.com/#RNASML
  20361. */
  20362. set boundingBoxSize(value: Vector3);
  20363. get boundingBoxSize(): Vector3;
  20364. /**
  20365. * In case the RTT has been created with a depth texture, get the associated
  20366. * depth texture.
  20367. * Otherwise, return null.
  20368. */
  20369. depthStencilTexture: Nullable<InternalTexture>;
  20370. /**
  20371. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20372. * or used a shadow, depth texture...
  20373. * @param name The friendly name of the texture
  20374. * @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)
  20375. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20376. * @param generateMipMaps True if mip maps need to be generated after render.
  20377. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20378. * @param type The type of the buffer in the RTT (int, half float, float...)
  20379. * @param isCube True if a cube texture needs to be created
  20380. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20381. * @param generateDepthBuffer True to generate a depth buffer
  20382. * @param generateStencilBuffer True to generate a stencil buffer
  20383. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20384. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20385. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20386. */
  20387. constructor(name: string, size: number | {
  20388. width: number;
  20389. height: number;
  20390. } | {
  20391. ratio: number;
  20392. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20393. /**
  20394. * Creates a depth stencil texture.
  20395. * This is only available in WebGL 2 or with the depth texture extension available.
  20396. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20397. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20398. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20399. */
  20400. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20401. private _processSizeParameter;
  20402. /**
  20403. * Define the number of samples to use in case of MSAA.
  20404. * It defaults to one meaning no MSAA has been enabled.
  20405. */
  20406. get samples(): number;
  20407. set samples(value: number);
  20408. /**
  20409. * Resets the refresh counter of the texture and start bak from scratch.
  20410. * Could be useful to regenerate the texture if it is setup to render only once.
  20411. */
  20412. resetRefreshCounter(): void;
  20413. /**
  20414. * Define the refresh rate of the texture or the rendering frequency.
  20415. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20416. */
  20417. get refreshRate(): number;
  20418. set refreshRate(value: number);
  20419. /**
  20420. * Adds a post process to the render target rendering passes.
  20421. * @param postProcess define the post process to add
  20422. */
  20423. addPostProcess(postProcess: PostProcess): void;
  20424. /**
  20425. * Clear all the post processes attached to the render target
  20426. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20427. */
  20428. clearPostProcesses(dispose?: boolean): void;
  20429. /**
  20430. * Remove one of the post process from the list of attached post processes to the texture
  20431. * @param postProcess define the post process to remove from the list
  20432. */
  20433. removePostProcess(postProcess: PostProcess): void;
  20434. /** @hidden */
  20435. _shouldRender(): boolean;
  20436. /**
  20437. * Gets the actual render size of the texture.
  20438. * @returns the width of the render size
  20439. */
  20440. getRenderSize(): number;
  20441. /**
  20442. * Gets the actual render width of the texture.
  20443. * @returns the width of the render size
  20444. */
  20445. getRenderWidth(): number;
  20446. /**
  20447. * Gets the actual render height of the texture.
  20448. * @returns the height of the render size
  20449. */
  20450. getRenderHeight(): number;
  20451. /**
  20452. * Get if the texture can be rescaled or not.
  20453. */
  20454. get canRescale(): boolean;
  20455. /**
  20456. * Resize the texture using a ratio.
  20457. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20458. */
  20459. scale(ratio: number): void;
  20460. /**
  20461. * Get the texture reflection matrix used to rotate/transform the reflection.
  20462. * @returns the reflection matrix
  20463. */
  20464. getReflectionTextureMatrix(): Matrix;
  20465. /**
  20466. * Resize the texture to a new desired size.
  20467. * Be carrefull as it will recreate all the data in the new texture.
  20468. * @param size Define the new size. It can be:
  20469. * - a number for squared texture,
  20470. * - an object containing { width: number, height: number }
  20471. * - or an object containing a ratio { ratio: number }
  20472. */
  20473. resize(size: number | {
  20474. width: number;
  20475. height: number;
  20476. } | {
  20477. ratio: number;
  20478. }): void;
  20479. /**
  20480. * Renders all the objects from the render list into the texture.
  20481. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20482. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20483. */
  20484. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20485. private _bestReflectionRenderTargetDimension;
  20486. /**
  20487. * @hidden
  20488. * @param faceIndex face index to bind to if this is a cubetexture
  20489. */
  20490. _bindFrameBuffer(faceIndex?: number): void;
  20491. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20492. private renderToTarget;
  20493. /**
  20494. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20495. * This allowed control for front to back rendering or reversly depending of the special needs.
  20496. *
  20497. * @param renderingGroupId The rendering group id corresponding to its index
  20498. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20499. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20500. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20501. */
  20502. 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;
  20503. /**
  20504. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20505. *
  20506. * @param renderingGroupId The rendering group id corresponding to its index
  20507. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20508. */
  20509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20510. /**
  20511. * Clones the texture.
  20512. * @returns the cloned texture
  20513. */
  20514. clone(): RenderTargetTexture;
  20515. /**
  20516. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20517. * @returns The JSON representation of the texture
  20518. */
  20519. serialize(): any;
  20520. /**
  20521. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20522. */
  20523. disposeFramebufferObjects(): void;
  20524. /**
  20525. * Dispose the texture and release its associated resources.
  20526. */
  20527. dispose(): void;
  20528. /** @hidden */
  20529. _rebuild(): void;
  20530. /**
  20531. * Clear the info related to rendering groups preventing retention point in material dispose.
  20532. */
  20533. freeRenderingGroups(): void;
  20534. /**
  20535. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20536. * @returns the view count
  20537. */
  20538. getViewCount(): number;
  20539. }
  20540. }
  20541. declare module BABYLON {
  20542. /**
  20543. * Options for compiling materials.
  20544. */
  20545. export interface IMaterialCompilationOptions {
  20546. /**
  20547. * Defines whether clip planes are enabled.
  20548. */
  20549. clipPlane: boolean;
  20550. /**
  20551. * Defines whether instances are enabled.
  20552. */
  20553. useInstances: boolean;
  20554. }
  20555. /**
  20556. * Base class for the main features of a material in Babylon.js
  20557. */
  20558. export class Material implements IAnimatable {
  20559. /**
  20560. * Returns the triangle fill mode
  20561. */
  20562. static readonly TriangleFillMode: number;
  20563. /**
  20564. * Returns the wireframe mode
  20565. */
  20566. static readonly WireFrameFillMode: number;
  20567. /**
  20568. * Returns the point fill mode
  20569. */
  20570. static readonly PointFillMode: number;
  20571. /**
  20572. * Returns the point list draw mode
  20573. */
  20574. static readonly PointListDrawMode: number;
  20575. /**
  20576. * Returns the line list draw mode
  20577. */
  20578. static readonly LineListDrawMode: number;
  20579. /**
  20580. * Returns the line loop draw mode
  20581. */
  20582. static readonly LineLoopDrawMode: number;
  20583. /**
  20584. * Returns the line strip draw mode
  20585. */
  20586. static readonly LineStripDrawMode: number;
  20587. /**
  20588. * Returns the triangle strip draw mode
  20589. */
  20590. static readonly TriangleStripDrawMode: number;
  20591. /**
  20592. * Returns the triangle fan draw mode
  20593. */
  20594. static readonly TriangleFanDrawMode: number;
  20595. /**
  20596. * Stores the clock-wise side orientation
  20597. */
  20598. static readonly ClockWiseSideOrientation: number;
  20599. /**
  20600. * Stores the counter clock-wise side orientation
  20601. */
  20602. static readonly CounterClockWiseSideOrientation: number;
  20603. /**
  20604. * The dirty texture flag value
  20605. */
  20606. static readonly TextureDirtyFlag: number;
  20607. /**
  20608. * The dirty light flag value
  20609. */
  20610. static readonly LightDirtyFlag: number;
  20611. /**
  20612. * The dirty fresnel flag value
  20613. */
  20614. static readonly FresnelDirtyFlag: number;
  20615. /**
  20616. * The dirty attribute flag value
  20617. */
  20618. static readonly AttributesDirtyFlag: number;
  20619. /**
  20620. * The dirty misc flag value
  20621. */
  20622. static readonly MiscDirtyFlag: number;
  20623. /**
  20624. * The all dirty flag value
  20625. */
  20626. static readonly AllDirtyFlag: number;
  20627. /**
  20628. * The ID of the material
  20629. */
  20630. id: string;
  20631. /**
  20632. * Gets or sets the unique id of the material
  20633. */
  20634. uniqueId: number;
  20635. /**
  20636. * The name of the material
  20637. */
  20638. name: string;
  20639. /**
  20640. * Gets or sets user defined metadata
  20641. */
  20642. metadata: any;
  20643. /**
  20644. * For internal use only. Please do not use.
  20645. */
  20646. reservedDataStore: any;
  20647. /**
  20648. * Specifies if the ready state should be checked on each call
  20649. */
  20650. checkReadyOnEveryCall: boolean;
  20651. /**
  20652. * Specifies if the ready state should be checked once
  20653. */
  20654. checkReadyOnlyOnce: boolean;
  20655. /**
  20656. * The state of the material
  20657. */
  20658. state: string;
  20659. /**
  20660. * The alpha value of the material
  20661. */
  20662. protected _alpha: number;
  20663. /**
  20664. * List of inspectable custom properties (used by the Inspector)
  20665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20666. */
  20667. inspectableCustomProperties: IInspectable[];
  20668. /**
  20669. * Sets the alpha value of the material
  20670. */
  20671. set alpha(value: number);
  20672. /**
  20673. * Gets the alpha value of the material
  20674. */
  20675. get alpha(): number;
  20676. /**
  20677. * Specifies if back face culling is enabled
  20678. */
  20679. protected _backFaceCulling: boolean;
  20680. /**
  20681. * Sets the back-face culling state
  20682. */
  20683. set backFaceCulling(value: boolean);
  20684. /**
  20685. * Gets the back-face culling state
  20686. */
  20687. get backFaceCulling(): boolean;
  20688. /**
  20689. * Stores the value for side orientation
  20690. */
  20691. sideOrientation: number;
  20692. /**
  20693. * Callback triggered when the material is compiled
  20694. */
  20695. onCompiled: Nullable<(effect: Effect) => void>;
  20696. /**
  20697. * Callback triggered when an error occurs
  20698. */
  20699. onError: Nullable<(effect: Effect, errors: string) => void>;
  20700. /**
  20701. * Callback triggered to get the render target textures
  20702. */
  20703. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20704. /**
  20705. * Gets a boolean indicating that current material needs to register RTT
  20706. */
  20707. get hasRenderTargetTextures(): boolean;
  20708. /**
  20709. * Specifies if the material should be serialized
  20710. */
  20711. doNotSerialize: boolean;
  20712. /**
  20713. * @hidden
  20714. */
  20715. _storeEffectOnSubMeshes: boolean;
  20716. /**
  20717. * Stores the animations for the material
  20718. */
  20719. animations: Nullable<Array<Animation>>;
  20720. /**
  20721. * An event triggered when the material is disposed
  20722. */
  20723. onDisposeObservable: Observable<Material>;
  20724. /**
  20725. * An observer which watches for dispose events
  20726. */
  20727. private _onDisposeObserver;
  20728. private _onUnBindObservable;
  20729. /**
  20730. * Called during a dispose event
  20731. */
  20732. set onDispose(callback: () => void);
  20733. private _onBindObservable;
  20734. /**
  20735. * An event triggered when the material is bound
  20736. */
  20737. get onBindObservable(): Observable<AbstractMesh>;
  20738. /**
  20739. * An observer which watches for bind events
  20740. */
  20741. private _onBindObserver;
  20742. /**
  20743. * Called during a bind event
  20744. */
  20745. set onBind(callback: (Mesh: AbstractMesh) => void);
  20746. /**
  20747. * An event triggered when the material is unbound
  20748. */
  20749. get onUnBindObservable(): Observable<Material>;
  20750. /**
  20751. * Stores the value of the alpha mode
  20752. */
  20753. private _alphaMode;
  20754. /**
  20755. * Sets the value of the alpha mode.
  20756. *
  20757. * | Value | Type | Description |
  20758. * | --- | --- | --- |
  20759. * | 0 | ALPHA_DISABLE | |
  20760. * | 1 | ALPHA_ADD | |
  20761. * | 2 | ALPHA_COMBINE | |
  20762. * | 3 | ALPHA_SUBTRACT | |
  20763. * | 4 | ALPHA_MULTIPLY | |
  20764. * | 5 | ALPHA_MAXIMIZED | |
  20765. * | 6 | ALPHA_ONEONE | |
  20766. * | 7 | ALPHA_PREMULTIPLIED | |
  20767. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20768. * | 9 | ALPHA_INTERPOLATE | |
  20769. * | 10 | ALPHA_SCREENMODE | |
  20770. *
  20771. */
  20772. set alphaMode(value: number);
  20773. /**
  20774. * Gets the value of the alpha mode
  20775. */
  20776. get alphaMode(): number;
  20777. /**
  20778. * Stores the state of the need depth pre-pass value
  20779. */
  20780. private _needDepthPrePass;
  20781. /**
  20782. * Sets the need depth pre-pass value
  20783. */
  20784. set needDepthPrePass(value: boolean);
  20785. /**
  20786. * Gets the depth pre-pass value
  20787. */
  20788. get needDepthPrePass(): boolean;
  20789. /**
  20790. * Specifies if depth writing should be disabled
  20791. */
  20792. disableDepthWrite: boolean;
  20793. /**
  20794. * Specifies if depth writing should be forced
  20795. */
  20796. forceDepthWrite: boolean;
  20797. /**
  20798. * Specifies the depth function that should be used. 0 means the default engine function
  20799. */
  20800. depthFunction: number;
  20801. /**
  20802. * Specifies if there should be a separate pass for culling
  20803. */
  20804. separateCullingPass: boolean;
  20805. /**
  20806. * Stores the state specifing if fog should be enabled
  20807. */
  20808. private _fogEnabled;
  20809. /**
  20810. * Sets the state for enabling fog
  20811. */
  20812. set fogEnabled(value: boolean);
  20813. /**
  20814. * Gets the value of the fog enabled state
  20815. */
  20816. get fogEnabled(): boolean;
  20817. /**
  20818. * Stores the size of points
  20819. */
  20820. pointSize: number;
  20821. /**
  20822. * Stores the z offset value
  20823. */
  20824. zOffset: number;
  20825. /**
  20826. * Gets a value specifying if wireframe mode is enabled
  20827. */
  20828. get wireframe(): boolean;
  20829. /**
  20830. * Sets the state of wireframe mode
  20831. */
  20832. set wireframe(value: boolean);
  20833. /**
  20834. * Gets the value specifying if point clouds are enabled
  20835. */
  20836. get pointsCloud(): boolean;
  20837. /**
  20838. * Sets the state of point cloud mode
  20839. */
  20840. set pointsCloud(value: boolean);
  20841. /**
  20842. * Gets the material fill mode
  20843. */
  20844. get fillMode(): number;
  20845. /**
  20846. * Sets the material fill mode
  20847. */
  20848. set fillMode(value: number);
  20849. /**
  20850. * @hidden
  20851. * Stores the effects for the material
  20852. */
  20853. _effect: Nullable<Effect>;
  20854. /**
  20855. * Specifies if uniform buffers should be used
  20856. */
  20857. private _useUBO;
  20858. /**
  20859. * Stores a reference to the scene
  20860. */
  20861. private _scene;
  20862. /**
  20863. * Stores the fill mode state
  20864. */
  20865. private _fillMode;
  20866. /**
  20867. * Specifies if the depth write state should be cached
  20868. */
  20869. private _cachedDepthWriteState;
  20870. /**
  20871. * Specifies if the depth function state should be cached
  20872. */
  20873. private _cachedDepthFunctionState;
  20874. /**
  20875. * Stores the uniform buffer
  20876. */
  20877. protected _uniformBuffer: UniformBuffer;
  20878. /** @hidden */
  20879. _indexInSceneMaterialArray: number;
  20880. /** @hidden */
  20881. meshMap: Nullable<{
  20882. [id: string]: AbstractMesh | undefined;
  20883. }>;
  20884. /**
  20885. * Creates a material instance
  20886. * @param name defines the name of the material
  20887. * @param scene defines the scene to reference
  20888. * @param doNotAdd specifies if the material should be added to the scene
  20889. */
  20890. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20891. /**
  20892. * Returns a string representation of the current material
  20893. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20894. * @returns a string with material information
  20895. */
  20896. toString(fullDetails?: boolean): string;
  20897. /**
  20898. * Gets the class name of the material
  20899. * @returns a string with the class name of the material
  20900. */
  20901. getClassName(): string;
  20902. /**
  20903. * Specifies if updates for the material been locked
  20904. */
  20905. get isFrozen(): boolean;
  20906. /**
  20907. * Locks updates for the material
  20908. */
  20909. freeze(): void;
  20910. /**
  20911. * Unlocks updates for the material
  20912. */
  20913. unfreeze(): void;
  20914. /**
  20915. * Specifies if the material is ready to be used
  20916. * @param mesh defines the mesh to check
  20917. * @param useInstances specifies if instances should be used
  20918. * @returns a boolean indicating if the material is ready to be used
  20919. */
  20920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20921. /**
  20922. * Specifies that the submesh is ready to be used
  20923. * @param mesh defines the mesh to check
  20924. * @param subMesh defines which submesh to check
  20925. * @param useInstances specifies that instances should be used
  20926. * @returns a boolean indicating that the submesh is ready or not
  20927. */
  20928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20929. /**
  20930. * Returns the material effect
  20931. * @returns the effect associated with the material
  20932. */
  20933. getEffect(): Nullable<Effect>;
  20934. /**
  20935. * Returns the current scene
  20936. * @returns a Scene
  20937. */
  20938. getScene(): Scene;
  20939. /**
  20940. * Specifies if the material will require alpha blending
  20941. * @returns a boolean specifying if alpha blending is needed
  20942. */
  20943. needAlphaBlending(): boolean;
  20944. /**
  20945. * Specifies if the mesh will require alpha blending
  20946. * @param mesh defines the mesh to check
  20947. * @returns a boolean specifying if alpha blending is needed for the mesh
  20948. */
  20949. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20950. /**
  20951. * Specifies if this material should be rendered in alpha test mode
  20952. * @returns a boolean specifying if an alpha test is needed.
  20953. */
  20954. needAlphaTesting(): boolean;
  20955. /**
  20956. * Gets the texture used for the alpha test
  20957. * @returns the texture to use for alpha testing
  20958. */
  20959. getAlphaTestTexture(): Nullable<BaseTexture>;
  20960. /**
  20961. * Marks the material to indicate that it needs to be re-calculated
  20962. */
  20963. markDirty(): void;
  20964. /** @hidden */
  20965. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20966. /**
  20967. * Binds the material to the mesh
  20968. * @param world defines the world transformation matrix
  20969. * @param mesh defines the mesh to bind the material to
  20970. */
  20971. bind(world: Matrix, mesh?: Mesh): void;
  20972. /**
  20973. * Binds the submesh to the material
  20974. * @param world defines the world transformation matrix
  20975. * @param mesh defines the mesh containing the submesh
  20976. * @param subMesh defines the submesh to bind the material to
  20977. */
  20978. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20979. /**
  20980. * Binds the world matrix to the material
  20981. * @param world defines the world transformation matrix
  20982. */
  20983. bindOnlyWorldMatrix(world: Matrix): void;
  20984. /**
  20985. * Binds the scene's uniform buffer to the effect.
  20986. * @param effect defines the effect to bind to the scene uniform buffer
  20987. * @param sceneUbo defines the uniform buffer storing scene data
  20988. */
  20989. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20990. /**
  20991. * Binds the view matrix to the effect
  20992. * @param effect defines the effect to bind the view matrix to
  20993. */
  20994. bindView(effect: Effect): void;
  20995. /**
  20996. * Binds the view projection matrix to the effect
  20997. * @param effect defines the effect to bind the view projection matrix to
  20998. */
  20999. bindViewProjection(effect: Effect): void;
  21000. /**
  21001. * Specifies if material alpha testing should be turned on for the mesh
  21002. * @param mesh defines the mesh to check
  21003. */
  21004. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21005. /**
  21006. * Processes to execute after binding the material to a mesh
  21007. * @param mesh defines the rendered mesh
  21008. */
  21009. protected _afterBind(mesh?: Mesh): void;
  21010. /**
  21011. * Unbinds the material from the mesh
  21012. */
  21013. unbind(): void;
  21014. /**
  21015. * Gets the active textures from the material
  21016. * @returns an array of textures
  21017. */
  21018. getActiveTextures(): BaseTexture[];
  21019. /**
  21020. * Specifies if the material uses a texture
  21021. * @param texture defines the texture to check against the material
  21022. * @returns a boolean specifying if the material uses the texture
  21023. */
  21024. hasTexture(texture: BaseTexture): boolean;
  21025. /**
  21026. * Makes a duplicate of the material, and gives it a new name
  21027. * @param name defines the new name for the duplicated material
  21028. * @returns the cloned material
  21029. */
  21030. clone(name: string): Nullable<Material>;
  21031. /**
  21032. * Gets the meshes bound to the material
  21033. * @returns an array of meshes bound to the material
  21034. */
  21035. getBindedMeshes(): AbstractMesh[];
  21036. /**
  21037. * Force shader compilation
  21038. * @param mesh defines the mesh associated with this material
  21039. * @param onCompiled defines a function to execute once the material is compiled
  21040. * @param options defines the options to configure the compilation
  21041. * @param onError defines a function to execute if the material fails compiling
  21042. */
  21043. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21044. /**
  21045. * Force shader compilation
  21046. * @param mesh defines the mesh that will use this material
  21047. * @param options defines additional options for compiling the shaders
  21048. * @returns a promise that resolves when the compilation completes
  21049. */
  21050. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21051. private static readonly _AllDirtyCallBack;
  21052. private static readonly _ImageProcessingDirtyCallBack;
  21053. private static readonly _TextureDirtyCallBack;
  21054. private static readonly _FresnelDirtyCallBack;
  21055. private static readonly _MiscDirtyCallBack;
  21056. private static readonly _LightsDirtyCallBack;
  21057. private static readonly _AttributeDirtyCallBack;
  21058. private static _FresnelAndMiscDirtyCallBack;
  21059. private static _TextureAndMiscDirtyCallBack;
  21060. private static readonly _DirtyCallbackArray;
  21061. private static readonly _RunDirtyCallBacks;
  21062. /**
  21063. * Marks a define in the material to indicate that it needs to be re-computed
  21064. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21065. */
  21066. markAsDirty(flag: number): void;
  21067. /**
  21068. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21069. * @param func defines a function which checks material defines against the submeshes
  21070. */
  21071. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21072. /**
  21073. * Indicates that we need to re-calculated for all submeshes
  21074. */
  21075. protected _markAllSubMeshesAsAllDirty(): void;
  21076. /**
  21077. * Indicates that image processing needs to be re-calculated for all submeshes
  21078. */
  21079. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21080. /**
  21081. * Indicates that textures need to be re-calculated for all submeshes
  21082. */
  21083. protected _markAllSubMeshesAsTexturesDirty(): void;
  21084. /**
  21085. * Indicates that fresnel needs to be re-calculated for all submeshes
  21086. */
  21087. protected _markAllSubMeshesAsFresnelDirty(): void;
  21088. /**
  21089. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21090. */
  21091. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21092. /**
  21093. * Indicates that lights need to be re-calculated for all submeshes
  21094. */
  21095. protected _markAllSubMeshesAsLightsDirty(): void;
  21096. /**
  21097. * Indicates that attributes need to be re-calculated for all submeshes
  21098. */
  21099. protected _markAllSubMeshesAsAttributesDirty(): void;
  21100. /**
  21101. * Indicates that misc needs to be re-calculated for all submeshes
  21102. */
  21103. protected _markAllSubMeshesAsMiscDirty(): void;
  21104. /**
  21105. * Indicates that textures and misc need to be re-calculated for all submeshes
  21106. */
  21107. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21108. /**
  21109. * Disposes the material
  21110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21111. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21112. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21113. */
  21114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21115. /** @hidden */
  21116. private releaseVertexArrayObject;
  21117. /**
  21118. * Serializes this material
  21119. * @returns the serialized material object
  21120. */
  21121. serialize(): any;
  21122. /**
  21123. * Creates a material from parsed material data
  21124. * @param parsedMaterial defines parsed material data
  21125. * @param scene defines the hosting scene
  21126. * @param rootUrl defines the root URL to use to load textures
  21127. * @returns a new material
  21128. */
  21129. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21130. }
  21131. }
  21132. declare module BABYLON {
  21133. /**
  21134. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21135. * separate meshes. This can be use to improve performances.
  21136. * @see http://doc.babylonjs.com/how_to/multi_materials
  21137. */
  21138. export class MultiMaterial extends Material {
  21139. private _subMaterials;
  21140. /**
  21141. * Gets or Sets the list of Materials used within the multi material.
  21142. * They need to be ordered according to the submeshes order in the associated mesh
  21143. */
  21144. get subMaterials(): Nullable<Material>[];
  21145. set subMaterials(value: Nullable<Material>[]);
  21146. /**
  21147. * Function used to align with Node.getChildren()
  21148. * @returns the list of Materials used within the multi material
  21149. */
  21150. getChildren(): Nullable<Material>[];
  21151. /**
  21152. * Instantiates a new Multi Material
  21153. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21154. * separate meshes. This can be use to improve performances.
  21155. * @see http://doc.babylonjs.com/how_to/multi_materials
  21156. * @param name Define the name in the scene
  21157. * @param scene Define the scene the material belongs to
  21158. */
  21159. constructor(name: string, scene: Scene);
  21160. private _hookArray;
  21161. /**
  21162. * Get one of the submaterial by its index in the submaterials array
  21163. * @param index The index to look the sub material at
  21164. * @returns The Material if the index has been defined
  21165. */
  21166. getSubMaterial(index: number): Nullable<Material>;
  21167. /**
  21168. * Get the list of active textures for the whole sub materials list.
  21169. * @returns All the textures that will be used during the rendering
  21170. */
  21171. getActiveTextures(): BaseTexture[];
  21172. /**
  21173. * Gets the current class name of the material e.g. "MultiMaterial"
  21174. * Mainly use in serialization.
  21175. * @returns the class name
  21176. */
  21177. getClassName(): string;
  21178. /**
  21179. * Checks if the material is ready to render the requested sub mesh
  21180. * @param mesh Define the mesh the submesh belongs to
  21181. * @param subMesh Define the sub mesh to look readyness for
  21182. * @param useInstances Define whether or not the material is used with instances
  21183. * @returns true if ready, otherwise false
  21184. */
  21185. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21186. /**
  21187. * Clones the current material and its related sub materials
  21188. * @param name Define the name of the newly cloned material
  21189. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21190. * @returns the cloned material
  21191. */
  21192. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21193. /**
  21194. * Serializes the materials into a JSON representation.
  21195. * @returns the JSON representation
  21196. */
  21197. serialize(): any;
  21198. /**
  21199. * Dispose the material and release its associated resources
  21200. * @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)
  21201. * @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)
  21202. * @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)
  21203. */
  21204. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21205. /**
  21206. * Creates a MultiMaterial from parsed MultiMaterial data.
  21207. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21208. * @param scene defines the hosting scene
  21209. * @returns a new MultiMaterial
  21210. */
  21211. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21212. }
  21213. }
  21214. declare module BABYLON {
  21215. /**
  21216. * Base class for submeshes
  21217. */
  21218. export class BaseSubMesh {
  21219. /** @hidden */
  21220. _materialDefines: Nullable<MaterialDefines>;
  21221. /** @hidden */
  21222. _materialEffect: Nullable<Effect>;
  21223. /**
  21224. * Gets material defines used by the effect associated to the sub mesh
  21225. */
  21226. get materialDefines(): Nullable<MaterialDefines>;
  21227. /**
  21228. * Sets material defines used by the effect associated to the sub mesh
  21229. */
  21230. set materialDefines(defines: Nullable<MaterialDefines>);
  21231. /**
  21232. * Gets associated effect
  21233. */
  21234. get effect(): Nullable<Effect>;
  21235. /**
  21236. * Sets associated effect (effect used to render this submesh)
  21237. * @param effect defines the effect to associate with
  21238. * @param defines defines the set of defines used to compile this effect
  21239. */
  21240. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21241. }
  21242. /**
  21243. * Defines a subdivision inside a mesh
  21244. */
  21245. export class SubMesh extends BaseSubMesh implements ICullable {
  21246. /** the material index to use */
  21247. materialIndex: number;
  21248. /** vertex index start */
  21249. verticesStart: number;
  21250. /** vertices count */
  21251. verticesCount: number;
  21252. /** index start */
  21253. indexStart: number;
  21254. /** indices count */
  21255. indexCount: number;
  21256. /** @hidden */
  21257. _linesIndexCount: number;
  21258. private _mesh;
  21259. private _renderingMesh;
  21260. private _boundingInfo;
  21261. private _linesIndexBuffer;
  21262. /** @hidden */
  21263. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21264. /** @hidden */
  21265. _trianglePlanes: Plane[];
  21266. /** @hidden */
  21267. _lastColliderTransformMatrix: Nullable<Matrix>;
  21268. /** @hidden */
  21269. _renderId: number;
  21270. /** @hidden */
  21271. _alphaIndex: number;
  21272. /** @hidden */
  21273. _distanceToCamera: number;
  21274. /** @hidden */
  21275. _id: number;
  21276. private _currentMaterial;
  21277. /**
  21278. * Add a new submesh to a mesh
  21279. * @param materialIndex defines the material index to use
  21280. * @param verticesStart defines vertex index start
  21281. * @param verticesCount defines vertices count
  21282. * @param indexStart defines index start
  21283. * @param indexCount defines indices count
  21284. * @param mesh defines the parent mesh
  21285. * @param renderingMesh defines an optional rendering mesh
  21286. * @param createBoundingBox defines if bounding box should be created for this submesh
  21287. * @returns the new submesh
  21288. */
  21289. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21290. /**
  21291. * Creates a new submesh
  21292. * @param materialIndex defines the material index to use
  21293. * @param verticesStart defines vertex index start
  21294. * @param verticesCount defines vertices count
  21295. * @param indexStart defines index start
  21296. * @param indexCount defines indices count
  21297. * @param mesh defines the parent mesh
  21298. * @param renderingMesh defines an optional rendering mesh
  21299. * @param createBoundingBox defines if bounding box should be created for this submesh
  21300. */
  21301. constructor(
  21302. /** the material index to use */
  21303. materialIndex: number,
  21304. /** vertex index start */
  21305. verticesStart: number,
  21306. /** vertices count */
  21307. verticesCount: number,
  21308. /** index start */
  21309. indexStart: number,
  21310. /** indices count */
  21311. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21312. /**
  21313. * Returns true if this submesh covers the entire parent mesh
  21314. * @ignorenaming
  21315. */
  21316. get IsGlobal(): boolean;
  21317. /**
  21318. * Returns the submesh BoudingInfo object
  21319. * @returns current bounding info (or mesh's one if the submesh is global)
  21320. */
  21321. getBoundingInfo(): BoundingInfo;
  21322. /**
  21323. * Sets the submesh BoundingInfo
  21324. * @param boundingInfo defines the new bounding info to use
  21325. * @returns the SubMesh
  21326. */
  21327. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21328. /**
  21329. * Returns the mesh of the current submesh
  21330. * @return the parent mesh
  21331. */
  21332. getMesh(): AbstractMesh;
  21333. /**
  21334. * Returns the rendering mesh of the submesh
  21335. * @returns the rendering mesh (could be different from parent mesh)
  21336. */
  21337. getRenderingMesh(): Mesh;
  21338. /**
  21339. * Returns the submesh material
  21340. * @returns null or the current material
  21341. */
  21342. getMaterial(): Nullable<Material>;
  21343. /**
  21344. * Sets a new updated BoundingInfo object to the submesh
  21345. * @param data defines an optional position array to use to determine the bounding info
  21346. * @returns the SubMesh
  21347. */
  21348. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21349. /** @hidden */
  21350. _checkCollision(collider: Collider): boolean;
  21351. /**
  21352. * Updates the submesh BoundingInfo
  21353. * @param world defines the world matrix to use to update the bounding info
  21354. * @returns the submesh
  21355. */
  21356. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21357. /**
  21358. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21359. * @param frustumPlanes defines the frustum planes
  21360. * @returns true if the submesh is intersecting with the frustum
  21361. */
  21362. isInFrustum(frustumPlanes: Plane[]): boolean;
  21363. /**
  21364. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21365. * @param frustumPlanes defines the frustum planes
  21366. * @returns true if the submesh is inside the frustum
  21367. */
  21368. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21369. /**
  21370. * Renders the submesh
  21371. * @param enableAlphaMode defines if alpha needs to be used
  21372. * @returns the submesh
  21373. */
  21374. render(enableAlphaMode: boolean): SubMesh;
  21375. /**
  21376. * @hidden
  21377. */
  21378. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21379. /**
  21380. * Checks if the submesh intersects with a ray
  21381. * @param ray defines the ray to test
  21382. * @returns true is the passed ray intersects the submesh bounding box
  21383. */
  21384. canIntersects(ray: Ray): boolean;
  21385. /**
  21386. * Intersects current submesh with a ray
  21387. * @param ray defines the ray to test
  21388. * @param positions defines mesh's positions array
  21389. * @param indices defines mesh's indices array
  21390. * @param fastCheck defines if only bounding info should be used
  21391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21392. * @returns intersection info or null if no intersection
  21393. */
  21394. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21395. /** @hidden */
  21396. private _intersectLines;
  21397. /** @hidden */
  21398. private _intersectUnIndexedLines;
  21399. /** @hidden */
  21400. private _intersectTriangles;
  21401. /** @hidden */
  21402. private _intersectUnIndexedTriangles;
  21403. /** @hidden */
  21404. _rebuild(): void;
  21405. /**
  21406. * Creates a new submesh from the passed mesh
  21407. * @param newMesh defines the new hosting mesh
  21408. * @param newRenderingMesh defines an optional rendering mesh
  21409. * @returns the new submesh
  21410. */
  21411. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21412. /**
  21413. * Release associated resources
  21414. */
  21415. dispose(): void;
  21416. /**
  21417. * Gets the class name
  21418. * @returns the string "SubMesh".
  21419. */
  21420. getClassName(): string;
  21421. /**
  21422. * Creates a new submesh from indices data
  21423. * @param materialIndex the index of the main mesh material
  21424. * @param startIndex the index where to start the copy in the mesh indices array
  21425. * @param indexCount the number of indices to copy then from the startIndex
  21426. * @param mesh the main mesh to create the submesh from
  21427. * @param renderingMesh the optional rendering mesh
  21428. * @returns a new submesh
  21429. */
  21430. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21431. }
  21432. }
  21433. declare module BABYLON {
  21434. /**
  21435. * Class used to represent data loading progression
  21436. */
  21437. export class SceneLoaderFlags {
  21438. private static _ForceFullSceneLoadingForIncremental;
  21439. private static _ShowLoadingScreen;
  21440. private static _CleanBoneMatrixWeights;
  21441. private static _loggingLevel;
  21442. /**
  21443. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21444. */
  21445. static get ForceFullSceneLoadingForIncremental(): boolean;
  21446. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21447. /**
  21448. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21449. */
  21450. static get ShowLoadingScreen(): boolean;
  21451. static set ShowLoadingScreen(value: boolean);
  21452. /**
  21453. * Defines the current logging level (while loading the scene)
  21454. * @ignorenaming
  21455. */
  21456. static get loggingLevel(): number;
  21457. static set loggingLevel(value: number);
  21458. /**
  21459. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21460. */
  21461. static get CleanBoneMatrixWeights(): boolean;
  21462. static set CleanBoneMatrixWeights(value: boolean);
  21463. }
  21464. }
  21465. declare module BABYLON {
  21466. /**
  21467. * Class used to store geometry data (vertex buffers + index buffer)
  21468. */
  21469. export class Geometry implements IGetSetVerticesData {
  21470. /**
  21471. * Gets or sets the ID of the geometry
  21472. */
  21473. id: string;
  21474. /**
  21475. * Gets or sets the unique ID of the geometry
  21476. */
  21477. uniqueId: number;
  21478. /**
  21479. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21480. */
  21481. delayLoadState: number;
  21482. /**
  21483. * Gets the file containing the data to load when running in delay load state
  21484. */
  21485. delayLoadingFile: Nullable<string>;
  21486. /**
  21487. * Callback called when the geometry is updated
  21488. */
  21489. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21490. private _scene;
  21491. private _engine;
  21492. private _meshes;
  21493. private _totalVertices;
  21494. /** @hidden */
  21495. _indices: IndicesArray;
  21496. /** @hidden */
  21497. _vertexBuffers: {
  21498. [key: string]: VertexBuffer;
  21499. };
  21500. private _isDisposed;
  21501. private _extend;
  21502. private _boundingBias;
  21503. /** @hidden */
  21504. _delayInfo: Array<string>;
  21505. private _indexBuffer;
  21506. private _indexBufferIsUpdatable;
  21507. /** @hidden */
  21508. _boundingInfo: Nullable<BoundingInfo>;
  21509. /** @hidden */
  21510. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21511. /** @hidden */
  21512. _softwareSkinningFrameId: number;
  21513. private _vertexArrayObjects;
  21514. private _updatable;
  21515. /** @hidden */
  21516. _positions: Nullable<Vector3[]>;
  21517. /**
  21518. * 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
  21519. */
  21520. get boundingBias(): Vector2;
  21521. /**
  21522. * 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
  21523. */
  21524. set boundingBias(value: Vector2);
  21525. /**
  21526. * Static function used to attach a new empty geometry to a mesh
  21527. * @param mesh defines the mesh to attach the geometry to
  21528. * @returns the new Geometry
  21529. */
  21530. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21531. /**
  21532. * Creates a new geometry
  21533. * @param id defines the unique ID
  21534. * @param scene defines the hosting scene
  21535. * @param vertexData defines the VertexData used to get geometry data
  21536. * @param updatable defines if geometry must be updatable (false by default)
  21537. * @param mesh defines the mesh that will be associated with the geometry
  21538. */
  21539. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21540. /**
  21541. * Gets the current extend of the geometry
  21542. */
  21543. get extend(): {
  21544. minimum: Vector3;
  21545. maximum: Vector3;
  21546. };
  21547. /**
  21548. * Gets the hosting scene
  21549. * @returns the hosting Scene
  21550. */
  21551. getScene(): Scene;
  21552. /**
  21553. * Gets the hosting engine
  21554. * @returns the hosting Engine
  21555. */
  21556. getEngine(): Engine;
  21557. /**
  21558. * Defines if the geometry is ready to use
  21559. * @returns true if the geometry is ready to be used
  21560. */
  21561. isReady(): boolean;
  21562. /**
  21563. * Gets a value indicating that the geometry should not be serialized
  21564. */
  21565. get doNotSerialize(): boolean;
  21566. /** @hidden */
  21567. _rebuild(): void;
  21568. /**
  21569. * Affects all geometry data in one call
  21570. * @param vertexData defines the geometry data
  21571. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21572. */
  21573. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21574. /**
  21575. * Set specific vertex data
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. * @param data defines the vertex data to use
  21578. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21579. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21580. */
  21581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21582. /**
  21583. * Removes a specific vertex data
  21584. * @param kind defines the data kind (Position, normal, etc...)
  21585. */
  21586. removeVerticesData(kind: string): void;
  21587. /**
  21588. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21589. * @param buffer defines the vertex buffer to use
  21590. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21591. */
  21592. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21593. /**
  21594. * Update a specific vertex buffer
  21595. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21596. * It will do nothing if the buffer is not updatable
  21597. * @param kind defines the data kind (Position, normal, etc...)
  21598. * @param data defines the data to use
  21599. * @param offset defines the offset in the target buffer where to store the data
  21600. * @param useBytes set to true if the offset is in bytes
  21601. */
  21602. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21603. /**
  21604. * Update a specific vertex buffer
  21605. * This function will create a new buffer if the current one is not updatable
  21606. * @param kind defines the data kind (Position, normal, etc...)
  21607. * @param data defines the data to use
  21608. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21609. */
  21610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21611. private _updateBoundingInfo;
  21612. /** @hidden */
  21613. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21614. /**
  21615. * Gets total number of vertices
  21616. * @returns the total number of vertices
  21617. */
  21618. getTotalVertices(): number;
  21619. /**
  21620. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21621. * @param kind defines the data kind (Position, normal, etc...)
  21622. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21623. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21624. * @returns a float array containing vertex data
  21625. */
  21626. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21627. /**
  21628. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21629. * @param kind defines the data kind (Position, normal, etc...)
  21630. * @returns true if the vertex buffer with the specified kind is updatable
  21631. */
  21632. isVertexBufferUpdatable(kind: string): boolean;
  21633. /**
  21634. * Gets a specific vertex buffer
  21635. * @param kind defines the data kind (Position, normal, etc...)
  21636. * @returns a VertexBuffer
  21637. */
  21638. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21639. /**
  21640. * Returns all vertex buffers
  21641. * @return an object holding all vertex buffers indexed by kind
  21642. */
  21643. getVertexBuffers(): Nullable<{
  21644. [key: string]: VertexBuffer;
  21645. }>;
  21646. /**
  21647. * Gets a boolean indicating if specific vertex buffer is present
  21648. * @param kind defines the data kind (Position, normal, etc...)
  21649. * @returns true if data is present
  21650. */
  21651. isVerticesDataPresent(kind: string): boolean;
  21652. /**
  21653. * Gets a list of all attached data kinds (Position, normal, etc...)
  21654. * @returns a list of string containing all kinds
  21655. */
  21656. getVerticesDataKinds(): string[];
  21657. /**
  21658. * Update index buffer
  21659. * @param indices defines the indices to store in the index buffer
  21660. * @param offset defines the offset in the target buffer where to store the data
  21661. * @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)
  21662. */
  21663. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21664. /**
  21665. * Creates a new index buffer
  21666. * @param indices defines the indices to store in the index buffer
  21667. * @param totalVertices defines the total number of vertices (could be null)
  21668. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21669. */
  21670. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21671. /**
  21672. * Return the total number of indices
  21673. * @returns the total number of indices
  21674. */
  21675. getTotalIndices(): number;
  21676. /**
  21677. * Gets the index buffer array
  21678. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21679. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21680. * @returns the index buffer array
  21681. */
  21682. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21683. /**
  21684. * Gets the index buffer
  21685. * @return the index buffer
  21686. */
  21687. getIndexBuffer(): Nullable<DataBuffer>;
  21688. /** @hidden */
  21689. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21690. /**
  21691. * Release the associated resources for a specific mesh
  21692. * @param mesh defines the source mesh
  21693. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21694. */
  21695. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21696. /**
  21697. * Apply current geometry to a given mesh
  21698. * @param mesh defines the mesh to apply geometry to
  21699. */
  21700. applyToMesh(mesh: Mesh): void;
  21701. private _updateExtend;
  21702. private _applyToMesh;
  21703. private notifyUpdate;
  21704. /**
  21705. * Load the geometry if it was flagged as delay loaded
  21706. * @param scene defines the hosting scene
  21707. * @param onLoaded defines a callback called when the geometry is loaded
  21708. */
  21709. load(scene: Scene, onLoaded?: () => void): void;
  21710. private _queueLoad;
  21711. /**
  21712. * Invert the geometry to move from a right handed system to a left handed one.
  21713. */
  21714. toLeftHanded(): void;
  21715. /** @hidden */
  21716. _resetPointsArrayCache(): void;
  21717. /** @hidden */
  21718. _generatePointsArray(): boolean;
  21719. /**
  21720. * Gets a value indicating if the geometry is disposed
  21721. * @returns true if the geometry was disposed
  21722. */
  21723. isDisposed(): boolean;
  21724. private _disposeVertexArrayObjects;
  21725. /**
  21726. * Free all associated resources
  21727. */
  21728. dispose(): void;
  21729. /**
  21730. * Clone the current geometry into a new geometry
  21731. * @param id defines the unique ID of the new geometry
  21732. * @returns a new geometry object
  21733. */
  21734. copy(id: string): Geometry;
  21735. /**
  21736. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21737. * @return a JSON representation of the current geometry data (without the vertices data)
  21738. */
  21739. serialize(): any;
  21740. private toNumberArray;
  21741. /**
  21742. * Serialize all vertices data into a JSON oject
  21743. * @returns a JSON representation of the current geometry data
  21744. */
  21745. serializeVerticeData(): any;
  21746. /**
  21747. * Extracts a clone of a mesh geometry
  21748. * @param mesh defines the source mesh
  21749. * @param id defines the unique ID of the new geometry object
  21750. * @returns the new geometry object
  21751. */
  21752. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21753. /**
  21754. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21755. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21756. * Be aware Math.random() could cause collisions, but:
  21757. * "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"
  21758. * @returns a string containing a new GUID
  21759. */
  21760. static RandomId(): string;
  21761. /** @hidden */
  21762. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21763. private static _CleanMatricesWeights;
  21764. /**
  21765. * Create a new geometry from persisted data (Using .babylon file format)
  21766. * @param parsedVertexData defines the persisted data
  21767. * @param scene defines the hosting scene
  21768. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21769. * @returns the new geometry object
  21770. */
  21771. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21772. }
  21773. }
  21774. declare module BABYLON {
  21775. /**
  21776. * Define an interface for all classes that will get and set the data on vertices
  21777. */
  21778. export interface IGetSetVerticesData {
  21779. /**
  21780. * Gets a boolean indicating if specific vertex data is present
  21781. * @param kind defines the vertex data kind to use
  21782. * @returns true is data kind is present
  21783. */
  21784. isVerticesDataPresent(kind: string): boolean;
  21785. /**
  21786. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21787. * @param kind defines the data kind (Position, normal, etc...)
  21788. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21789. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21790. * @returns a float array containing vertex data
  21791. */
  21792. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21793. /**
  21794. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21795. * @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.
  21796. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21797. * @returns the indices array or an empty array if the mesh has no geometry
  21798. */
  21799. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21800. /**
  21801. * Set specific vertex data
  21802. * @param kind defines the data kind (Position, normal, etc...)
  21803. * @param data defines the vertex data to use
  21804. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21805. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21806. */
  21807. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21808. /**
  21809. * Update a specific associated vertex buffer
  21810. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21811. * - VertexBuffer.PositionKind
  21812. * - VertexBuffer.UVKind
  21813. * - VertexBuffer.UV2Kind
  21814. * - VertexBuffer.UV3Kind
  21815. * - VertexBuffer.UV4Kind
  21816. * - VertexBuffer.UV5Kind
  21817. * - VertexBuffer.UV6Kind
  21818. * - VertexBuffer.ColorKind
  21819. * - VertexBuffer.MatricesIndicesKind
  21820. * - VertexBuffer.MatricesIndicesExtraKind
  21821. * - VertexBuffer.MatricesWeightsKind
  21822. * - VertexBuffer.MatricesWeightsExtraKind
  21823. * @param data defines the data source
  21824. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21825. * @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)
  21826. */
  21827. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21828. /**
  21829. * Creates a new index buffer
  21830. * @param indices defines the indices to store in the index buffer
  21831. * @param totalVertices defines the total number of vertices (could be null)
  21832. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21833. */
  21834. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21835. }
  21836. /**
  21837. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21838. */
  21839. export class VertexData {
  21840. /**
  21841. * Mesh side orientation : usually the external or front surface
  21842. */
  21843. static readonly FRONTSIDE: number;
  21844. /**
  21845. * Mesh side orientation : usually the internal or back surface
  21846. */
  21847. static readonly BACKSIDE: number;
  21848. /**
  21849. * Mesh side orientation : both internal and external or front and back surfaces
  21850. */
  21851. static readonly DOUBLESIDE: number;
  21852. /**
  21853. * Mesh side orientation : by default, `FRONTSIDE`
  21854. */
  21855. static readonly DEFAULTSIDE: number;
  21856. /**
  21857. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21858. */
  21859. positions: Nullable<FloatArray>;
  21860. /**
  21861. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21862. */
  21863. normals: Nullable<FloatArray>;
  21864. /**
  21865. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21866. */
  21867. tangents: Nullable<FloatArray>;
  21868. /**
  21869. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21870. */
  21871. uvs: Nullable<FloatArray>;
  21872. /**
  21873. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21874. */
  21875. uvs2: Nullable<FloatArray>;
  21876. /**
  21877. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21878. */
  21879. uvs3: Nullable<FloatArray>;
  21880. /**
  21881. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21882. */
  21883. uvs4: Nullable<FloatArray>;
  21884. /**
  21885. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21886. */
  21887. uvs5: Nullable<FloatArray>;
  21888. /**
  21889. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21890. */
  21891. uvs6: Nullable<FloatArray>;
  21892. /**
  21893. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21894. */
  21895. colors: Nullable<FloatArray>;
  21896. /**
  21897. * 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).
  21898. */
  21899. matricesIndices: Nullable<FloatArray>;
  21900. /**
  21901. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21902. */
  21903. matricesWeights: Nullable<FloatArray>;
  21904. /**
  21905. * An array extending the number of possible indices
  21906. */
  21907. matricesIndicesExtra: Nullable<FloatArray>;
  21908. /**
  21909. * An array extending the number of possible weights when the number of indices is extended
  21910. */
  21911. matricesWeightsExtra: Nullable<FloatArray>;
  21912. /**
  21913. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21914. */
  21915. indices: Nullable<IndicesArray>;
  21916. /**
  21917. * Uses the passed data array to set the set the values for the specified kind of data
  21918. * @param data a linear array of floating numbers
  21919. * @param kind the type of data that is being set, eg positions, colors etc
  21920. */
  21921. set(data: FloatArray, kind: string): void;
  21922. /**
  21923. * Associates the vertexData to the passed Mesh.
  21924. * Sets it as updatable or not (default `false`)
  21925. * @param mesh the mesh the vertexData is applied to
  21926. * @param updatable when used and having the value true allows new data to update the vertexData
  21927. * @returns the VertexData
  21928. */
  21929. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21930. /**
  21931. * Associates the vertexData to the passed Geometry.
  21932. * Sets it as updatable or not (default `false`)
  21933. * @param geometry the geometry the vertexData is applied to
  21934. * @param updatable when used and having the value true allows new data to update the vertexData
  21935. * @returns VertexData
  21936. */
  21937. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21938. /**
  21939. * Updates the associated mesh
  21940. * @param mesh the mesh to be updated
  21941. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21942. * @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
  21943. * @returns VertexData
  21944. */
  21945. updateMesh(mesh: Mesh): VertexData;
  21946. /**
  21947. * Updates the associated geometry
  21948. * @param geometry the geometry to be updated
  21949. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21950. * @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
  21951. * @returns VertexData.
  21952. */
  21953. updateGeometry(geometry: Geometry): VertexData;
  21954. private _applyTo;
  21955. private _update;
  21956. /**
  21957. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21958. * @param matrix the transforming matrix
  21959. * @returns the VertexData
  21960. */
  21961. transform(matrix: Matrix): VertexData;
  21962. /**
  21963. * Merges the passed VertexData into the current one
  21964. * @param other the VertexData to be merged into the current one
  21965. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21966. * @returns the modified VertexData
  21967. */
  21968. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21969. private _mergeElement;
  21970. private _validate;
  21971. /**
  21972. * Serializes the VertexData
  21973. * @returns a serialized object
  21974. */
  21975. serialize(): any;
  21976. /**
  21977. * Extracts the vertexData from a mesh
  21978. * @param mesh the mesh from which to extract the VertexData
  21979. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21980. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21981. * @returns the object VertexData associated to the passed mesh
  21982. */
  21983. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21984. /**
  21985. * Extracts the vertexData from the geometry
  21986. * @param geometry the geometry from which to extract the VertexData
  21987. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21988. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21989. * @returns the object VertexData associated to the passed mesh
  21990. */
  21991. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21992. private static _ExtractFrom;
  21993. /**
  21994. * Creates the VertexData for a Ribbon
  21995. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21996. * * pathArray array of paths, each of which an array of successive Vector3
  21997. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21998. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21999. * * 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
  22000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22001. * * 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)
  22002. * * 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)
  22003. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22004. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22005. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22006. * @returns the VertexData of the ribbon
  22007. */
  22008. static CreateRibbon(options: {
  22009. pathArray: Vector3[][];
  22010. closeArray?: boolean;
  22011. closePath?: boolean;
  22012. offset?: number;
  22013. sideOrientation?: number;
  22014. frontUVs?: Vector4;
  22015. backUVs?: Vector4;
  22016. invertUV?: boolean;
  22017. uvs?: Vector2[];
  22018. colors?: Color4[];
  22019. }): VertexData;
  22020. /**
  22021. * Creates the VertexData for a box
  22022. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22023. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22024. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22025. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22026. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22027. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22028. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22030. * * 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)
  22031. * * 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)
  22032. * @returns the VertexData of the box
  22033. */
  22034. static CreateBox(options: {
  22035. size?: number;
  22036. width?: number;
  22037. height?: number;
  22038. depth?: number;
  22039. faceUV?: Vector4[];
  22040. faceColors?: Color4[];
  22041. sideOrientation?: number;
  22042. frontUVs?: Vector4;
  22043. backUVs?: Vector4;
  22044. }): VertexData;
  22045. /**
  22046. * Creates the VertexData for a tiled box
  22047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22048. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22049. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22050. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22052. * @returns the VertexData of the box
  22053. */
  22054. static CreateTiledBox(options: {
  22055. pattern?: number;
  22056. width?: number;
  22057. height?: number;
  22058. depth?: number;
  22059. tileSize?: number;
  22060. tileWidth?: number;
  22061. tileHeight?: number;
  22062. alignHorizontal?: number;
  22063. alignVertical?: number;
  22064. faceUV?: Vector4[];
  22065. faceColors?: Color4[];
  22066. sideOrientation?: number;
  22067. }): VertexData;
  22068. /**
  22069. * Creates the VertexData for a tiled plane
  22070. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22071. * * pattern a limited pattern arrangement depending on the number
  22072. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22073. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22074. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22076. * * 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)
  22077. * * 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)
  22078. * @returns the VertexData of the tiled plane
  22079. */
  22080. static CreateTiledPlane(options: {
  22081. pattern?: number;
  22082. tileSize?: number;
  22083. tileWidth?: number;
  22084. tileHeight?: number;
  22085. size?: number;
  22086. width?: number;
  22087. height?: number;
  22088. alignHorizontal?: number;
  22089. alignVertical?: number;
  22090. sideOrientation?: number;
  22091. frontUVs?: Vector4;
  22092. backUVs?: Vector4;
  22093. }): VertexData;
  22094. /**
  22095. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22097. * * segments sets the number of horizontal strips optional, default 32
  22098. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22099. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22100. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22101. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22102. * * 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
  22103. * * 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
  22104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22105. * * 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)
  22106. * * 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)
  22107. * @returns the VertexData of the ellipsoid
  22108. */
  22109. static CreateSphere(options: {
  22110. segments?: number;
  22111. diameter?: number;
  22112. diameterX?: number;
  22113. diameterY?: number;
  22114. diameterZ?: number;
  22115. arc?: number;
  22116. slice?: number;
  22117. sideOrientation?: number;
  22118. frontUVs?: Vector4;
  22119. backUVs?: Vector4;
  22120. }): VertexData;
  22121. /**
  22122. * Creates the VertexData for a cylinder, cone or prism
  22123. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22124. * * height sets the height (y direction) of the cylinder, optional, default 2
  22125. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22126. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22127. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22128. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22129. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22130. * * 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
  22131. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22132. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22133. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22134. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22136. * * 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)
  22137. * * 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)
  22138. * @returns the VertexData of the cylinder, cone or prism
  22139. */
  22140. static CreateCylinder(options: {
  22141. height?: number;
  22142. diameterTop?: number;
  22143. diameterBottom?: number;
  22144. diameter?: number;
  22145. tessellation?: number;
  22146. subdivisions?: number;
  22147. arc?: number;
  22148. faceColors?: Color4[];
  22149. faceUV?: Vector4[];
  22150. hasRings?: boolean;
  22151. enclose?: boolean;
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. }): VertexData;
  22156. /**
  22157. * Creates the VertexData for a torus
  22158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22159. * * diameter the diameter of the torus, optional default 1
  22160. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22161. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22163. * * 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)
  22164. * * 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)
  22165. * @returns the VertexData of the torus
  22166. */
  22167. static CreateTorus(options: {
  22168. diameter?: number;
  22169. thickness?: number;
  22170. tessellation?: number;
  22171. sideOrientation?: number;
  22172. frontUVs?: Vector4;
  22173. backUVs?: Vector4;
  22174. }): VertexData;
  22175. /**
  22176. * Creates the VertexData of the LineSystem
  22177. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22178. * - lines an array of lines, each line being an array of successive Vector3
  22179. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22180. * @returns the VertexData of the LineSystem
  22181. */
  22182. static CreateLineSystem(options: {
  22183. lines: Vector3[][];
  22184. colors?: Nullable<Color4[][]>;
  22185. }): VertexData;
  22186. /**
  22187. * Create the VertexData for a DashedLines
  22188. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22189. * - points an array successive Vector3
  22190. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22191. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22192. * - dashNb the intended total number of dashes, optional, default 200
  22193. * @returns the VertexData for the DashedLines
  22194. */
  22195. static CreateDashedLines(options: {
  22196. points: Vector3[];
  22197. dashSize?: number;
  22198. gapSize?: number;
  22199. dashNb?: number;
  22200. }): VertexData;
  22201. /**
  22202. * Creates the VertexData for a Ground
  22203. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22204. * - width the width (x direction) of the ground, optional, default 1
  22205. * - height the height (z direction) of the ground, optional, default 1
  22206. * - subdivisions the number of subdivisions per side, optional, default 1
  22207. * @returns the VertexData of the Ground
  22208. */
  22209. static CreateGround(options: {
  22210. width?: number;
  22211. height?: number;
  22212. subdivisions?: number;
  22213. subdivisionsX?: number;
  22214. subdivisionsY?: number;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22218. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22219. * * xmin the ground minimum X coordinate, optional, default -1
  22220. * * zmin the ground minimum Z coordinate, optional, default -1
  22221. * * xmax the ground maximum X coordinate, optional, default 1
  22222. * * zmax the ground maximum Z coordinate, optional, default 1
  22223. * * 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}
  22224. * * 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}
  22225. * @returns the VertexData of the TiledGround
  22226. */
  22227. static CreateTiledGround(options: {
  22228. xmin: number;
  22229. zmin: number;
  22230. xmax: number;
  22231. zmax: number;
  22232. subdivisions?: {
  22233. w: number;
  22234. h: number;
  22235. };
  22236. precision?: {
  22237. w: number;
  22238. h: number;
  22239. };
  22240. }): VertexData;
  22241. /**
  22242. * Creates the VertexData of the Ground designed from a heightmap
  22243. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22244. * * width the width (x direction) of the ground
  22245. * * height the height (z direction) of the ground
  22246. * * subdivisions the number of subdivisions per side
  22247. * * minHeight the minimum altitude on the ground, optional, default 0
  22248. * * maxHeight the maximum altitude on the ground, optional default 1
  22249. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22250. * * buffer the array holding the image color data
  22251. * * bufferWidth the width of image
  22252. * * bufferHeight the height of image
  22253. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22254. * @returns the VertexData of the Ground designed from a heightmap
  22255. */
  22256. static CreateGroundFromHeightMap(options: {
  22257. width: number;
  22258. height: number;
  22259. subdivisions: number;
  22260. minHeight: number;
  22261. maxHeight: number;
  22262. colorFilter: Color3;
  22263. buffer: Uint8Array;
  22264. bufferWidth: number;
  22265. bufferHeight: number;
  22266. alphaFilter: number;
  22267. }): VertexData;
  22268. /**
  22269. * Creates the VertexData for a Plane
  22270. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22271. * * size sets the width and height of the plane to the value of size, optional default 1
  22272. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22273. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the box
  22278. */
  22279. static CreatePlane(options: {
  22280. size?: number;
  22281. width?: number;
  22282. height?: number;
  22283. sideOrientation?: number;
  22284. frontUVs?: Vector4;
  22285. backUVs?: Vector4;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData of the Disc or regular Polygon
  22289. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22290. * * radius the radius of the disc, optional default 0.5
  22291. * * tessellation the number of polygon sides, optional, default 64
  22292. * * 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
  22293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22294. * * 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)
  22295. * * 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)
  22296. * @returns the VertexData of the box
  22297. */
  22298. static CreateDisc(options: {
  22299. radius?: number;
  22300. tessellation?: number;
  22301. arc?: number;
  22302. sideOrientation?: number;
  22303. frontUVs?: Vector4;
  22304. backUVs?: Vector4;
  22305. }): VertexData;
  22306. /**
  22307. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22308. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22309. * @param polygon a mesh built from polygonTriangulation.build()
  22310. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22311. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22312. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22313. * @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)
  22314. * @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)
  22315. * @returns the VertexData of the Polygon
  22316. */
  22317. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22318. /**
  22319. * Creates the VertexData of the IcoSphere
  22320. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22321. * * radius the radius of the IcoSphere, optional default 1
  22322. * * radiusX allows stretching in the x direction, optional, default radius
  22323. * * radiusY allows stretching in the y direction, optional, default radius
  22324. * * radiusZ allows stretching in the z direction, optional, default radius
  22325. * * flat when true creates a flat shaded mesh, optional, default true
  22326. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22327. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22328. * * 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)
  22329. * * 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)
  22330. * @returns the VertexData of the IcoSphere
  22331. */
  22332. static CreateIcoSphere(options: {
  22333. radius?: number;
  22334. radiusX?: number;
  22335. radiusY?: number;
  22336. radiusZ?: number;
  22337. flat?: boolean;
  22338. subdivisions?: number;
  22339. sideOrientation?: number;
  22340. frontUVs?: Vector4;
  22341. backUVs?: Vector4;
  22342. }): VertexData;
  22343. /**
  22344. * Creates the VertexData for a Polyhedron
  22345. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22346. * * type provided types are:
  22347. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22348. * * 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)
  22349. * * size the size of the IcoSphere, optional default 1
  22350. * * sizeX allows stretching in the x direction, optional, default size
  22351. * * sizeY allows stretching in the y direction, optional, default size
  22352. * * sizeZ allows stretching in the z direction, optional, default size
  22353. * * 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
  22354. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22355. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22356. * * flat when true creates a flat shaded mesh, optional, default true
  22357. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22359. * * 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)
  22360. * * 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)
  22361. * @returns the VertexData of the Polyhedron
  22362. */
  22363. static CreatePolyhedron(options: {
  22364. type?: number;
  22365. size?: number;
  22366. sizeX?: number;
  22367. sizeY?: number;
  22368. sizeZ?: number;
  22369. custom?: any;
  22370. faceUV?: Vector4[];
  22371. faceColors?: Color4[];
  22372. flat?: boolean;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for a TorusKnot
  22379. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22380. * * radius the radius of the torus knot, optional, default 2
  22381. * * tube the thickness of the tube, optional, default 0.5
  22382. * * radialSegments the number of sides on each tube segments, optional, default 32
  22383. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22384. * * p the number of windings around the z axis, optional, default 2
  22385. * * q the number of windings around the x axis, optional, default 3
  22386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22387. * * 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)
  22388. * * 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)
  22389. * @returns the VertexData of the Torus Knot
  22390. */
  22391. static CreateTorusKnot(options: {
  22392. radius?: number;
  22393. tube?: number;
  22394. radialSegments?: number;
  22395. tubularSegments?: number;
  22396. p?: number;
  22397. q?: number;
  22398. sideOrientation?: number;
  22399. frontUVs?: Vector4;
  22400. backUVs?: Vector4;
  22401. }): VertexData;
  22402. /**
  22403. * Compute normals for given positions and indices
  22404. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22405. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22406. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22407. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22408. * * facetNormals : optional array of facet normals (vector3)
  22409. * * facetPositions : optional array of facet positions (vector3)
  22410. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22411. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22412. * * bInfo : optional bounding info, required for facetPartitioning computation
  22413. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22414. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22415. * * useRightHandedSystem: optional boolean to for right handed system computation
  22416. * * depthSort : optional boolean to enable the facet depth sort computation
  22417. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22418. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22419. */
  22420. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22421. facetNormals?: any;
  22422. facetPositions?: any;
  22423. facetPartitioning?: any;
  22424. ratio?: number;
  22425. bInfo?: any;
  22426. bbSize?: Vector3;
  22427. subDiv?: any;
  22428. useRightHandedSystem?: boolean;
  22429. depthSort?: boolean;
  22430. distanceTo?: Vector3;
  22431. depthSortedFacets?: any;
  22432. }): void;
  22433. /** @hidden */
  22434. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22435. /**
  22436. * Applies VertexData created from the imported parameters to the geometry
  22437. * @param parsedVertexData the parsed data from an imported file
  22438. * @param geometry the geometry to apply the VertexData to
  22439. */
  22440. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22441. }
  22442. }
  22443. declare module BABYLON {
  22444. /**
  22445. * Defines a target to use with MorphTargetManager
  22446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22447. */
  22448. export class MorphTarget implements IAnimatable {
  22449. /** defines the name of the target */
  22450. name: string;
  22451. /**
  22452. * Gets or sets the list of animations
  22453. */
  22454. animations: Animation[];
  22455. private _scene;
  22456. private _positions;
  22457. private _normals;
  22458. private _tangents;
  22459. private _uvs;
  22460. private _influence;
  22461. private _uniqueId;
  22462. /**
  22463. * Observable raised when the influence changes
  22464. */
  22465. onInfluenceChanged: Observable<boolean>;
  22466. /** @hidden */
  22467. _onDataLayoutChanged: Observable<void>;
  22468. /**
  22469. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22470. */
  22471. get influence(): number;
  22472. set influence(influence: number);
  22473. /**
  22474. * Gets or sets the id of the morph Target
  22475. */
  22476. id: string;
  22477. private _animationPropertiesOverride;
  22478. /**
  22479. * Gets or sets the animation properties override
  22480. */
  22481. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22482. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22483. /**
  22484. * Creates a new MorphTarget
  22485. * @param name defines the name of the target
  22486. * @param influence defines the influence to use
  22487. * @param scene defines the scene the morphtarget belongs to
  22488. */
  22489. constructor(
  22490. /** defines the name of the target */
  22491. name: string, influence?: number, scene?: Nullable<Scene>);
  22492. /**
  22493. * Gets the unique ID of this manager
  22494. */
  22495. get uniqueId(): number;
  22496. /**
  22497. * Gets a boolean defining if the target contains position data
  22498. */
  22499. get hasPositions(): boolean;
  22500. /**
  22501. * Gets a boolean defining if the target contains normal data
  22502. */
  22503. get hasNormals(): boolean;
  22504. /**
  22505. * Gets a boolean defining if the target contains tangent data
  22506. */
  22507. get hasTangents(): boolean;
  22508. /**
  22509. * Gets a boolean defining if the target contains texture coordinates data
  22510. */
  22511. get hasUVs(): boolean;
  22512. /**
  22513. * Affects position data to this target
  22514. * @param data defines the position data to use
  22515. */
  22516. setPositions(data: Nullable<FloatArray>): void;
  22517. /**
  22518. * Gets the position data stored in this target
  22519. * @returns a FloatArray containing the position data (or null if not present)
  22520. */
  22521. getPositions(): Nullable<FloatArray>;
  22522. /**
  22523. * Affects normal data to this target
  22524. * @param data defines the normal data to use
  22525. */
  22526. setNormals(data: Nullable<FloatArray>): void;
  22527. /**
  22528. * Gets the normal data stored in this target
  22529. * @returns a FloatArray containing the normal data (or null if not present)
  22530. */
  22531. getNormals(): Nullable<FloatArray>;
  22532. /**
  22533. * Affects tangent data to this target
  22534. * @param data defines the tangent data to use
  22535. */
  22536. setTangents(data: Nullable<FloatArray>): void;
  22537. /**
  22538. * Gets the tangent data stored in this target
  22539. * @returns a FloatArray containing the tangent data (or null if not present)
  22540. */
  22541. getTangents(): Nullable<FloatArray>;
  22542. /**
  22543. * Affects texture coordinates data to this target
  22544. * @param data defines the texture coordinates data to use
  22545. */
  22546. setUVs(data: Nullable<FloatArray>): void;
  22547. /**
  22548. * Gets the texture coordinates data stored in this target
  22549. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22550. */
  22551. getUVs(): Nullable<FloatArray>;
  22552. /**
  22553. * Clone the current target
  22554. * @returns a new MorphTarget
  22555. */
  22556. clone(): MorphTarget;
  22557. /**
  22558. * Serializes the current target into a Serialization object
  22559. * @returns the serialized object
  22560. */
  22561. serialize(): any;
  22562. /**
  22563. * Returns the string "MorphTarget"
  22564. * @returns "MorphTarget"
  22565. */
  22566. getClassName(): string;
  22567. /**
  22568. * Creates a new target from serialized data
  22569. * @param serializationObject defines the serialized data to use
  22570. * @returns a new MorphTarget
  22571. */
  22572. static Parse(serializationObject: any): MorphTarget;
  22573. /**
  22574. * Creates a MorphTarget from mesh data
  22575. * @param mesh defines the source mesh
  22576. * @param name defines the name to use for the new target
  22577. * @param influence defines the influence to attach to the target
  22578. * @returns a new MorphTarget
  22579. */
  22580. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22581. }
  22582. }
  22583. declare module BABYLON {
  22584. /**
  22585. * This class is used to deform meshes using morphing between different targets
  22586. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22587. */
  22588. export class MorphTargetManager {
  22589. private _targets;
  22590. private _targetInfluenceChangedObservers;
  22591. private _targetDataLayoutChangedObservers;
  22592. private _activeTargets;
  22593. private _scene;
  22594. private _influences;
  22595. private _supportsNormals;
  22596. private _supportsTangents;
  22597. private _supportsUVs;
  22598. private _vertexCount;
  22599. private _uniqueId;
  22600. private _tempInfluences;
  22601. /**
  22602. * Gets or sets a boolean indicating if normals must be morphed
  22603. */
  22604. enableNormalMorphing: boolean;
  22605. /**
  22606. * Gets or sets a boolean indicating if tangents must be morphed
  22607. */
  22608. enableTangentMorphing: boolean;
  22609. /**
  22610. * Gets or sets a boolean indicating if UV must be morphed
  22611. */
  22612. enableUVMorphing: boolean;
  22613. /**
  22614. * Creates a new MorphTargetManager
  22615. * @param scene defines the current scene
  22616. */
  22617. constructor(scene?: Nullable<Scene>);
  22618. /**
  22619. * Gets the unique ID of this manager
  22620. */
  22621. get uniqueId(): number;
  22622. /**
  22623. * Gets the number of vertices handled by this manager
  22624. */
  22625. get vertexCount(): number;
  22626. /**
  22627. * Gets a boolean indicating if this manager supports morphing of normals
  22628. */
  22629. get supportsNormals(): boolean;
  22630. /**
  22631. * Gets a boolean indicating if this manager supports morphing of tangents
  22632. */
  22633. get supportsTangents(): boolean;
  22634. /**
  22635. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22636. */
  22637. get supportsUVs(): boolean;
  22638. /**
  22639. * Gets the number of targets stored in this manager
  22640. */
  22641. get numTargets(): number;
  22642. /**
  22643. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22644. */
  22645. get numInfluencers(): number;
  22646. /**
  22647. * Gets the list of influences (one per target)
  22648. */
  22649. get influences(): Float32Array;
  22650. /**
  22651. * Gets the active target at specified index. An active target is a target with an influence > 0
  22652. * @param index defines the index to check
  22653. * @returns the requested target
  22654. */
  22655. getActiveTarget(index: number): MorphTarget;
  22656. /**
  22657. * Gets the target at specified index
  22658. * @param index defines the index to check
  22659. * @returns the requested target
  22660. */
  22661. getTarget(index: number): MorphTarget;
  22662. /**
  22663. * Add a new target to this manager
  22664. * @param target defines the target to add
  22665. */
  22666. addTarget(target: MorphTarget): void;
  22667. /**
  22668. * Removes a target from the manager
  22669. * @param target defines the target to remove
  22670. */
  22671. removeTarget(target: MorphTarget): void;
  22672. /**
  22673. * Clone the current manager
  22674. * @returns a new MorphTargetManager
  22675. */
  22676. clone(): MorphTargetManager;
  22677. /**
  22678. * Serializes the current manager into a Serialization object
  22679. * @returns the serialized object
  22680. */
  22681. serialize(): any;
  22682. private _syncActiveTargets;
  22683. /**
  22684. * Syncrhonize the targets with all the meshes using this morph target manager
  22685. */
  22686. synchronize(): void;
  22687. /**
  22688. * Creates a new MorphTargetManager from serialized data
  22689. * @param serializationObject defines the serialized data
  22690. * @param scene defines the hosting scene
  22691. * @returns the new MorphTargetManager
  22692. */
  22693. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22694. }
  22695. }
  22696. declare module BABYLON {
  22697. /**
  22698. * Class used to represent a specific level of detail of a mesh
  22699. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22700. */
  22701. export class MeshLODLevel {
  22702. /** Defines the distance where this level should start being displayed */
  22703. distance: number;
  22704. /** Defines the mesh to use to render this level */
  22705. mesh: Nullable<Mesh>;
  22706. /**
  22707. * Creates a new LOD level
  22708. * @param distance defines the distance where this level should star being displayed
  22709. * @param mesh defines the mesh to use to render this level
  22710. */
  22711. constructor(
  22712. /** Defines the distance where this level should start being displayed */
  22713. distance: number,
  22714. /** Defines the mesh to use to render this level */
  22715. mesh: Nullable<Mesh>);
  22716. }
  22717. }
  22718. declare module BABYLON {
  22719. /**
  22720. * Mesh representing the gorund
  22721. */
  22722. export class GroundMesh extends Mesh {
  22723. /** If octree should be generated */
  22724. generateOctree: boolean;
  22725. private _heightQuads;
  22726. /** @hidden */
  22727. _subdivisionsX: number;
  22728. /** @hidden */
  22729. _subdivisionsY: number;
  22730. /** @hidden */
  22731. _width: number;
  22732. /** @hidden */
  22733. _height: number;
  22734. /** @hidden */
  22735. _minX: number;
  22736. /** @hidden */
  22737. _maxX: number;
  22738. /** @hidden */
  22739. _minZ: number;
  22740. /** @hidden */
  22741. _maxZ: number;
  22742. constructor(name: string, scene: Scene);
  22743. /**
  22744. * "GroundMesh"
  22745. * @returns "GroundMesh"
  22746. */
  22747. getClassName(): string;
  22748. /**
  22749. * The minimum of x and y subdivisions
  22750. */
  22751. get subdivisions(): number;
  22752. /**
  22753. * X subdivisions
  22754. */
  22755. get subdivisionsX(): number;
  22756. /**
  22757. * Y subdivisions
  22758. */
  22759. get subdivisionsY(): number;
  22760. /**
  22761. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22762. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22763. * @param chunksCount the number of subdivisions for x and y
  22764. * @param octreeBlocksSize (Default: 32)
  22765. */
  22766. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22767. /**
  22768. * Returns a height (y) value in the Worl system :
  22769. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22770. * @param x x coordinate
  22771. * @param z z coordinate
  22772. * @returns the ground y position if (x, z) are outside the ground surface.
  22773. */
  22774. getHeightAtCoordinates(x: number, z: number): number;
  22775. /**
  22776. * Returns a normalized vector (Vector3) orthogonal to the ground
  22777. * at the ground coordinates (x, z) expressed in the World system.
  22778. * @param x x coordinate
  22779. * @param z z coordinate
  22780. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22781. */
  22782. getNormalAtCoordinates(x: number, z: number): Vector3;
  22783. /**
  22784. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22785. * at the ground coordinates (x, z) expressed in the World system.
  22786. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22787. * @param x x coordinate
  22788. * @param z z coordinate
  22789. * @param ref vector to store the result
  22790. * @returns the GroundMesh.
  22791. */
  22792. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22793. /**
  22794. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22795. * if the ground has been updated.
  22796. * This can be used in the render loop.
  22797. * @returns the GroundMesh.
  22798. */
  22799. updateCoordinateHeights(): GroundMesh;
  22800. private _getFacetAt;
  22801. private _initHeightQuads;
  22802. private _computeHeightQuads;
  22803. /**
  22804. * Serializes this ground mesh
  22805. * @param serializationObject object to write serialization to
  22806. */
  22807. serialize(serializationObject: any): void;
  22808. /**
  22809. * Parses a serialized ground mesh
  22810. * @param parsedMesh the serialized mesh
  22811. * @param scene the scene to create the ground mesh in
  22812. * @returns the created ground mesh
  22813. */
  22814. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22815. }
  22816. }
  22817. declare module BABYLON {
  22818. /**
  22819. * Interface for Physics-Joint data
  22820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22821. */
  22822. export interface PhysicsJointData {
  22823. /**
  22824. * The main pivot of the joint
  22825. */
  22826. mainPivot?: Vector3;
  22827. /**
  22828. * The connected pivot of the joint
  22829. */
  22830. connectedPivot?: Vector3;
  22831. /**
  22832. * The main axis of the joint
  22833. */
  22834. mainAxis?: Vector3;
  22835. /**
  22836. * The connected axis of the joint
  22837. */
  22838. connectedAxis?: Vector3;
  22839. /**
  22840. * The collision of the joint
  22841. */
  22842. collision?: boolean;
  22843. /**
  22844. * Native Oimo/Cannon/Energy data
  22845. */
  22846. nativeParams?: any;
  22847. }
  22848. /**
  22849. * This is a holder class for the physics joint created by the physics plugin
  22850. * It holds a set of functions to control the underlying joint
  22851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22852. */
  22853. export class PhysicsJoint {
  22854. /**
  22855. * The type of the physics joint
  22856. */
  22857. type: number;
  22858. /**
  22859. * The data for the physics joint
  22860. */
  22861. jointData: PhysicsJointData;
  22862. private _physicsJoint;
  22863. protected _physicsPlugin: IPhysicsEnginePlugin;
  22864. /**
  22865. * Initializes the physics joint
  22866. * @param type The type of the physics joint
  22867. * @param jointData The data for the physics joint
  22868. */
  22869. constructor(
  22870. /**
  22871. * The type of the physics joint
  22872. */
  22873. type: number,
  22874. /**
  22875. * The data for the physics joint
  22876. */
  22877. jointData: PhysicsJointData);
  22878. /**
  22879. * Gets the physics joint
  22880. */
  22881. get physicsJoint(): any;
  22882. /**
  22883. * Sets the physics joint
  22884. */
  22885. set physicsJoint(newJoint: any);
  22886. /**
  22887. * Sets the physics plugin
  22888. */
  22889. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22890. /**
  22891. * Execute a function that is physics-plugin specific.
  22892. * @param {Function} func the function that will be executed.
  22893. * It accepts two parameters: the physics world and the physics joint
  22894. */
  22895. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22896. /**
  22897. * Distance-Joint type
  22898. */
  22899. static DistanceJoint: number;
  22900. /**
  22901. * Hinge-Joint type
  22902. */
  22903. static HingeJoint: number;
  22904. /**
  22905. * Ball-and-Socket joint type
  22906. */
  22907. static BallAndSocketJoint: number;
  22908. /**
  22909. * Wheel-Joint type
  22910. */
  22911. static WheelJoint: number;
  22912. /**
  22913. * Slider-Joint type
  22914. */
  22915. static SliderJoint: number;
  22916. /**
  22917. * Prismatic-Joint type
  22918. */
  22919. static PrismaticJoint: number;
  22920. /**
  22921. * Universal-Joint type
  22922. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22923. */
  22924. static UniversalJoint: number;
  22925. /**
  22926. * Hinge-Joint 2 type
  22927. */
  22928. static Hinge2Joint: number;
  22929. /**
  22930. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22931. */
  22932. static PointToPointJoint: number;
  22933. /**
  22934. * Spring-Joint type
  22935. */
  22936. static SpringJoint: number;
  22937. /**
  22938. * Lock-Joint type
  22939. */
  22940. static LockJoint: number;
  22941. }
  22942. /**
  22943. * A class representing a physics distance joint
  22944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22945. */
  22946. export class DistanceJoint extends PhysicsJoint {
  22947. /**
  22948. *
  22949. * @param jointData The data for the Distance-Joint
  22950. */
  22951. constructor(jointData: DistanceJointData);
  22952. /**
  22953. * Update the predefined distance.
  22954. * @param maxDistance The maximum preferred distance
  22955. * @param minDistance The minimum preferred distance
  22956. */
  22957. updateDistance(maxDistance: number, minDistance?: number): void;
  22958. }
  22959. /**
  22960. * Represents a Motor-Enabled Joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22964. /**
  22965. * Initializes the Motor-Enabled Joint
  22966. * @param type The type of the joint
  22967. * @param jointData The physica joint data for the joint
  22968. */
  22969. constructor(type: number, jointData: PhysicsJointData);
  22970. /**
  22971. * Set the motor values.
  22972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22973. * @param force the force to apply
  22974. * @param maxForce max force for this motor.
  22975. */
  22976. setMotor(force?: number, maxForce?: number): void;
  22977. /**
  22978. * Set the motor's limits.
  22979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22980. * @param upperLimit The upper limit of the motor
  22981. * @param lowerLimit The lower limit of the motor
  22982. */
  22983. setLimit(upperLimit: number, lowerLimit?: number): void;
  22984. }
  22985. /**
  22986. * This class represents a single physics Hinge-Joint
  22987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22988. */
  22989. export class HingeJoint extends MotorEnabledJoint {
  22990. /**
  22991. * Initializes the Hinge-Joint
  22992. * @param jointData The joint data for the Hinge-Joint
  22993. */
  22994. constructor(jointData: PhysicsJointData);
  22995. /**
  22996. * Set the motor values.
  22997. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22998. * @param {number} force the force to apply
  22999. * @param {number} maxForce max force for this motor.
  23000. */
  23001. setMotor(force?: number, maxForce?: number): void;
  23002. /**
  23003. * Set the motor's limits.
  23004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23005. * @param upperLimit The upper limit of the motor
  23006. * @param lowerLimit The lower limit of the motor
  23007. */
  23008. setLimit(upperLimit: number, lowerLimit?: number): void;
  23009. }
  23010. /**
  23011. * This class represents a dual hinge physics joint (same as wheel joint)
  23012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23013. */
  23014. export class Hinge2Joint extends MotorEnabledJoint {
  23015. /**
  23016. * Initializes the Hinge2-Joint
  23017. * @param jointData The joint data for the Hinge2-Joint
  23018. */
  23019. constructor(jointData: PhysicsJointData);
  23020. /**
  23021. * Set the motor values.
  23022. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23023. * @param {number} targetSpeed the speed the motor is to reach
  23024. * @param {number} maxForce max force for this motor.
  23025. * @param {motorIndex} the motor's index, 0 or 1.
  23026. */
  23027. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23028. /**
  23029. * Set the motor limits.
  23030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23031. * @param {number} upperLimit the upper limit
  23032. * @param {number} lowerLimit lower limit
  23033. * @param {motorIndex} the motor's index, 0 or 1.
  23034. */
  23035. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23036. }
  23037. /**
  23038. * Interface for a motor enabled joint
  23039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23040. */
  23041. export interface IMotorEnabledJoint {
  23042. /**
  23043. * Physics joint
  23044. */
  23045. physicsJoint: any;
  23046. /**
  23047. * Sets the motor of the motor-enabled joint
  23048. * @param force The force of the motor
  23049. * @param maxForce The maximum force of the motor
  23050. * @param motorIndex The index of the motor
  23051. */
  23052. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23053. /**
  23054. * Sets the limit of the motor
  23055. * @param upperLimit The upper limit of the motor
  23056. * @param lowerLimit The lower limit of the motor
  23057. * @param motorIndex The index of the motor
  23058. */
  23059. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23060. }
  23061. /**
  23062. * Joint data for a Distance-Joint
  23063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23064. */
  23065. export interface DistanceJointData extends PhysicsJointData {
  23066. /**
  23067. * Max distance the 2 joint objects can be apart
  23068. */
  23069. maxDistance: number;
  23070. }
  23071. /**
  23072. * Joint data from a spring joint
  23073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23074. */
  23075. export interface SpringJointData extends PhysicsJointData {
  23076. /**
  23077. * Length of the spring
  23078. */
  23079. length: number;
  23080. /**
  23081. * Stiffness of the spring
  23082. */
  23083. stiffness: number;
  23084. /**
  23085. * Damping of the spring
  23086. */
  23087. damping: number;
  23088. /** this callback will be called when applying the force to the impostors. */
  23089. forceApplicationCallback: () => void;
  23090. }
  23091. }
  23092. declare module BABYLON {
  23093. /**
  23094. * Holds the data for the raycast result
  23095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23096. */
  23097. export class PhysicsRaycastResult {
  23098. private _hasHit;
  23099. private _hitDistance;
  23100. private _hitNormalWorld;
  23101. private _hitPointWorld;
  23102. private _rayFromWorld;
  23103. private _rayToWorld;
  23104. /**
  23105. * Gets if there was a hit
  23106. */
  23107. get hasHit(): boolean;
  23108. /**
  23109. * Gets the distance from the hit
  23110. */
  23111. get hitDistance(): number;
  23112. /**
  23113. * Gets the hit normal/direction in the world
  23114. */
  23115. get hitNormalWorld(): Vector3;
  23116. /**
  23117. * Gets the hit point in the world
  23118. */
  23119. get hitPointWorld(): Vector3;
  23120. /**
  23121. * Gets the ray "start point" of the ray in the world
  23122. */
  23123. get rayFromWorld(): Vector3;
  23124. /**
  23125. * Gets the ray "end point" of the ray in the world
  23126. */
  23127. get rayToWorld(): Vector3;
  23128. /**
  23129. * Sets the hit data (normal & point in world space)
  23130. * @param hitNormalWorld defines the normal in world space
  23131. * @param hitPointWorld defines the point in world space
  23132. */
  23133. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23134. /**
  23135. * Sets the distance from the start point to the hit point
  23136. * @param distance
  23137. */
  23138. setHitDistance(distance: number): void;
  23139. /**
  23140. * Calculates the distance manually
  23141. */
  23142. calculateHitDistance(): void;
  23143. /**
  23144. * Resets all the values to default
  23145. * @param from The from point on world space
  23146. * @param to The to point on world space
  23147. */
  23148. reset(from?: Vector3, to?: Vector3): void;
  23149. }
  23150. /**
  23151. * Interface for the size containing width and height
  23152. */
  23153. interface IXYZ {
  23154. /**
  23155. * X
  23156. */
  23157. x: number;
  23158. /**
  23159. * Y
  23160. */
  23161. y: number;
  23162. /**
  23163. * Z
  23164. */
  23165. z: number;
  23166. }
  23167. }
  23168. declare module BABYLON {
  23169. /**
  23170. * Interface used to describe a physics joint
  23171. */
  23172. export interface PhysicsImpostorJoint {
  23173. /** Defines the main impostor to which the joint is linked */
  23174. mainImpostor: PhysicsImpostor;
  23175. /** Defines the impostor that is connected to the main impostor using this joint */
  23176. connectedImpostor: PhysicsImpostor;
  23177. /** Defines the joint itself */
  23178. joint: PhysicsJoint;
  23179. }
  23180. /** @hidden */
  23181. export interface IPhysicsEnginePlugin {
  23182. world: any;
  23183. name: string;
  23184. setGravity(gravity: Vector3): void;
  23185. setTimeStep(timeStep: number): void;
  23186. getTimeStep(): number;
  23187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23188. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23189. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23190. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23191. removePhysicsBody(impostor: PhysicsImpostor): void;
  23192. generateJoint(joint: PhysicsImpostorJoint): void;
  23193. removeJoint(joint: PhysicsImpostorJoint): void;
  23194. isSupported(): boolean;
  23195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23202. getBodyMass(impostor: PhysicsImpostor): number;
  23203. getBodyFriction(impostor: PhysicsImpostor): number;
  23204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23205. getBodyRestitution(impostor: PhysicsImpostor): number;
  23206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23207. getBodyPressure?(impostor: PhysicsImpostor): number;
  23208. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23209. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23210. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23211. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23212. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23213. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23214. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23215. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23216. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23217. sleepBody(impostor: PhysicsImpostor): void;
  23218. wakeUpBody(impostor: PhysicsImpostor): void;
  23219. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23220. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23221. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23222. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23223. getRadius(impostor: PhysicsImpostor): number;
  23224. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23226. dispose(): void;
  23227. }
  23228. /**
  23229. * Interface used to define a physics engine
  23230. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23231. */
  23232. export interface IPhysicsEngine {
  23233. /**
  23234. * Gets the gravity vector used by the simulation
  23235. */
  23236. gravity: Vector3;
  23237. /**
  23238. * Sets the gravity vector used by the simulation
  23239. * @param gravity defines the gravity vector to use
  23240. */
  23241. setGravity(gravity: Vector3): void;
  23242. /**
  23243. * Set the time step of the physics engine.
  23244. * Default is 1/60.
  23245. * To slow it down, enter 1/600 for example.
  23246. * To speed it up, 1/30
  23247. * @param newTimeStep the new timestep to apply to this world.
  23248. */
  23249. setTimeStep(newTimeStep: number): void;
  23250. /**
  23251. * Get the time step of the physics engine.
  23252. * @returns the current time step
  23253. */
  23254. getTimeStep(): number;
  23255. /**
  23256. * Set the sub time step of the physics engine.
  23257. * Default is 0 meaning there is no sub steps
  23258. * To increase physics resolution precision, set a small value (like 1 ms)
  23259. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23260. */
  23261. setSubTimeStep(subTimeStep: number): void;
  23262. /**
  23263. * Get the sub time step of the physics engine.
  23264. * @returns the current sub time step
  23265. */
  23266. getSubTimeStep(): number;
  23267. /**
  23268. * Release all resources
  23269. */
  23270. dispose(): void;
  23271. /**
  23272. * Gets the name of the current physics plugin
  23273. * @returns the name of the plugin
  23274. */
  23275. getPhysicsPluginName(): string;
  23276. /**
  23277. * Adding a new impostor for the impostor tracking.
  23278. * This will be done by the impostor itself.
  23279. * @param impostor the impostor to add
  23280. */
  23281. addImpostor(impostor: PhysicsImpostor): void;
  23282. /**
  23283. * Remove an impostor from the engine.
  23284. * This impostor and its mesh will not longer be updated by the physics engine.
  23285. * @param impostor the impostor to remove
  23286. */
  23287. removeImpostor(impostor: PhysicsImpostor): void;
  23288. /**
  23289. * Add a joint to the physics engine
  23290. * @param mainImpostor defines the main impostor to which the joint is added.
  23291. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23292. * @param joint defines the joint that will connect both impostors.
  23293. */
  23294. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23295. /**
  23296. * Removes a joint from the simulation
  23297. * @param mainImpostor defines the impostor used with the joint
  23298. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23299. * @param joint defines the joint to remove
  23300. */
  23301. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23302. /**
  23303. * Gets the current plugin used to run the simulation
  23304. * @returns current plugin
  23305. */
  23306. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23307. /**
  23308. * Gets the list of physic impostors
  23309. * @returns an array of PhysicsImpostor
  23310. */
  23311. getImpostors(): Array<PhysicsImpostor>;
  23312. /**
  23313. * Gets the impostor for a physics enabled object
  23314. * @param object defines the object impersonated by the impostor
  23315. * @returns the PhysicsImpostor or null if not found
  23316. */
  23317. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23318. /**
  23319. * Gets the impostor for a physics body object
  23320. * @param body defines physics body used by the impostor
  23321. * @returns the PhysicsImpostor or null if not found
  23322. */
  23323. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23324. /**
  23325. * Does a raycast in the physics world
  23326. * @param from when should the ray start?
  23327. * @param to when should the ray end?
  23328. * @returns PhysicsRaycastResult
  23329. */
  23330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23331. /**
  23332. * Called by the scene. No need to call it.
  23333. * @param delta defines the timespam between frames
  23334. */
  23335. _step(delta: number): void;
  23336. }
  23337. }
  23338. declare module BABYLON {
  23339. /**
  23340. * The interface for the physics imposter parameters
  23341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23342. */
  23343. export interface PhysicsImpostorParameters {
  23344. /**
  23345. * The mass of the physics imposter
  23346. */
  23347. mass: number;
  23348. /**
  23349. * The friction of the physics imposter
  23350. */
  23351. friction?: number;
  23352. /**
  23353. * The coefficient of restitution of the physics imposter
  23354. */
  23355. restitution?: number;
  23356. /**
  23357. * The native options of the physics imposter
  23358. */
  23359. nativeOptions?: any;
  23360. /**
  23361. * Specifies if the parent should be ignored
  23362. */
  23363. ignoreParent?: boolean;
  23364. /**
  23365. * Specifies if bi-directional transformations should be disabled
  23366. */
  23367. disableBidirectionalTransformation?: boolean;
  23368. /**
  23369. * The pressure inside the physics imposter, soft object only
  23370. */
  23371. pressure?: number;
  23372. /**
  23373. * The stiffness the physics imposter, soft object only
  23374. */
  23375. stiffness?: number;
  23376. /**
  23377. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23378. */
  23379. velocityIterations?: number;
  23380. /**
  23381. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23382. */
  23383. positionIterations?: number;
  23384. /**
  23385. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23386. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23387. * Add to fix multiple points
  23388. */
  23389. fixedPoints?: number;
  23390. /**
  23391. * The collision margin around a soft object
  23392. */
  23393. margin?: number;
  23394. /**
  23395. * The collision margin around a soft object
  23396. */
  23397. damping?: number;
  23398. /**
  23399. * The path for a rope based on an extrusion
  23400. */
  23401. path?: any;
  23402. /**
  23403. * The shape of an extrusion used for a rope based on an extrusion
  23404. */
  23405. shape?: any;
  23406. }
  23407. /**
  23408. * Interface for a physics-enabled object
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export interface IPhysicsEnabledObject {
  23412. /**
  23413. * The position of the physics-enabled object
  23414. */
  23415. position: Vector3;
  23416. /**
  23417. * The rotation of the physics-enabled object
  23418. */
  23419. rotationQuaternion: Nullable<Quaternion>;
  23420. /**
  23421. * The scale of the physics-enabled object
  23422. */
  23423. scaling: Vector3;
  23424. /**
  23425. * The rotation of the physics-enabled object
  23426. */
  23427. rotation?: Vector3;
  23428. /**
  23429. * The parent of the physics-enabled object
  23430. */
  23431. parent?: any;
  23432. /**
  23433. * The bounding info of the physics-enabled object
  23434. * @returns The bounding info of the physics-enabled object
  23435. */
  23436. getBoundingInfo(): BoundingInfo;
  23437. /**
  23438. * Computes the world matrix
  23439. * @param force Specifies if the world matrix should be computed by force
  23440. * @returns A world matrix
  23441. */
  23442. computeWorldMatrix(force: boolean): Matrix;
  23443. /**
  23444. * Gets the world matrix
  23445. * @returns A world matrix
  23446. */
  23447. getWorldMatrix?(): Matrix;
  23448. /**
  23449. * Gets the child meshes
  23450. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23451. * @returns An array of abstract meshes
  23452. */
  23453. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23454. /**
  23455. * Gets the vertex data
  23456. * @param kind The type of vertex data
  23457. * @returns A nullable array of numbers, or a float32 array
  23458. */
  23459. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23460. /**
  23461. * Gets the indices from the mesh
  23462. * @returns A nullable array of index arrays
  23463. */
  23464. getIndices?(): Nullable<IndicesArray>;
  23465. /**
  23466. * Gets the scene from the mesh
  23467. * @returns the indices array or null
  23468. */
  23469. getScene?(): Scene;
  23470. /**
  23471. * Gets the absolute position from the mesh
  23472. * @returns the absolute position
  23473. */
  23474. getAbsolutePosition(): Vector3;
  23475. /**
  23476. * Gets the absolute pivot point from the mesh
  23477. * @returns the absolute pivot point
  23478. */
  23479. getAbsolutePivotPoint(): Vector3;
  23480. /**
  23481. * Rotates the mesh
  23482. * @param axis The axis of rotation
  23483. * @param amount The amount of rotation
  23484. * @param space The space of the rotation
  23485. * @returns The rotation transform node
  23486. */
  23487. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23488. /**
  23489. * Translates the mesh
  23490. * @param axis The axis of translation
  23491. * @param distance The distance of translation
  23492. * @param space The space of the translation
  23493. * @returns The transform node
  23494. */
  23495. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23496. /**
  23497. * Sets the absolute position of the mesh
  23498. * @param absolutePosition The absolute position of the mesh
  23499. * @returns The transform node
  23500. */
  23501. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23502. /**
  23503. * Gets the class name of the mesh
  23504. * @returns The class name
  23505. */
  23506. getClassName(): string;
  23507. }
  23508. /**
  23509. * Represents a physics imposter
  23510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23511. */
  23512. export class PhysicsImpostor {
  23513. /**
  23514. * The physics-enabled object used as the physics imposter
  23515. */
  23516. object: IPhysicsEnabledObject;
  23517. /**
  23518. * The type of the physics imposter
  23519. */
  23520. type: number;
  23521. private _options;
  23522. private _scene?;
  23523. /**
  23524. * The default object size of the imposter
  23525. */
  23526. static DEFAULT_OBJECT_SIZE: Vector3;
  23527. /**
  23528. * The identity quaternion of the imposter
  23529. */
  23530. static IDENTITY_QUATERNION: Quaternion;
  23531. /** @hidden */
  23532. _pluginData: any;
  23533. private _physicsEngine;
  23534. private _physicsBody;
  23535. private _bodyUpdateRequired;
  23536. private _onBeforePhysicsStepCallbacks;
  23537. private _onAfterPhysicsStepCallbacks;
  23538. /** @hidden */
  23539. _onPhysicsCollideCallbacks: Array<{
  23540. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23541. otherImpostors: Array<PhysicsImpostor>;
  23542. }>;
  23543. private _deltaPosition;
  23544. private _deltaRotation;
  23545. private _deltaRotationConjugated;
  23546. /** @hidden */
  23547. _isFromLine: boolean;
  23548. private _parent;
  23549. private _isDisposed;
  23550. private static _tmpVecs;
  23551. private static _tmpQuat;
  23552. /**
  23553. * Specifies if the physics imposter is disposed
  23554. */
  23555. get isDisposed(): boolean;
  23556. /**
  23557. * Gets the mass of the physics imposter
  23558. */
  23559. get mass(): number;
  23560. set mass(value: number);
  23561. /**
  23562. * Gets the coefficient of friction
  23563. */
  23564. get friction(): number;
  23565. /**
  23566. * Sets the coefficient of friction
  23567. */
  23568. set friction(value: number);
  23569. /**
  23570. * Gets the coefficient of restitution
  23571. */
  23572. get restitution(): number;
  23573. /**
  23574. * Sets the coefficient of restitution
  23575. */
  23576. set restitution(value: number);
  23577. /**
  23578. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23579. */
  23580. get pressure(): number;
  23581. /**
  23582. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23583. */
  23584. set pressure(value: number);
  23585. /**
  23586. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23587. */
  23588. get stiffness(): number;
  23589. /**
  23590. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23591. */
  23592. set stiffness(value: number);
  23593. /**
  23594. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23595. */
  23596. get velocityIterations(): number;
  23597. /**
  23598. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23599. */
  23600. set velocityIterations(value: number);
  23601. /**
  23602. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23603. */
  23604. get positionIterations(): number;
  23605. /**
  23606. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23607. */
  23608. set positionIterations(value: number);
  23609. /**
  23610. * The unique id of the physics imposter
  23611. * set by the physics engine when adding this impostor to the array
  23612. */
  23613. uniqueId: number;
  23614. /**
  23615. * @hidden
  23616. */
  23617. soft: boolean;
  23618. /**
  23619. * @hidden
  23620. */
  23621. segments: number;
  23622. private _joints;
  23623. /**
  23624. * Initializes the physics imposter
  23625. * @param object The physics-enabled object used as the physics imposter
  23626. * @param type The type of the physics imposter
  23627. * @param _options The options for the physics imposter
  23628. * @param _scene The Babylon scene
  23629. */
  23630. constructor(
  23631. /**
  23632. * The physics-enabled object used as the physics imposter
  23633. */
  23634. object: IPhysicsEnabledObject,
  23635. /**
  23636. * The type of the physics imposter
  23637. */
  23638. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23639. /**
  23640. * This function will completly initialize this impostor.
  23641. * It will create a new body - but only if this mesh has no parent.
  23642. * If it has, this impostor will not be used other than to define the impostor
  23643. * of the child mesh.
  23644. * @hidden
  23645. */
  23646. _init(): void;
  23647. private _getPhysicsParent;
  23648. /**
  23649. * Should a new body be generated.
  23650. * @returns boolean specifying if body initialization is required
  23651. */
  23652. isBodyInitRequired(): boolean;
  23653. /**
  23654. * Sets the updated scaling
  23655. * @param updated Specifies if the scaling is updated
  23656. */
  23657. setScalingUpdated(): void;
  23658. /**
  23659. * Force a regeneration of this or the parent's impostor's body.
  23660. * Use under cautious - This will remove all joints already implemented.
  23661. */
  23662. forceUpdate(): void;
  23663. /**
  23664. * Gets the body that holds this impostor. Either its own, or its parent.
  23665. */
  23666. get physicsBody(): any;
  23667. /**
  23668. * Get the parent of the physics imposter
  23669. * @returns Physics imposter or null
  23670. */
  23671. get parent(): Nullable<PhysicsImpostor>;
  23672. /**
  23673. * Sets the parent of the physics imposter
  23674. */
  23675. set parent(value: Nullable<PhysicsImpostor>);
  23676. /**
  23677. * Set the physics body. Used mainly by the physics engine/plugin
  23678. */
  23679. set physicsBody(physicsBody: any);
  23680. /**
  23681. * Resets the update flags
  23682. */
  23683. resetUpdateFlags(): void;
  23684. /**
  23685. * Gets the object extend size
  23686. * @returns the object extend size
  23687. */
  23688. getObjectExtendSize(): Vector3;
  23689. /**
  23690. * Gets the object center
  23691. * @returns The object center
  23692. */
  23693. getObjectCenter(): Vector3;
  23694. /**
  23695. * Get a specific parametes from the options parameter
  23696. * @param paramName The object parameter name
  23697. * @returns The object parameter
  23698. */
  23699. getParam(paramName: string): any;
  23700. /**
  23701. * Sets a specific parameter in the options given to the physics plugin
  23702. * @param paramName The parameter name
  23703. * @param value The value of the parameter
  23704. */
  23705. setParam(paramName: string, value: number): void;
  23706. /**
  23707. * Specifically change the body's mass option. Won't recreate the physics body object
  23708. * @param mass The mass of the physics imposter
  23709. */
  23710. setMass(mass: number): void;
  23711. /**
  23712. * Gets the linear velocity
  23713. * @returns linear velocity or null
  23714. */
  23715. getLinearVelocity(): Nullable<Vector3>;
  23716. /**
  23717. * Sets the linear velocity
  23718. * @param velocity linear velocity or null
  23719. */
  23720. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23721. /**
  23722. * Gets the angular velocity
  23723. * @returns angular velocity or null
  23724. */
  23725. getAngularVelocity(): Nullable<Vector3>;
  23726. /**
  23727. * Sets the angular velocity
  23728. * @param velocity The velocity or null
  23729. */
  23730. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23731. /**
  23732. * Execute a function with the physics plugin native code
  23733. * Provide a function the will have two variables - the world object and the physics body object
  23734. * @param func The function to execute with the physics plugin native code
  23735. */
  23736. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23737. /**
  23738. * Register a function that will be executed before the physics world is stepping forward
  23739. * @param func The function to execute before the physics world is stepped forward
  23740. */
  23741. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23742. /**
  23743. * Unregister a function that will be executed before the physics world is stepping forward
  23744. * @param func The function to execute before the physics world is stepped forward
  23745. */
  23746. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23747. /**
  23748. * Register a function that will be executed after the physics step
  23749. * @param func The function to execute after physics step
  23750. */
  23751. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23752. /**
  23753. * Unregisters a function that will be executed after the physics step
  23754. * @param func The function to execute after physics step
  23755. */
  23756. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23757. /**
  23758. * register a function that will be executed when this impostor collides against a different body
  23759. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23760. * @param func Callback that is executed on collision
  23761. */
  23762. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23763. /**
  23764. * Unregisters the physics imposter on contact
  23765. * @param collideAgainst The physics object to collide against
  23766. * @param func Callback to execute on collision
  23767. */
  23768. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23769. private _tmpQuat;
  23770. private _tmpQuat2;
  23771. /**
  23772. * Get the parent rotation
  23773. * @returns The parent rotation
  23774. */
  23775. getParentsRotation(): Quaternion;
  23776. /**
  23777. * this function is executed by the physics engine.
  23778. */
  23779. beforeStep: () => void;
  23780. /**
  23781. * this function is executed by the physics engine
  23782. */
  23783. afterStep: () => void;
  23784. /**
  23785. * Legacy collision detection event support
  23786. */
  23787. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23788. /**
  23789. * event and body object due to cannon's event-based architecture.
  23790. */
  23791. onCollide: (e: {
  23792. body: any;
  23793. }) => void;
  23794. /**
  23795. * Apply a force
  23796. * @param force The force to apply
  23797. * @param contactPoint The contact point for the force
  23798. * @returns The physics imposter
  23799. */
  23800. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23801. /**
  23802. * Apply an impulse
  23803. * @param force The impulse force
  23804. * @param contactPoint The contact point for the impulse force
  23805. * @returns The physics imposter
  23806. */
  23807. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23808. /**
  23809. * A help function to create a joint
  23810. * @param otherImpostor A physics imposter used to create a joint
  23811. * @param jointType The type of joint
  23812. * @param jointData The data for the joint
  23813. * @returns The physics imposter
  23814. */
  23815. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23816. /**
  23817. * Add a joint to this impostor with a different impostor
  23818. * @param otherImpostor A physics imposter used to add a joint
  23819. * @param joint The joint to add
  23820. * @returns The physics imposter
  23821. */
  23822. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23823. /**
  23824. * Add an anchor to a cloth impostor
  23825. * @param otherImpostor rigid impostor to anchor to
  23826. * @param width ratio across width from 0 to 1
  23827. * @param height ratio up height from 0 to 1
  23828. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23829. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23830. * @returns impostor the soft imposter
  23831. */
  23832. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23833. /**
  23834. * Add a hook to a rope impostor
  23835. * @param otherImpostor rigid impostor to anchor to
  23836. * @param length ratio across rope from 0 to 1
  23837. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23838. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23839. * @returns impostor the rope imposter
  23840. */
  23841. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23842. /**
  23843. * Will keep this body still, in a sleep mode.
  23844. * @returns the physics imposter
  23845. */
  23846. sleep(): PhysicsImpostor;
  23847. /**
  23848. * Wake the body up.
  23849. * @returns The physics imposter
  23850. */
  23851. wakeUp(): PhysicsImpostor;
  23852. /**
  23853. * Clones the physics imposter
  23854. * @param newObject The physics imposter clones to this physics-enabled object
  23855. * @returns A nullable physics imposter
  23856. */
  23857. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23858. /**
  23859. * Disposes the physics imposter
  23860. */
  23861. dispose(): void;
  23862. /**
  23863. * Sets the delta position
  23864. * @param position The delta position amount
  23865. */
  23866. setDeltaPosition(position: Vector3): void;
  23867. /**
  23868. * Sets the delta rotation
  23869. * @param rotation The delta rotation amount
  23870. */
  23871. setDeltaRotation(rotation: Quaternion): void;
  23872. /**
  23873. * Gets the box size of the physics imposter and stores the result in the input parameter
  23874. * @param result Stores the box size
  23875. * @returns The physics imposter
  23876. */
  23877. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23878. /**
  23879. * Gets the radius of the physics imposter
  23880. * @returns Radius of the physics imposter
  23881. */
  23882. getRadius(): number;
  23883. /**
  23884. * Sync a bone with this impostor
  23885. * @param bone The bone to sync to the impostor.
  23886. * @param boneMesh The mesh that the bone is influencing.
  23887. * @param jointPivot The pivot of the joint / bone in local space.
  23888. * @param distToJoint Optional distance from the impostor to the joint.
  23889. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23890. */
  23891. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23892. /**
  23893. * Sync impostor to a bone
  23894. * @param bone The bone that the impostor will be synced to.
  23895. * @param boneMesh The mesh that the bone is influencing.
  23896. * @param jointPivot The pivot of the joint / bone in local space.
  23897. * @param distToJoint Optional distance from the impostor to the joint.
  23898. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23899. * @param boneAxis Optional vector3 axis the bone is aligned with
  23900. */
  23901. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23902. /**
  23903. * No-Imposter type
  23904. */
  23905. static NoImpostor: number;
  23906. /**
  23907. * Sphere-Imposter type
  23908. */
  23909. static SphereImpostor: number;
  23910. /**
  23911. * Box-Imposter type
  23912. */
  23913. static BoxImpostor: number;
  23914. /**
  23915. * Plane-Imposter type
  23916. */
  23917. static PlaneImpostor: number;
  23918. /**
  23919. * Mesh-imposter type
  23920. */
  23921. static MeshImpostor: number;
  23922. /**
  23923. * Capsule-Impostor type (Ammo.js plugin only)
  23924. */
  23925. static CapsuleImpostor: number;
  23926. /**
  23927. * Cylinder-Imposter type
  23928. */
  23929. static CylinderImpostor: number;
  23930. /**
  23931. * Particle-Imposter type
  23932. */
  23933. static ParticleImpostor: number;
  23934. /**
  23935. * Heightmap-Imposter type
  23936. */
  23937. static HeightmapImpostor: number;
  23938. /**
  23939. * ConvexHull-Impostor type (Ammo.js plugin only)
  23940. */
  23941. static ConvexHullImpostor: number;
  23942. /**
  23943. * Custom-Imposter type (Ammo.js plugin only)
  23944. */
  23945. static CustomImpostor: number;
  23946. /**
  23947. * Rope-Imposter type
  23948. */
  23949. static RopeImpostor: number;
  23950. /**
  23951. * Cloth-Imposter type
  23952. */
  23953. static ClothImpostor: number;
  23954. /**
  23955. * Softbody-Imposter type
  23956. */
  23957. static SoftbodyImpostor: number;
  23958. }
  23959. }
  23960. declare module BABYLON {
  23961. /**
  23962. * @hidden
  23963. **/
  23964. export class _CreationDataStorage {
  23965. closePath?: boolean;
  23966. closeArray?: boolean;
  23967. idx: number[];
  23968. dashSize: number;
  23969. gapSize: number;
  23970. path3D: Path3D;
  23971. pathArray: Vector3[][];
  23972. arc: number;
  23973. radius: number;
  23974. cap: number;
  23975. tessellation: number;
  23976. }
  23977. /**
  23978. * @hidden
  23979. **/
  23980. class _InstanceDataStorage {
  23981. visibleInstances: any;
  23982. batchCache: _InstancesBatch;
  23983. instancesBufferSize: number;
  23984. instancesBuffer: Nullable<Buffer>;
  23985. instancesData: Float32Array;
  23986. overridenInstanceCount: number;
  23987. isFrozen: boolean;
  23988. previousBatch: Nullable<_InstancesBatch>;
  23989. hardwareInstancedRendering: boolean;
  23990. sideOrientation: number;
  23991. manualUpdate: boolean;
  23992. }
  23993. /**
  23994. * @hidden
  23995. **/
  23996. export class _InstancesBatch {
  23997. mustReturn: boolean;
  23998. visibleInstances: Nullable<InstancedMesh[]>[];
  23999. renderSelf: boolean[];
  24000. hardwareInstancedRendering: boolean[];
  24001. }
  24002. /**
  24003. * Class used to represent renderable models
  24004. */
  24005. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24006. /**
  24007. * Mesh side orientation : usually the external or front surface
  24008. */
  24009. static readonly FRONTSIDE: number;
  24010. /**
  24011. * Mesh side orientation : usually the internal or back surface
  24012. */
  24013. static readonly BACKSIDE: number;
  24014. /**
  24015. * Mesh side orientation : both internal and external or front and back surfaces
  24016. */
  24017. static readonly DOUBLESIDE: number;
  24018. /**
  24019. * Mesh side orientation : by default, `FRONTSIDE`
  24020. */
  24021. static readonly DEFAULTSIDE: number;
  24022. /**
  24023. * Mesh cap setting : no cap
  24024. */
  24025. static readonly NO_CAP: number;
  24026. /**
  24027. * Mesh cap setting : one cap at the beginning of the mesh
  24028. */
  24029. static readonly CAP_START: number;
  24030. /**
  24031. * Mesh cap setting : one cap at the end of the mesh
  24032. */
  24033. static readonly CAP_END: number;
  24034. /**
  24035. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24036. */
  24037. static readonly CAP_ALL: number;
  24038. /**
  24039. * Mesh pattern setting : no flip or rotate
  24040. */
  24041. static readonly NO_FLIP: number;
  24042. /**
  24043. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24044. */
  24045. static readonly FLIP_TILE: number;
  24046. /**
  24047. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24048. */
  24049. static readonly ROTATE_TILE: number;
  24050. /**
  24051. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24052. */
  24053. static readonly FLIP_ROW: number;
  24054. /**
  24055. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24056. */
  24057. static readonly ROTATE_ROW: number;
  24058. /**
  24059. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24060. */
  24061. static readonly FLIP_N_ROTATE_TILE: number;
  24062. /**
  24063. * Mesh pattern setting : rotate pattern and rotate
  24064. */
  24065. static readonly FLIP_N_ROTATE_ROW: number;
  24066. /**
  24067. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24068. */
  24069. static readonly CENTER: number;
  24070. /**
  24071. * Mesh tile positioning : part tiles on left
  24072. */
  24073. static readonly LEFT: number;
  24074. /**
  24075. * Mesh tile positioning : part tiles on right
  24076. */
  24077. static readonly RIGHT: number;
  24078. /**
  24079. * Mesh tile positioning : part tiles on top
  24080. */
  24081. static readonly TOP: number;
  24082. /**
  24083. * Mesh tile positioning : part tiles on bottom
  24084. */
  24085. static readonly BOTTOM: number;
  24086. /**
  24087. * Gets the default side orientation.
  24088. * @param orientation the orientation to value to attempt to get
  24089. * @returns the default orientation
  24090. * @hidden
  24091. */
  24092. static _GetDefaultSideOrientation(orientation?: number): number;
  24093. private _internalMeshDataInfo;
  24094. /**
  24095. * An event triggered before rendering the mesh
  24096. */
  24097. get onBeforeRenderObservable(): Observable<Mesh>;
  24098. /**
  24099. * An event triggered before binding the mesh
  24100. */
  24101. get onBeforeBindObservable(): Observable<Mesh>;
  24102. /**
  24103. * An event triggered after rendering the mesh
  24104. */
  24105. get onAfterRenderObservable(): Observable<Mesh>;
  24106. /**
  24107. * An event triggered before drawing the mesh
  24108. */
  24109. get onBeforeDrawObservable(): Observable<Mesh>;
  24110. private _onBeforeDrawObserver;
  24111. /**
  24112. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24113. */
  24114. set onBeforeDraw(callback: () => void);
  24115. get hasInstances(): boolean;
  24116. /**
  24117. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24118. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24119. */
  24120. delayLoadState: number;
  24121. /**
  24122. * Gets the list of instances created from this mesh
  24123. * it is not supposed to be modified manually.
  24124. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24125. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24126. */
  24127. instances: InstancedMesh[];
  24128. /**
  24129. * Gets the file containing delay loading data for this mesh
  24130. */
  24131. delayLoadingFile: string;
  24132. /** @hidden */
  24133. _binaryInfo: any;
  24134. /**
  24135. * User defined function used to change how LOD level selection is done
  24136. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24137. */
  24138. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24139. /**
  24140. * Gets or sets the morph target manager
  24141. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24142. */
  24143. get morphTargetManager(): Nullable<MorphTargetManager>;
  24144. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24145. /** @hidden */
  24146. _creationDataStorage: Nullable<_CreationDataStorage>;
  24147. /** @hidden */
  24148. _geometry: Nullable<Geometry>;
  24149. /** @hidden */
  24150. _delayInfo: Array<string>;
  24151. /** @hidden */
  24152. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24153. /** @hidden */
  24154. _instanceDataStorage: _InstanceDataStorage;
  24155. private _effectiveMaterial;
  24156. /** @hidden */
  24157. _shouldGenerateFlatShading: boolean;
  24158. /** @hidden */
  24159. _originalBuilderSideOrientation: number;
  24160. /**
  24161. * Use this property to change the original side orientation defined at construction time
  24162. */
  24163. overrideMaterialSideOrientation: Nullable<number>;
  24164. /**
  24165. * Gets the source mesh (the one used to clone this one from)
  24166. */
  24167. get source(): Nullable<Mesh>;
  24168. /**
  24169. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24170. */
  24171. get isUnIndexed(): boolean;
  24172. set isUnIndexed(value: boolean);
  24173. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24174. get worldMatrixInstancedBuffer(): Float32Array;
  24175. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24176. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24177. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24178. /**
  24179. * @constructor
  24180. * @param name The value used by scene.getMeshByName() to do a lookup.
  24181. * @param scene The scene to add this mesh to.
  24182. * @param parent The parent of this mesh, if it has one
  24183. * @param source An optional Mesh from which geometry is shared, cloned.
  24184. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24185. * When false, achieved by calling a clone(), also passing False.
  24186. * This will make creation of children, recursive.
  24187. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24188. */
  24189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24190. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24191. doNotInstantiate: boolean;
  24192. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24193. /**
  24194. * Gets the class name
  24195. * @returns the string "Mesh".
  24196. */
  24197. getClassName(): string;
  24198. /** @hidden */
  24199. get _isMesh(): boolean;
  24200. /**
  24201. * Returns a description of this mesh
  24202. * @param fullDetails define if full details about this mesh must be used
  24203. * @returns a descriptive string representing this mesh
  24204. */
  24205. toString(fullDetails?: boolean): string;
  24206. /** @hidden */
  24207. _unBindEffect(): void;
  24208. /**
  24209. * Gets a boolean indicating if this mesh has LOD
  24210. */
  24211. get hasLODLevels(): boolean;
  24212. /**
  24213. * Gets the list of MeshLODLevel associated with the current mesh
  24214. * @returns an array of MeshLODLevel
  24215. */
  24216. getLODLevels(): MeshLODLevel[];
  24217. private _sortLODLevels;
  24218. /**
  24219. * Add a mesh as LOD level triggered at the given distance.
  24220. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24221. * @param distance The distance from the center of the object to show this level
  24222. * @param mesh The mesh to be added as LOD level (can be null)
  24223. * @return This mesh (for chaining)
  24224. */
  24225. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24226. /**
  24227. * Returns the LOD level mesh at the passed distance or null if not found.
  24228. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24229. * @param distance The distance from the center of the object to show this level
  24230. * @returns a Mesh or `null`
  24231. */
  24232. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24233. /**
  24234. * Remove a mesh from the LOD array
  24235. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24236. * @param mesh defines the mesh to be removed
  24237. * @return This mesh (for chaining)
  24238. */
  24239. removeLODLevel(mesh: Mesh): Mesh;
  24240. /**
  24241. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24242. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24243. * @param camera defines the camera to use to compute distance
  24244. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24245. * @return This mesh (for chaining)
  24246. */
  24247. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24248. /**
  24249. * Gets the mesh internal Geometry object
  24250. */
  24251. get geometry(): Nullable<Geometry>;
  24252. /**
  24253. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24254. * @returns the total number of vertices
  24255. */
  24256. getTotalVertices(): number;
  24257. /**
  24258. * Returns the content of an associated vertex buffer
  24259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24260. * - VertexBuffer.PositionKind
  24261. * - VertexBuffer.UVKind
  24262. * - VertexBuffer.UV2Kind
  24263. * - VertexBuffer.UV3Kind
  24264. * - VertexBuffer.UV4Kind
  24265. * - VertexBuffer.UV5Kind
  24266. * - VertexBuffer.UV6Kind
  24267. * - VertexBuffer.ColorKind
  24268. * - VertexBuffer.MatricesIndicesKind
  24269. * - VertexBuffer.MatricesIndicesExtraKind
  24270. * - VertexBuffer.MatricesWeightsKind
  24271. * - VertexBuffer.MatricesWeightsExtraKind
  24272. * @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
  24273. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24274. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24275. */
  24276. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24277. /**
  24278. * Returns the mesh VertexBuffer object from the requested `kind`
  24279. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24280. * - VertexBuffer.PositionKind
  24281. * - VertexBuffer.NormalKind
  24282. * - VertexBuffer.UVKind
  24283. * - VertexBuffer.UV2Kind
  24284. * - VertexBuffer.UV3Kind
  24285. * - VertexBuffer.UV4Kind
  24286. * - VertexBuffer.UV5Kind
  24287. * - VertexBuffer.UV6Kind
  24288. * - VertexBuffer.ColorKind
  24289. * - VertexBuffer.MatricesIndicesKind
  24290. * - VertexBuffer.MatricesIndicesExtraKind
  24291. * - VertexBuffer.MatricesWeightsKind
  24292. * - VertexBuffer.MatricesWeightsExtraKind
  24293. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24294. */
  24295. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24296. /**
  24297. * Tests if a specific vertex buffer is associated with this mesh
  24298. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24299. * - VertexBuffer.PositionKind
  24300. * - VertexBuffer.NormalKind
  24301. * - VertexBuffer.UVKind
  24302. * - VertexBuffer.UV2Kind
  24303. * - VertexBuffer.UV3Kind
  24304. * - VertexBuffer.UV4Kind
  24305. * - VertexBuffer.UV5Kind
  24306. * - VertexBuffer.UV6Kind
  24307. * - VertexBuffer.ColorKind
  24308. * - VertexBuffer.MatricesIndicesKind
  24309. * - VertexBuffer.MatricesIndicesExtraKind
  24310. * - VertexBuffer.MatricesWeightsKind
  24311. * - VertexBuffer.MatricesWeightsExtraKind
  24312. * @returns a boolean
  24313. */
  24314. isVerticesDataPresent(kind: string): boolean;
  24315. /**
  24316. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24317. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24318. * - VertexBuffer.PositionKind
  24319. * - VertexBuffer.UVKind
  24320. * - VertexBuffer.UV2Kind
  24321. * - VertexBuffer.UV3Kind
  24322. * - VertexBuffer.UV4Kind
  24323. * - VertexBuffer.UV5Kind
  24324. * - VertexBuffer.UV6Kind
  24325. * - VertexBuffer.ColorKind
  24326. * - VertexBuffer.MatricesIndicesKind
  24327. * - VertexBuffer.MatricesIndicesExtraKind
  24328. * - VertexBuffer.MatricesWeightsKind
  24329. * - VertexBuffer.MatricesWeightsExtraKind
  24330. * @returns a boolean
  24331. */
  24332. isVertexBufferUpdatable(kind: string): boolean;
  24333. /**
  24334. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24335. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24336. * - VertexBuffer.PositionKind
  24337. * - VertexBuffer.NormalKind
  24338. * - VertexBuffer.UVKind
  24339. * - VertexBuffer.UV2Kind
  24340. * - VertexBuffer.UV3Kind
  24341. * - VertexBuffer.UV4Kind
  24342. * - VertexBuffer.UV5Kind
  24343. * - VertexBuffer.UV6Kind
  24344. * - VertexBuffer.ColorKind
  24345. * - VertexBuffer.MatricesIndicesKind
  24346. * - VertexBuffer.MatricesIndicesExtraKind
  24347. * - VertexBuffer.MatricesWeightsKind
  24348. * - VertexBuffer.MatricesWeightsExtraKind
  24349. * @returns an array of strings
  24350. */
  24351. getVerticesDataKinds(): string[];
  24352. /**
  24353. * Returns a positive integer : the total number of indices in this mesh geometry.
  24354. * @returns the numner of indices or zero if the mesh has no geometry.
  24355. */
  24356. getTotalIndices(): number;
  24357. /**
  24358. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24359. * @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.
  24360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24361. * @returns the indices array or an empty array if the mesh has no geometry
  24362. */
  24363. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24364. get isBlocked(): boolean;
  24365. /**
  24366. * Determine if the current mesh is ready to be rendered
  24367. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24368. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24369. * @returns true if all associated assets are ready (material, textures, shaders)
  24370. */
  24371. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24372. /**
  24373. * 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.
  24374. */
  24375. get areNormalsFrozen(): boolean;
  24376. /**
  24377. * 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.
  24378. * @returns the current mesh
  24379. */
  24380. freezeNormals(): Mesh;
  24381. /**
  24382. * 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
  24383. * @returns the current mesh
  24384. */
  24385. unfreezeNormals(): Mesh;
  24386. /**
  24387. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24388. */
  24389. set overridenInstanceCount(count: number);
  24390. /** @hidden */
  24391. _preActivate(): Mesh;
  24392. /** @hidden */
  24393. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24394. /** @hidden */
  24395. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24396. /**
  24397. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24398. * This means the mesh underlying bounding box and sphere are recomputed.
  24399. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24400. * @returns the current mesh
  24401. */
  24402. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24403. /** @hidden */
  24404. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24405. /**
  24406. * This function will subdivide the mesh into multiple submeshes
  24407. * @param count defines the expected number of submeshes
  24408. */
  24409. subdivide(count: number): void;
  24410. /**
  24411. * Copy a FloatArray into a specific associated vertex buffer
  24412. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24413. * - VertexBuffer.PositionKind
  24414. * - VertexBuffer.UVKind
  24415. * - VertexBuffer.UV2Kind
  24416. * - VertexBuffer.UV3Kind
  24417. * - VertexBuffer.UV4Kind
  24418. * - VertexBuffer.UV5Kind
  24419. * - VertexBuffer.UV6Kind
  24420. * - VertexBuffer.ColorKind
  24421. * - VertexBuffer.MatricesIndicesKind
  24422. * - VertexBuffer.MatricesIndicesExtraKind
  24423. * - VertexBuffer.MatricesWeightsKind
  24424. * - VertexBuffer.MatricesWeightsExtraKind
  24425. * @param data defines the data source
  24426. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24427. * @param stride defines the data stride size (can be null)
  24428. * @returns the current mesh
  24429. */
  24430. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24431. /**
  24432. * Delete a vertex buffer associated with this mesh
  24433. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24434. * - VertexBuffer.PositionKind
  24435. * - VertexBuffer.UVKind
  24436. * - VertexBuffer.UV2Kind
  24437. * - VertexBuffer.UV3Kind
  24438. * - VertexBuffer.UV4Kind
  24439. * - VertexBuffer.UV5Kind
  24440. * - VertexBuffer.UV6Kind
  24441. * - VertexBuffer.ColorKind
  24442. * - VertexBuffer.MatricesIndicesKind
  24443. * - VertexBuffer.MatricesIndicesExtraKind
  24444. * - VertexBuffer.MatricesWeightsKind
  24445. * - VertexBuffer.MatricesWeightsExtraKind
  24446. */
  24447. removeVerticesData(kind: string): void;
  24448. /**
  24449. * Flags an associated vertex buffer as updatable
  24450. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24451. * - VertexBuffer.PositionKind
  24452. * - VertexBuffer.UVKind
  24453. * - VertexBuffer.UV2Kind
  24454. * - VertexBuffer.UV3Kind
  24455. * - VertexBuffer.UV4Kind
  24456. * - VertexBuffer.UV5Kind
  24457. * - VertexBuffer.UV6Kind
  24458. * - VertexBuffer.ColorKind
  24459. * - VertexBuffer.MatricesIndicesKind
  24460. * - VertexBuffer.MatricesIndicesExtraKind
  24461. * - VertexBuffer.MatricesWeightsKind
  24462. * - VertexBuffer.MatricesWeightsExtraKind
  24463. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24464. */
  24465. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24466. /**
  24467. * Sets the mesh global Vertex Buffer
  24468. * @param buffer defines the buffer to use
  24469. * @returns the current mesh
  24470. */
  24471. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24472. /**
  24473. * Update a specific associated vertex buffer
  24474. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24475. * - VertexBuffer.PositionKind
  24476. * - VertexBuffer.UVKind
  24477. * - VertexBuffer.UV2Kind
  24478. * - VertexBuffer.UV3Kind
  24479. * - VertexBuffer.UV4Kind
  24480. * - VertexBuffer.UV5Kind
  24481. * - VertexBuffer.UV6Kind
  24482. * - VertexBuffer.ColorKind
  24483. * - VertexBuffer.MatricesIndicesKind
  24484. * - VertexBuffer.MatricesIndicesExtraKind
  24485. * - VertexBuffer.MatricesWeightsKind
  24486. * - VertexBuffer.MatricesWeightsExtraKind
  24487. * @param data defines the data source
  24488. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24489. * @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)
  24490. * @returns the current mesh
  24491. */
  24492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24493. /**
  24494. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24495. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24496. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24497. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24498. * @returns the current mesh
  24499. */
  24500. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24501. /**
  24502. * Creates a un-shared specific occurence of the geometry for the mesh.
  24503. * @returns the current mesh
  24504. */
  24505. makeGeometryUnique(): Mesh;
  24506. /**
  24507. * Set the index buffer of this mesh
  24508. * @param indices defines the source data
  24509. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24510. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24511. * @returns the current mesh
  24512. */
  24513. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24514. /**
  24515. * Update the current index buffer
  24516. * @param indices defines the source data
  24517. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24518. * @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)
  24519. * @returns the current mesh
  24520. */
  24521. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24522. /**
  24523. * Invert the geometry to move from a right handed system to a left handed one.
  24524. * @returns the current mesh
  24525. */
  24526. toLeftHanded(): Mesh;
  24527. /** @hidden */
  24528. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24529. /** @hidden */
  24530. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24531. /**
  24532. * Registers for this mesh a javascript function called just before the rendering process
  24533. * @param func defines the function to call before rendering this mesh
  24534. * @returns the current mesh
  24535. */
  24536. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24537. /**
  24538. * Disposes a previously registered javascript function called before the rendering
  24539. * @param func defines the function to remove
  24540. * @returns the current mesh
  24541. */
  24542. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24543. /**
  24544. * Registers for this mesh a javascript function called just after the rendering is complete
  24545. * @param func defines the function to call after rendering this mesh
  24546. * @returns the current mesh
  24547. */
  24548. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24549. /**
  24550. * Disposes a previously registered javascript function called after the rendering.
  24551. * @param func defines the function to remove
  24552. * @returns the current mesh
  24553. */
  24554. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24555. /** @hidden */
  24556. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24557. /** @hidden */
  24558. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24559. /** @hidden */
  24560. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24561. /** @hidden */
  24562. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24563. /** @hidden */
  24564. _rebuild(): void;
  24565. /** @hidden */
  24566. _freeze(): void;
  24567. /** @hidden */
  24568. _unFreeze(): void;
  24569. /**
  24570. * 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
  24571. * @param subMesh defines the subMesh to render
  24572. * @param enableAlphaMode defines if alpha mode can be changed
  24573. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24574. * @returns the current mesh
  24575. */
  24576. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24577. private _onBeforeDraw;
  24578. /**
  24579. * Renormalize the mesh and patch it up if there are no weights
  24580. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24581. * However in the case of zero weights then we set just a single influence to 1.
  24582. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24583. */
  24584. cleanMatrixWeights(): void;
  24585. private normalizeSkinFourWeights;
  24586. private normalizeSkinWeightsAndExtra;
  24587. /**
  24588. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24589. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24590. * the user know there was an issue with importing the mesh
  24591. * @returns a validation object with skinned, valid and report string
  24592. */
  24593. validateSkinning(): {
  24594. skinned: boolean;
  24595. valid: boolean;
  24596. report: string;
  24597. };
  24598. /** @hidden */
  24599. _checkDelayState(): Mesh;
  24600. private _queueLoad;
  24601. /**
  24602. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24603. * A mesh is in the frustum if its bounding box intersects the frustum
  24604. * @param frustumPlanes defines the frustum to test
  24605. * @returns true if the mesh is in the frustum planes
  24606. */
  24607. isInFrustum(frustumPlanes: Plane[]): boolean;
  24608. /**
  24609. * Sets the mesh material by the material or multiMaterial `id` property
  24610. * @param id is a string identifying the material or the multiMaterial
  24611. * @returns the current mesh
  24612. */
  24613. setMaterialByID(id: string): Mesh;
  24614. /**
  24615. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24616. * @returns an array of IAnimatable
  24617. */
  24618. getAnimatables(): IAnimatable[];
  24619. /**
  24620. * Modifies the mesh geometry according to the passed transformation matrix.
  24621. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24622. * The mesh normals are modified using the same transformation.
  24623. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24624. * @param transform defines the transform matrix to use
  24625. * @see http://doc.babylonjs.com/resources/baking_transformations
  24626. * @returns the current mesh
  24627. */
  24628. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24629. /**
  24630. * Modifies the mesh geometry according to its own current World Matrix.
  24631. * The mesh World Matrix is then reset.
  24632. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24633. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24634. * @see http://doc.babylonjs.com/resources/baking_transformations
  24635. * @returns the current mesh
  24636. */
  24637. bakeCurrentTransformIntoVertices(): Mesh;
  24638. /** @hidden */
  24639. get _positions(): Nullable<Vector3[]>;
  24640. /** @hidden */
  24641. _resetPointsArrayCache(): Mesh;
  24642. /** @hidden */
  24643. _generatePointsArray(): boolean;
  24644. /**
  24645. * Returns a new Mesh object generated from the current mesh properties.
  24646. * This method must not get confused with createInstance()
  24647. * @param name is a string, the name given to the new mesh
  24648. * @param newParent can be any Node object (default `null`)
  24649. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24650. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24651. * @returns a new mesh
  24652. */
  24653. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24654. /**
  24655. * Releases resources associated with this mesh.
  24656. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24657. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24658. */
  24659. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24660. /** @hidden */
  24661. _disposeInstanceSpecificData(): void;
  24662. /**
  24663. * Modifies the mesh geometry according to a displacement map.
  24664. * 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.
  24665. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24666. * @param url is a string, the URL from the image file is to be downloaded.
  24667. * @param minHeight is the lower limit of the displacement.
  24668. * @param maxHeight is the upper limit of the displacement.
  24669. * @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.
  24670. * @param uvOffset is an optional vector2 used to offset UV.
  24671. * @param uvScale is an optional vector2 used to scale UV.
  24672. * @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.
  24673. * @returns the Mesh.
  24674. */
  24675. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24676. /**
  24677. * Modifies the mesh geometry according to a displacementMap buffer.
  24678. * 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.
  24679. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24680. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24681. * @param heightMapWidth is the width of the buffer image.
  24682. * @param heightMapHeight is the height of the buffer image.
  24683. * @param minHeight is the lower limit of the displacement.
  24684. * @param maxHeight is the upper limit of the displacement.
  24685. * @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.
  24686. * @param uvOffset is an optional vector2 used to offset UV.
  24687. * @param uvScale is an optional vector2 used to scale UV.
  24688. * @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.
  24689. * @returns the Mesh.
  24690. */
  24691. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24692. /**
  24693. * Modify the mesh to get a flat shading rendering.
  24694. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24695. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24696. * @returns current mesh
  24697. */
  24698. convertToFlatShadedMesh(): Mesh;
  24699. /**
  24700. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24701. * In other words, more vertices, no more indices and a single bigger VBO.
  24702. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24703. * @returns current mesh
  24704. */
  24705. convertToUnIndexedMesh(): Mesh;
  24706. /**
  24707. * Inverses facet orientations.
  24708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24709. * @param flipNormals will also inverts the normals
  24710. * @returns current mesh
  24711. */
  24712. flipFaces(flipNormals?: boolean): Mesh;
  24713. /**
  24714. * Increase the number of facets and hence vertices in a mesh
  24715. * Vertex normals are interpolated from existing vertex normals
  24716. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24717. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24718. */
  24719. increaseVertices(numberPerEdge: number): void;
  24720. /**
  24721. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24722. * This will undo any application of covertToFlatShadedMesh
  24723. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24724. */
  24725. forceSharedVertices(): void;
  24726. /** @hidden */
  24727. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24728. /** @hidden */
  24729. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24730. /**
  24731. * Creates a new InstancedMesh object from the mesh model.
  24732. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24733. * @param name defines the name of the new instance
  24734. * @returns a new InstancedMesh
  24735. */
  24736. createInstance(name: string): InstancedMesh;
  24737. /**
  24738. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24739. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24740. * @returns the current mesh
  24741. */
  24742. synchronizeInstances(): Mesh;
  24743. /**
  24744. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24745. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24746. * This should be used together with the simplification to avoid disappearing triangles.
  24747. * @param successCallback an optional success callback to be called after the optimization finished.
  24748. * @returns the current mesh
  24749. */
  24750. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24751. /**
  24752. * Serialize current mesh
  24753. * @param serializationObject defines the object which will receive the serialization data
  24754. */
  24755. serialize(serializationObject: any): void;
  24756. /** @hidden */
  24757. _syncGeometryWithMorphTargetManager(): void;
  24758. /** @hidden */
  24759. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24760. /**
  24761. * Returns a new Mesh object parsed from the source provided.
  24762. * @param parsedMesh is the source
  24763. * @param scene defines the hosting scene
  24764. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24765. * @returns a new Mesh
  24766. */
  24767. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24768. /**
  24769. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24770. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24771. * @param name defines the name of the mesh to create
  24772. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24773. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24774. * @param closePath creates a seam between the first and the last points of each path of the path array
  24775. * @param offset is taken in account only if the `pathArray` is containing a single path
  24776. * @param scene defines the hosting scene
  24777. * @param updatable defines if the mesh must be flagged as updatable
  24778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24779. * @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)
  24780. * @returns a new Mesh
  24781. */
  24782. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24783. /**
  24784. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24785. * @param name defines the name of the mesh to create
  24786. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24787. * @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
  24788. * @param scene defines the hosting scene
  24789. * @param updatable defines if the mesh must be flagged as updatable
  24790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24791. * @returns a new Mesh
  24792. */
  24793. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24794. /**
  24795. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24796. * @param name defines the name of the mesh to create
  24797. * @param size sets the size (float) of each box side (default 1)
  24798. * @param scene defines the hosting scene
  24799. * @param updatable defines if the mesh must be flagged as updatable
  24800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24801. * @returns a new Mesh
  24802. */
  24803. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24804. /**
  24805. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24806. * @param name defines the name of the mesh to create
  24807. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24808. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24809. * @param scene defines the hosting scene
  24810. * @param updatable defines if the mesh must be flagged as updatable
  24811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24812. * @returns a new Mesh
  24813. */
  24814. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24815. /**
  24816. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24817. * @param name defines the name of the mesh to create
  24818. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24819. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24820. * @param scene defines the hosting scene
  24821. * @returns a new Mesh
  24822. */
  24823. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24824. /**
  24825. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24826. * @param name defines the name of the mesh to create
  24827. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24828. * @param diameterTop set the top cap diameter (floats, default 1)
  24829. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24830. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24831. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24832. * @param scene defines the hosting scene
  24833. * @param updatable defines if the mesh must be flagged as updatable
  24834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24835. * @returns a new Mesh
  24836. */
  24837. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24838. /**
  24839. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24840. * @param name defines the name of the mesh to create
  24841. * @param diameter sets the diameter size (float) of the torus (default 1)
  24842. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24843. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24844. * @param scene defines the hosting scene
  24845. * @param updatable defines if the mesh must be flagged as updatable
  24846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24847. * @returns a new Mesh
  24848. */
  24849. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24850. /**
  24851. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24852. * @param name defines the name of the mesh to create
  24853. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24854. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24855. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24856. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24857. * @param p the number of windings on X axis (positive integers, default 2)
  24858. * @param q the number of windings on Y axis (positive integers, default 3)
  24859. * @param scene defines the hosting scene
  24860. * @param updatable defines if the mesh must be flagged as updatable
  24861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24862. * @returns a new Mesh
  24863. */
  24864. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24865. /**
  24866. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24867. * @param name defines the name of the mesh to create
  24868. * @param points is an array successive Vector3
  24869. * @param scene defines the hosting scene
  24870. * @param updatable defines if the mesh must be flagged as updatable
  24871. * @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).
  24872. * @returns a new Mesh
  24873. */
  24874. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24875. /**
  24876. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24877. * @param name defines the name of the mesh to create
  24878. * @param points is an array successive Vector3
  24879. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24880. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24881. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24882. * @param scene defines the hosting scene
  24883. * @param updatable defines if the mesh must be flagged as updatable
  24884. * @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)
  24885. * @returns a new Mesh
  24886. */
  24887. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24888. /**
  24889. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24890. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24891. * 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.
  24892. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24893. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24894. * Remember you can only change the shape positions, not their number when updating a polygon.
  24895. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24896. * @param name defines the name of the mesh to create
  24897. * @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
  24898. * @param scene defines the hosting scene
  24899. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24900. * @param updatable defines if the mesh must be flagged as updatable
  24901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24902. * @param earcutInjection can be used to inject your own earcut reference
  24903. * @returns a new Mesh
  24904. */
  24905. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24906. /**
  24907. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24908. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24909. * @param name defines the name of the mesh to create
  24910. * @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
  24911. * @param depth defines the height of extrusion
  24912. * @param scene defines the hosting scene
  24913. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24914. * @param updatable defines if the mesh must be flagged as updatable
  24915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24916. * @param earcutInjection can be used to inject your own earcut reference
  24917. * @returns a new Mesh
  24918. */
  24919. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24920. /**
  24921. * Creates an extruded shape mesh.
  24922. * 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
  24923. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24924. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24925. * @param name defines the name of the mesh to create
  24926. * @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
  24927. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24928. * @param scale is the value to scale the shape
  24929. * @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
  24930. * @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
  24931. * @param scene defines the hosting scene
  24932. * @param updatable defines if the mesh must be flagged as updatable
  24933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24934. * @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)
  24935. * @returns a new Mesh
  24936. */
  24937. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24938. /**
  24939. * Creates an custom extruded shape mesh.
  24940. * The custom extrusion is a parametric shape.
  24941. * It has no predefined shape. Its final shape will depend on the input parameters.
  24942. * Please consider using the same method from the MeshBuilder class instead
  24943. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24944. * @param name defines the name of the mesh to create
  24945. * @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
  24946. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24947. * @param scaleFunction is a custom Javascript function called on each path point
  24948. * @param rotationFunction is a custom Javascript function called on each path point
  24949. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24950. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24951. * @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
  24952. * @param scene defines the hosting scene
  24953. * @param updatable defines if the mesh must be flagged as updatable
  24954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24955. * @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)
  24956. * @returns a new Mesh
  24957. */
  24958. 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;
  24959. /**
  24960. * Creates lathe mesh.
  24961. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24962. * Please consider using the same method from the MeshBuilder class instead
  24963. * @param name defines the name of the mesh to create
  24964. * @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
  24965. * @param radius is the radius value of the lathe
  24966. * @param tessellation is the side number of the lathe.
  24967. * @param scene defines the hosting scene
  24968. * @param updatable defines if the mesh must be flagged as updatable
  24969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24970. * @returns a new Mesh
  24971. */
  24972. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24973. /**
  24974. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24975. * @param name defines the name of the mesh to create
  24976. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24977. * @param scene defines the hosting scene
  24978. * @param updatable defines if the mesh must be flagged as updatable
  24979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24980. * @returns a new Mesh
  24981. */
  24982. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24983. /**
  24984. * Creates a ground mesh.
  24985. * Please consider using the same method from the MeshBuilder class instead
  24986. * @param name defines the name of the mesh to create
  24987. * @param width set the width of the ground
  24988. * @param height set the height of the ground
  24989. * @param subdivisions sets the number of subdivisions per side
  24990. * @param scene defines the hosting scene
  24991. * @param updatable defines if the mesh must be flagged as updatable
  24992. * @returns a new Mesh
  24993. */
  24994. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24995. /**
  24996. * Creates a tiled ground mesh.
  24997. * Please consider using the same method from the MeshBuilder class instead
  24998. * @param name defines the name of the mesh to create
  24999. * @param xmin set the ground minimum X coordinate
  25000. * @param zmin set the ground minimum Y coordinate
  25001. * @param xmax set the ground maximum X coordinate
  25002. * @param zmax set the ground maximum Z coordinate
  25003. * @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
  25004. * @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
  25005. * @param scene defines the hosting scene
  25006. * @param updatable defines if the mesh must be flagged as updatable
  25007. * @returns a new Mesh
  25008. */
  25009. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25010. w: number;
  25011. h: number;
  25012. }, precision: {
  25013. w: number;
  25014. h: number;
  25015. }, scene: Scene, updatable?: boolean): Mesh;
  25016. /**
  25017. * Creates a ground mesh from a height map.
  25018. * Please consider using the same method from the MeshBuilder class instead
  25019. * @see http://doc.babylonjs.com/babylon101/height_map
  25020. * @param name defines the name of the mesh to create
  25021. * @param url sets the URL of the height map image resource
  25022. * @param width set the ground width size
  25023. * @param height set the ground height size
  25024. * @param subdivisions sets the number of subdivision per side
  25025. * @param minHeight is the minimum altitude on the ground
  25026. * @param maxHeight is the maximum altitude on the ground
  25027. * @param scene defines the hosting scene
  25028. * @param updatable defines if the mesh must be flagged as updatable
  25029. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25030. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25031. * @returns a new Mesh
  25032. */
  25033. 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;
  25034. /**
  25035. * Creates a tube mesh.
  25036. * The tube is a parametric shape.
  25037. * It has no predefined shape. Its final shape will depend on the input parameters.
  25038. * Please consider using the same method from the MeshBuilder class instead
  25039. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25040. * @param name defines the name of the mesh to create
  25041. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25042. * @param radius sets the tube radius size
  25043. * @param tessellation is the number of sides on the tubular surface
  25044. * @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
  25045. * @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
  25046. * @param scene defines the hosting scene
  25047. * @param updatable defines if the mesh must be flagged as updatable
  25048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25049. * @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)
  25050. * @returns a new Mesh
  25051. */
  25052. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25053. (i: number, distance: number): number;
  25054. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25055. /**
  25056. * Creates a polyhedron mesh.
  25057. * Please consider using the same method from the MeshBuilder class instead.
  25058. * * 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
  25059. * * The parameter `size` (positive float, default 1) sets the polygon size
  25060. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25061. * * 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`
  25062. * * 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
  25063. * * 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)`)
  25064. * * 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
  25065. * * 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
  25066. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25067. * * 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
  25068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25069. * @param name defines the name of the mesh to create
  25070. * @param options defines the options used to create the mesh
  25071. * @param scene defines the hosting scene
  25072. * @returns a new Mesh
  25073. */
  25074. static CreatePolyhedron(name: string, options: {
  25075. type?: number;
  25076. size?: number;
  25077. sizeX?: number;
  25078. sizeY?: number;
  25079. sizeZ?: number;
  25080. custom?: any;
  25081. faceUV?: Vector4[];
  25082. faceColors?: Color4[];
  25083. updatable?: boolean;
  25084. sideOrientation?: number;
  25085. }, scene: Scene): Mesh;
  25086. /**
  25087. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25088. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25089. * * 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`)
  25090. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25091. * * 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
  25092. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25093. * * 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
  25094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25095. * @param name defines the name of the mesh
  25096. * @param options defines the options used to create the mesh
  25097. * @param scene defines the hosting scene
  25098. * @returns a new Mesh
  25099. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25100. */
  25101. static CreateIcoSphere(name: string, options: {
  25102. radius?: number;
  25103. flat?: boolean;
  25104. subdivisions?: number;
  25105. sideOrientation?: number;
  25106. updatable?: boolean;
  25107. }, scene: Scene): Mesh;
  25108. /**
  25109. * Creates a decal mesh.
  25110. * Please consider using the same method from the MeshBuilder class instead.
  25111. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25112. * @param name defines the name of the mesh
  25113. * @param sourceMesh defines the mesh receiving the decal
  25114. * @param position sets the position of the decal in world coordinates
  25115. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25116. * @param size sets the decal scaling
  25117. * @param angle sets the angle to rotate the decal
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25121. /**
  25122. * Prepare internal position array for software CPU skinning
  25123. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25124. */
  25125. setPositionsForCPUSkinning(): Float32Array;
  25126. /**
  25127. * Prepare internal normal array for software CPU skinning
  25128. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25129. */
  25130. setNormalsForCPUSkinning(): Float32Array;
  25131. /**
  25132. * Updates the vertex buffer by applying transformation from the bones
  25133. * @param skeleton defines the skeleton to apply to current mesh
  25134. * @returns the current mesh
  25135. */
  25136. applySkeleton(skeleton: Skeleton): Mesh;
  25137. /**
  25138. * 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
  25139. * @param meshes defines the list of meshes to scan
  25140. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25141. */
  25142. static MinMax(meshes: AbstractMesh[]): {
  25143. min: Vector3;
  25144. max: Vector3;
  25145. };
  25146. /**
  25147. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25148. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25149. * @returns a vector3
  25150. */
  25151. static Center(meshesOrMinMaxVector: {
  25152. min: Vector3;
  25153. max: Vector3;
  25154. } | AbstractMesh[]): Vector3;
  25155. /**
  25156. * Merge the array of meshes into a single mesh for performance reasons.
  25157. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25158. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25159. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25160. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25161. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25162. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25163. * @returns a new mesh
  25164. */
  25165. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25166. /** @hidden */
  25167. addInstance(instance: InstancedMesh): void;
  25168. /** @hidden */
  25169. removeInstance(instance: InstancedMesh): void;
  25170. }
  25171. }
  25172. declare module BABYLON {
  25173. /**
  25174. * This is the base class of all the camera used in the application.
  25175. * @see http://doc.babylonjs.com/features/cameras
  25176. */
  25177. export class Camera extends Node {
  25178. /** @hidden */
  25179. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25180. /**
  25181. * This is the default projection mode used by the cameras.
  25182. * It helps recreating a feeling of perspective and better appreciate depth.
  25183. * This is the best way to simulate real life cameras.
  25184. */
  25185. static readonly PERSPECTIVE_CAMERA: number;
  25186. /**
  25187. * This helps creating camera with an orthographic mode.
  25188. * 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.
  25189. */
  25190. static readonly ORTHOGRAPHIC_CAMERA: number;
  25191. /**
  25192. * This is the default FOV mode for perspective cameras.
  25193. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25194. */
  25195. static readonly FOVMODE_VERTICAL_FIXED: number;
  25196. /**
  25197. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25198. */
  25199. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25200. /**
  25201. * This specifies ther is no need for a camera rig.
  25202. * Basically only one eye is rendered corresponding to the camera.
  25203. */
  25204. static readonly RIG_MODE_NONE: number;
  25205. /**
  25206. * Simulates a camera Rig with one blue eye and one red eye.
  25207. * This can be use with 3d blue and red glasses.
  25208. */
  25209. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25210. /**
  25211. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25212. */
  25213. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25214. /**
  25215. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25216. */
  25217. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25218. /**
  25219. * Defines that both eyes of the camera will be rendered over under each other.
  25220. */
  25221. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25222. /**
  25223. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25224. */
  25225. static readonly RIG_MODE_VR: number;
  25226. /**
  25227. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25228. */
  25229. static readonly RIG_MODE_WEBVR: number;
  25230. /**
  25231. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25232. */
  25233. static readonly RIG_MODE_CUSTOM: number;
  25234. /**
  25235. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25236. */
  25237. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25238. /**
  25239. * Define the input manager associated with the camera.
  25240. */
  25241. inputs: CameraInputsManager<Camera>;
  25242. /** @hidden */
  25243. _position: Vector3;
  25244. /**
  25245. * Define the current local position of the camera in the scene
  25246. */
  25247. get position(): Vector3;
  25248. set position(newPosition: Vector3);
  25249. /**
  25250. * The vector the camera should consider as up.
  25251. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25252. */
  25253. upVector: Vector3;
  25254. /**
  25255. * Define the current limit on the left side for an orthographic camera
  25256. * In scene unit
  25257. */
  25258. orthoLeft: Nullable<number>;
  25259. /**
  25260. * Define the current limit on the right side for an orthographic camera
  25261. * In scene unit
  25262. */
  25263. orthoRight: Nullable<number>;
  25264. /**
  25265. * Define the current limit on the bottom side for an orthographic camera
  25266. * In scene unit
  25267. */
  25268. orthoBottom: Nullable<number>;
  25269. /**
  25270. * Define the current limit on the top side for an orthographic camera
  25271. * In scene unit
  25272. */
  25273. orthoTop: Nullable<number>;
  25274. /**
  25275. * Field Of View is set in Radians. (default is 0.8)
  25276. */
  25277. fov: number;
  25278. /**
  25279. * Define the minimum distance the camera can see from.
  25280. * This is important to note that the depth buffer are not infinite and the closer it starts
  25281. * the more your scene might encounter depth fighting issue.
  25282. */
  25283. minZ: number;
  25284. /**
  25285. * Define the maximum distance the camera can see to.
  25286. * This is important to note that the depth buffer are not infinite and the further it end
  25287. * the more your scene might encounter depth fighting issue.
  25288. */
  25289. maxZ: number;
  25290. /**
  25291. * Define the default inertia of the camera.
  25292. * This helps giving a smooth feeling to the camera movement.
  25293. */
  25294. inertia: number;
  25295. /**
  25296. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25297. */
  25298. mode: number;
  25299. /**
  25300. * Define wether the camera is intermediate.
  25301. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25302. */
  25303. isIntermediate: boolean;
  25304. /**
  25305. * Define the viewport of the camera.
  25306. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25307. */
  25308. viewport: Viewport;
  25309. /**
  25310. * Restricts the camera to viewing objects with the same layerMask.
  25311. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25312. */
  25313. layerMask: number;
  25314. /**
  25315. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25316. */
  25317. fovMode: number;
  25318. /**
  25319. * Rig mode of the camera.
  25320. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25321. * This is normally controlled byt the camera themselves as internal use.
  25322. */
  25323. cameraRigMode: number;
  25324. /**
  25325. * Defines the distance between both "eyes" in case of a RIG
  25326. */
  25327. interaxialDistance: number;
  25328. /**
  25329. * Defines if stereoscopic rendering is done side by side or over under.
  25330. */
  25331. isStereoscopicSideBySide: boolean;
  25332. /**
  25333. * 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
  25334. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25335. * else in the scene. (Eg. security camera)
  25336. *
  25337. * 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)
  25338. */
  25339. customRenderTargets: RenderTargetTexture[];
  25340. /**
  25341. * When set, the camera will render to this render target instead of the default canvas
  25342. *
  25343. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25344. */
  25345. outputRenderTarget: Nullable<RenderTargetTexture>;
  25346. /**
  25347. * Observable triggered when the camera view matrix has changed.
  25348. */
  25349. onViewMatrixChangedObservable: Observable<Camera>;
  25350. /**
  25351. * Observable triggered when the camera Projection matrix has changed.
  25352. */
  25353. onProjectionMatrixChangedObservable: Observable<Camera>;
  25354. /**
  25355. * Observable triggered when the inputs have been processed.
  25356. */
  25357. onAfterCheckInputsObservable: Observable<Camera>;
  25358. /**
  25359. * Observable triggered when reset has been called and applied to the camera.
  25360. */
  25361. onRestoreStateObservable: Observable<Camera>;
  25362. /** @hidden */
  25363. _cameraRigParams: any;
  25364. /** @hidden */
  25365. _rigCameras: Camera[];
  25366. /** @hidden */
  25367. _rigPostProcess: Nullable<PostProcess>;
  25368. protected _webvrViewMatrix: Matrix;
  25369. /** @hidden */
  25370. _skipRendering: boolean;
  25371. /** @hidden */
  25372. _projectionMatrix: Matrix;
  25373. /** @hidden */
  25374. _postProcesses: Nullable<PostProcess>[];
  25375. /** @hidden */
  25376. _activeMeshes: SmartArray<AbstractMesh>;
  25377. protected _globalPosition: Vector3;
  25378. /** @hidden */
  25379. _computedViewMatrix: Matrix;
  25380. private _doNotComputeProjectionMatrix;
  25381. private _transformMatrix;
  25382. private _frustumPlanes;
  25383. private _refreshFrustumPlanes;
  25384. private _storedFov;
  25385. private _stateStored;
  25386. /**
  25387. * Instantiates a new camera object.
  25388. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25389. * @see http://doc.babylonjs.com/features/cameras
  25390. * @param name Defines the name of the camera in the scene
  25391. * @param position Defines the position of the camera
  25392. * @param scene Defines the scene the camera belongs too
  25393. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25394. */
  25395. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25396. /**
  25397. * Store current camera state (fov, position, etc..)
  25398. * @returns the camera
  25399. */
  25400. storeState(): Camera;
  25401. /**
  25402. * Restores the camera state values if it has been stored. You must call storeState() first
  25403. */
  25404. protected _restoreStateValues(): boolean;
  25405. /**
  25406. * Restored camera state. You must call storeState() first.
  25407. * @returns true if restored and false otherwise
  25408. */
  25409. restoreState(): boolean;
  25410. /**
  25411. * Gets the class name of the camera.
  25412. * @returns the class name
  25413. */
  25414. getClassName(): string;
  25415. /** @hidden */
  25416. readonly _isCamera: boolean;
  25417. /**
  25418. * Gets a string representation of the camera useful for debug purpose.
  25419. * @param fullDetails Defines that a more verboe level of logging is required
  25420. * @returns the string representation
  25421. */
  25422. toString(fullDetails?: boolean): string;
  25423. /**
  25424. * Gets the current world space position of the camera.
  25425. */
  25426. get globalPosition(): Vector3;
  25427. /**
  25428. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25429. * @returns the active meshe list
  25430. */
  25431. getActiveMeshes(): SmartArray<AbstractMesh>;
  25432. /**
  25433. * Check wether a mesh is part of the current active mesh list of the camera
  25434. * @param mesh Defines the mesh to check
  25435. * @returns true if active, false otherwise
  25436. */
  25437. isActiveMesh(mesh: Mesh): boolean;
  25438. /**
  25439. * Is this camera ready to be used/rendered
  25440. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25441. * @return true if the camera is ready
  25442. */
  25443. isReady(completeCheck?: boolean): boolean;
  25444. /** @hidden */
  25445. _initCache(): void;
  25446. /** @hidden */
  25447. _updateCache(ignoreParentClass?: boolean): void;
  25448. /** @hidden */
  25449. _isSynchronized(): boolean;
  25450. /** @hidden */
  25451. _isSynchronizedViewMatrix(): boolean;
  25452. /** @hidden */
  25453. _isSynchronizedProjectionMatrix(): boolean;
  25454. /**
  25455. * Attach the input controls to a specific dom element to get the input from.
  25456. * @param element Defines the element the controls should be listened from
  25457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25458. */
  25459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25460. /**
  25461. * Detach the current controls from the specified dom element.
  25462. * @param element Defines the element to stop listening the inputs from
  25463. */
  25464. detachControl(element: HTMLElement): void;
  25465. /**
  25466. * Update the camera state according to the different inputs gathered during the frame.
  25467. */
  25468. update(): void;
  25469. /** @hidden */
  25470. _checkInputs(): void;
  25471. /** @hidden */
  25472. get rigCameras(): Camera[];
  25473. /**
  25474. * Gets the post process used by the rig cameras
  25475. */
  25476. get rigPostProcess(): Nullable<PostProcess>;
  25477. /**
  25478. * Internal, gets the first post proces.
  25479. * @returns the first post process to be run on this camera.
  25480. */
  25481. _getFirstPostProcess(): Nullable<PostProcess>;
  25482. private _cascadePostProcessesToRigCams;
  25483. /**
  25484. * Attach a post process to the camera.
  25485. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25486. * @param postProcess The post process to attach to the camera
  25487. * @param insertAt The position of the post process in case several of them are in use in the scene
  25488. * @returns the position the post process has been inserted at
  25489. */
  25490. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25491. /**
  25492. * Detach a post process to the camera.
  25493. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25494. * @param postProcess The post process to detach from the camera
  25495. */
  25496. detachPostProcess(postProcess: PostProcess): void;
  25497. /**
  25498. * Gets the current world matrix of the camera
  25499. */
  25500. getWorldMatrix(): Matrix;
  25501. /** @hidden */
  25502. _getViewMatrix(): Matrix;
  25503. /**
  25504. * Gets the current view matrix of the camera.
  25505. * @param force forces the camera to recompute the matrix without looking at the cached state
  25506. * @returns the view matrix
  25507. */
  25508. getViewMatrix(force?: boolean): Matrix;
  25509. /**
  25510. * Freeze the projection matrix.
  25511. * It will prevent the cache check of the camera projection compute and can speed up perf
  25512. * if no parameter of the camera are meant to change
  25513. * @param projection Defines manually a projection if necessary
  25514. */
  25515. freezeProjectionMatrix(projection?: Matrix): void;
  25516. /**
  25517. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25518. */
  25519. unfreezeProjectionMatrix(): void;
  25520. /**
  25521. * Gets the current projection matrix of the camera.
  25522. * @param force forces the camera to recompute the matrix without looking at the cached state
  25523. * @returns the projection matrix
  25524. */
  25525. getProjectionMatrix(force?: boolean): Matrix;
  25526. /**
  25527. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25528. * @returns a Matrix
  25529. */
  25530. getTransformationMatrix(): Matrix;
  25531. private _updateFrustumPlanes;
  25532. /**
  25533. * Checks if a cullable object (mesh...) is in the camera frustum
  25534. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25535. * @param target The object to check
  25536. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25537. * @returns true if the object is in frustum otherwise false
  25538. */
  25539. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25540. /**
  25541. * Checks if a cullable object (mesh...) is in the camera frustum
  25542. * Unlike isInFrustum this cheks the full bounding box
  25543. * @param target The object to check
  25544. * @returns true if the object is in frustum otherwise false
  25545. */
  25546. isCompletelyInFrustum(target: ICullable): boolean;
  25547. /**
  25548. * Gets a ray in the forward direction from the camera.
  25549. * @param length Defines the length of the ray to create
  25550. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25551. * @param origin Defines the start point of the ray which defaults to the camera position
  25552. * @returns the forward ray
  25553. */
  25554. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25555. /**
  25556. * Releases resources associated with this node.
  25557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25559. */
  25560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25561. /** @hidden */
  25562. _isLeftCamera: boolean;
  25563. /**
  25564. * Gets the left camera of a rig setup in case of Rigged Camera
  25565. */
  25566. get isLeftCamera(): boolean;
  25567. /** @hidden */
  25568. _isRightCamera: boolean;
  25569. /**
  25570. * Gets the right camera of a rig setup in case of Rigged Camera
  25571. */
  25572. get isRightCamera(): boolean;
  25573. /**
  25574. * Gets the left camera of a rig setup in case of Rigged Camera
  25575. */
  25576. get leftCamera(): Nullable<FreeCamera>;
  25577. /**
  25578. * Gets the right camera of a rig setup in case of Rigged Camera
  25579. */
  25580. get rightCamera(): Nullable<FreeCamera>;
  25581. /**
  25582. * Gets the left camera target of a rig setup in case of Rigged Camera
  25583. * @returns the target position
  25584. */
  25585. getLeftTarget(): Nullable<Vector3>;
  25586. /**
  25587. * Gets the right camera target of a rig setup in case of Rigged Camera
  25588. * @returns the target position
  25589. */
  25590. getRightTarget(): Nullable<Vector3>;
  25591. /**
  25592. * @hidden
  25593. */
  25594. setCameraRigMode(mode: number, rigParams: any): void;
  25595. /** @hidden */
  25596. static _setStereoscopicRigMode(camera: Camera): void;
  25597. /** @hidden */
  25598. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25599. /** @hidden */
  25600. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25601. /** @hidden */
  25602. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25603. /** @hidden */
  25604. _getVRProjectionMatrix(): Matrix;
  25605. protected _updateCameraRotationMatrix(): void;
  25606. protected _updateWebVRCameraRotationMatrix(): void;
  25607. /**
  25608. * This function MUST be overwritten by the different WebVR cameras available.
  25609. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25610. * @hidden
  25611. */
  25612. _getWebVRProjectionMatrix(): Matrix;
  25613. /**
  25614. * This function MUST be overwritten by the different WebVR cameras available.
  25615. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25616. * @hidden
  25617. */
  25618. _getWebVRViewMatrix(): Matrix;
  25619. /** @hidden */
  25620. setCameraRigParameter(name: string, value: any): void;
  25621. /**
  25622. * needs to be overridden by children so sub has required properties to be copied
  25623. * @hidden
  25624. */
  25625. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25626. /**
  25627. * May need to be overridden by children
  25628. * @hidden
  25629. */
  25630. _updateRigCameras(): void;
  25631. /** @hidden */
  25632. _setupInputs(): void;
  25633. /**
  25634. * Serialiaze the camera setup to a json represention
  25635. * @returns the JSON representation
  25636. */
  25637. serialize(): any;
  25638. /**
  25639. * Clones the current camera.
  25640. * @param name The cloned camera name
  25641. * @returns the cloned camera
  25642. */
  25643. clone(name: string): Camera;
  25644. /**
  25645. * Gets the direction of the camera relative to a given local axis.
  25646. * @param localAxis Defines the reference axis to provide a relative direction.
  25647. * @return the direction
  25648. */
  25649. getDirection(localAxis: Vector3): Vector3;
  25650. /**
  25651. * Returns the current camera absolute rotation
  25652. */
  25653. get absoluteRotation(): Quaternion;
  25654. /**
  25655. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25656. * @param localAxis Defines the reference axis to provide a relative direction.
  25657. * @param result Defines the vector to store the result in
  25658. */
  25659. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25660. /**
  25661. * Gets a camera constructor for a given camera type
  25662. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25663. * @param name The name of the camera the result will be able to instantiate
  25664. * @param scene The scene the result will construct the camera in
  25665. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25666. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25667. * @returns a factory method to construc the camera
  25668. */
  25669. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25670. /**
  25671. * Compute the world matrix of the camera.
  25672. * @returns the camera world matrix
  25673. */
  25674. computeWorldMatrix(): Matrix;
  25675. /**
  25676. * Parse a JSON and creates the camera from the parsed information
  25677. * @param parsedCamera The JSON to parse
  25678. * @param scene The scene to instantiate the camera in
  25679. * @returns the newly constructed camera
  25680. */
  25681. static Parse(parsedCamera: any, scene: Scene): Camera;
  25682. }
  25683. }
  25684. declare module BABYLON {
  25685. /**
  25686. * Class containing static functions to help procedurally build meshes
  25687. */
  25688. export class DiscBuilder {
  25689. /**
  25690. * Creates a plane polygonal mesh. By default, this is a disc
  25691. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25692. * * 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
  25693. * * 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
  25694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25695. * * 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
  25696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25697. * @param name defines the name of the mesh
  25698. * @param options defines the options used to create the mesh
  25699. * @param scene defines the hosting scene
  25700. * @returns the plane polygonal mesh
  25701. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25702. */
  25703. static CreateDisc(name: string, options: {
  25704. radius?: number;
  25705. tessellation?: number;
  25706. arc?: number;
  25707. updatable?: boolean;
  25708. sideOrientation?: number;
  25709. frontUVs?: Vector4;
  25710. backUVs?: Vector4;
  25711. }, scene?: Nullable<Scene>): Mesh;
  25712. }
  25713. }
  25714. declare module BABYLON {
  25715. /**
  25716. * This represents all the required information to add a fresnel effect on a material:
  25717. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25718. */
  25719. export class FresnelParameters {
  25720. private _isEnabled;
  25721. /**
  25722. * Define if the fresnel effect is enable or not.
  25723. */
  25724. get isEnabled(): boolean;
  25725. set isEnabled(value: boolean);
  25726. /**
  25727. * Define the color used on edges (grazing angle)
  25728. */
  25729. leftColor: Color3;
  25730. /**
  25731. * Define the color used on center
  25732. */
  25733. rightColor: Color3;
  25734. /**
  25735. * Define bias applied to computed fresnel term
  25736. */
  25737. bias: number;
  25738. /**
  25739. * Defined the power exponent applied to fresnel term
  25740. */
  25741. power: number;
  25742. /**
  25743. * Clones the current fresnel and its valuues
  25744. * @returns a clone fresnel configuration
  25745. */
  25746. clone(): FresnelParameters;
  25747. /**
  25748. * Serializes the current fresnel parameters to a JSON representation.
  25749. * @return the JSON serialization
  25750. */
  25751. serialize(): any;
  25752. /**
  25753. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25754. * @param parsedFresnelParameters Define the JSON representation
  25755. * @returns the parsed parameters
  25756. */
  25757. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25758. }
  25759. }
  25760. declare module BABYLON {
  25761. /**
  25762. * Base class of materials working in push mode in babylon JS
  25763. * @hidden
  25764. */
  25765. export class PushMaterial extends Material {
  25766. protected _activeEffect: Effect;
  25767. protected _normalMatrix: Matrix;
  25768. /**
  25769. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25770. * This means that the material can keep using a previous shader while a new one is being compiled.
  25771. * This is mostly used when shader parallel compilation is supported (true by default)
  25772. */
  25773. allowShaderHotSwapping: boolean;
  25774. constructor(name: string, scene: Scene);
  25775. getEffect(): Effect;
  25776. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25777. /**
  25778. * Binds the given world matrix to the active effect
  25779. *
  25780. * @param world the matrix to bind
  25781. */
  25782. bindOnlyWorldMatrix(world: Matrix): void;
  25783. /**
  25784. * Binds the given normal matrix to the active effect
  25785. *
  25786. * @param normalMatrix the matrix to bind
  25787. */
  25788. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25789. bind(world: Matrix, mesh?: Mesh): void;
  25790. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25791. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25792. }
  25793. }
  25794. declare module BABYLON {
  25795. /**
  25796. * This groups all the flags used to control the materials channel.
  25797. */
  25798. export class MaterialFlags {
  25799. private static _DiffuseTextureEnabled;
  25800. /**
  25801. * Are diffuse textures enabled in the application.
  25802. */
  25803. static get DiffuseTextureEnabled(): boolean;
  25804. static set DiffuseTextureEnabled(value: boolean);
  25805. private static _AmbientTextureEnabled;
  25806. /**
  25807. * Are ambient textures enabled in the application.
  25808. */
  25809. static get AmbientTextureEnabled(): boolean;
  25810. static set AmbientTextureEnabled(value: boolean);
  25811. private static _OpacityTextureEnabled;
  25812. /**
  25813. * Are opacity textures enabled in the application.
  25814. */
  25815. static get OpacityTextureEnabled(): boolean;
  25816. static set OpacityTextureEnabled(value: boolean);
  25817. private static _ReflectionTextureEnabled;
  25818. /**
  25819. * Are reflection textures enabled in the application.
  25820. */
  25821. static get ReflectionTextureEnabled(): boolean;
  25822. static set ReflectionTextureEnabled(value: boolean);
  25823. private static _EmissiveTextureEnabled;
  25824. /**
  25825. * Are emissive textures enabled in the application.
  25826. */
  25827. static get EmissiveTextureEnabled(): boolean;
  25828. static set EmissiveTextureEnabled(value: boolean);
  25829. private static _SpecularTextureEnabled;
  25830. /**
  25831. * Are specular textures enabled in the application.
  25832. */
  25833. static get SpecularTextureEnabled(): boolean;
  25834. static set SpecularTextureEnabled(value: boolean);
  25835. private static _BumpTextureEnabled;
  25836. /**
  25837. * Are bump textures enabled in the application.
  25838. */
  25839. static get BumpTextureEnabled(): boolean;
  25840. static set BumpTextureEnabled(value: boolean);
  25841. private static _LightmapTextureEnabled;
  25842. /**
  25843. * Are lightmap textures enabled in the application.
  25844. */
  25845. static get LightmapTextureEnabled(): boolean;
  25846. static set LightmapTextureEnabled(value: boolean);
  25847. private static _RefractionTextureEnabled;
  25848. /**
  25849. * Are refraction textures enabled in the application.
  25850. */
  25851. static get RefractionTextureEnabled(): boolean;
  25852. static set RefractionTextureEnabled(value: boolean);
  25853. private static _ColorGradingTextureEnabled;
  25854. /**
  25855. * Are color grading textures enabled in the application.
  25856. */
  25857. static get ColorGradingTextureEnabled(): boolean;
  25858. static set ColorGradingTextureEnabled(value: boolean);
  25859. private static _FresnelEnabled;
  25860. /**
  25861. * Are fresnels enabled in the application.
  25862. */
  25863. static get FresnelEnabled(): boolean;
  25864. static set FresnelEnabled(value: boolean);
  25865. private static _ClearCoatTextureEnabled;
  25866. /**
  25867. * Are clear coat textures enabled in the application.
  25868. */
  25869. static get ClearCoatTextureEnabled(): boolean;
  25870. static set ClearCoatTextureEnabled(value: boolean);
  25871. private static _ClearCoatBumpTextureEnabled;
  25872. /**
  25873. * Are clear coat bump textures enabled in the application.
  25874. */
  25875. static get ClearCoatBumpTextureEnabled(): boolean;
  25876. static set ClearCoatBumpTextureEnabled(value: boolean);
  25877. private static _ClearCoatTintTextureEnabled;
  25878. /**
  25879. * Are clear coat tint textures enabled in the application.
  25880. */
  25881. static get ClearCoatTintTextureEnabled(): boolean;
  25882. static set ClearCoatTintTextureEnabled(value: boolean);
  25883. private static _SheenTextureEnabled;
  25884. /**
  25885. * Are sheen textures enabled in the application.
  25886. */
  25887. static get SheenTextureEnabled(): boolean;
  25888. static set SheenTextureEnabled(value: boolean);
  25889. private static _AnisotropicTextureEnabled;
  25890. /**
  25891. * Are anisotropic textures enabled in the application.
  25892. */
  25893. static get AnisotropicTextureEnabled(): boolean;
  25894. static set AnisotropicTextureEnabled(value: boolean);
  25895. private static _ThicknessTextureEnabled;
  25896. /**
  25897. * Are thickness textures enabled in the application.
  25898. */
  25899. static get ThicknessTextureEnabled(): boolean;
  25900. static set ThicknessTextureEnabled(value: boolean);
  25901. }
  25902. }
  25903. declare module BABYLON {
  25904. /** @hidden */
  25905. export var defaultFragmentDeclaration: {
  25906. name: string;
  25907. shader: string;
  25908. };
  25909. }
  25910. declare module BABYLON {
  25911. /** @hidden */
  25912. export var defaultUboDeclaration: {
  25913. name: string;
  25914. shader: string;
  25915. };
  25916. }
  25917. declare module BABYLON {
  25918. /** @hidden */
  25919. export var lightFragmentDeclaration: {
  25920. name: string;
  25921. shader: string;
  25922. };
  25923. }
  25924. declare module BABYLON {
  25925. /** @hidden */
  25926. export var lightUboDeclaration: {
  25927. name: string;
  25928. shader: string;
  25929. };
  25930. }
  25931. declare module BABYLON {
  25932. /** @hidden */
  25933. export var lightsFragmentFunctions: {
  25934. name: string;
  25935. shader: string;
  25936. };
  25937. }
  25938. declare module BABYLON {
  25939. /** @hidden */
  25940. export var shadowsFragmentFunctions: {
  25941. name: string;
  25942. shader: string;
  25943. };
  25944. }
  25945. declare module BABYLON {
  25946. /** @hidden */
  25947. export var fresnelFunction: {
  25948. name: string;
  25949. shader: string;
  25950. };
  25951. }
  25952. declare module BABYLON {
  25953. /** @hidden */
  25954. export var reflectionFunction: {
  25955. name: string;
  25956. shader: string;
  25957. };
  25958. }
  25959. declare module BABYLON {
  25960. /** @hidden */
  25961. export var bumpFragmentFunctions: {
  25962. name: string;
  25963. shader: string;
  25964. };
  25965. }
  25966. declare module BABYLON {
  25967. /** @hidden */
  25968. export var logDepthDeclaration: {
  25969. name: string;
  25970. shader: string;
  25971. };
  25972. }
  25973. declare module BABYLON {
  25974. /** @hidden */
  25975. export var bumpFragment: {
  25976. name: string;
  25977. shader: string;
  25978. };
  25979. }
  25980. declare module BABYLON {
  25981. /** @hidden */
  25982. export var depthPrePass: {
  25983. name: string;
  25984. shader: string;
  25985. };
  25986. }
  25987. declare module BABYLON {
  25988. /** @hidden */
  25989. export var lightFragment: {
  25990. name: string;
  25991. shader: string;
  25992. };
  25993. }
  25994. declare module BABYLON {
  25995. /** @hidden */
  25996. export var logDepthFragment: {
  25997. name: string;
  25998. shader: string;
  25999. };
  26000. }
  26001. declare module BABYLON {
  26002. /** @hidden */
  26003. export var defaultPixelShader: {
  26004. name: string;
  26005. shader: string;
  26006. };
  26007. }
  26008. declare module BABYLON {
  26009. /** @hidden */
  26010. export var defaultVertexDeclaration: {
  26011. name: string;
  26012. shader: string;
  26013. };
  26014. }
  26015. declare module BABYLON {
  26016. /** @hidden */
  26017. export var bumpVertexDeclaration: {
  26018. name: string;
  26019. shader: string;
  26020. };
  26021. }
  26022. declare module BABYLON {
  26023. /** @hidden */
  26024. export var bumpVertex: {
  26025. name: string;
  26026. shader: string;
  26027. };
  26028. }
  26029. declare module BABYLON {
  26030. /** @hidden */
  26031. export var fogVertex: {
  26032. name: string;
  26033. shader: string;
  26034. };
  26035. }
  26036. declare module BABYLON {
  26037. /** @hidden */
  26038. export var shadowsVertex: {
  26039. name: string;
  26040. shader: string;
  26041. };
  26042. }
  26043. declare module BABYLON {
  26044. /** @hidden */
  26045. export var pointCloudVertex: {
  26046. name: string;
  26047. shader: string;
  26048. };
  26049. }
  26050. declare module BABYLON {
  26051. /** @hidden */
  26052. export var logDepthVertex: {
  26053. name: string;
  26054. shader: string;
  26055. };
  26056. }
  26057. declare module BABYLON {
  26058. /** @hidden */
  26059. export var defaultVertexShader: {
  26060. name: string;
  26061. shader: string;
  26062. };
  26063. }
  26064. declare module BABYLON {
  26065. /** @hidden */
  26066. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26067. MAINUV1: boolean;
  26068. MAINUV2: boolean;
  26069. DIFFUSE: boolean;
  26070. DIFFUSEDIRECTUV: number;
  26071. AMBIENT: boolean;
  26072. AMBIENTDIRECTUV: number;
  26073. OPACITY: boolean;
  26074. OPACITYDIRECTUV: number;
  26075. OPACITYRGB: boolean;
  26076. REFLECTION: boolean;
  26077. EMISSIVE: boolean;
  26078. EMISSIVEDIRECTUV: number;
  26079. SPECULAR: boolean;
  26080. SPECULARDIRECTUV: number;
  26081. BUMP: boolean;
  26082. BUMPDIRECTUV: number;
  26083. PARALLAX: boolean;
  26084. PARALLAXOCCLUSION: boolean;
  26085. SPECULAROVERALPHA: boolean;
  26086. CLIPPLANE: boolean;
  26087. CLIPPLANE2: boolean;
  26088. CLIPPLANE3: boolean;
  26089. CLIPPLANE4: boolean;
  26090. CLIPPLANE5: boolean;
  26091. CLIPPLANE6: boolean;
  26092. ALPHATEST: boolean;
  26093. DEPTHPREPASS: boolean;
  26094. ALPHAFROMDIFFUSE: boolean;
  26095. POINTSIZE: boolean;
  26096. FOG: boolean;
  26097. SPECULARTERM: boolean;
  26098. DIFFUSEFRESNEL: boolean;
  26099. OPACITYFRESNEL: boolean;
  26100. REFLECTIONFRESNEL: boolean;
  26101. REFRACTIONFRESNEL: boolean;
  26102. EMISSIVEFRESNEL: boolean;
  26103. FRESNEL: boolean;
  26104. NORMAL: boolean;
  26105. UV1: boolean;
  26106. UV2: boolean;
  26107. VERTEXCOLOR: boolean;
  26108. VERTEXALPHA: boolean;
  26109. NUM_BONE_INFLUENCERS: number;
  26110. BonesPerMesh: number;
  26111. BONETEXTURE: boolean;
  26112. INSTANCES: boolean;
  26113. GLOSSINESS: boolean;
  26114. ROUGHNESS: boolean;
  26115. EMISSIVEASILLUMINATION: boolean;
  26116. LINKEMISSIVEWITHDIFFUSE: boolean;
  26117. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26118. LIGHTMAP: boolean;
  26119. LIGHTMAPDIRECTUV: number;
  26120. OBJECTSPACE_NORMALMAP: boolean;
  26121. USELIGHTMAPASSHADOWMAP: boolean;
  26122. REFLECTIONMAP_3D: boolean;
  26123. REFLECTIONMAP_SPHERICAL: boolean;
  26124. REFLECTIONMAP_PLANAR: boolean;
  26125. REFLECTIONMAP_CUBIC: boolean;
  26126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26127. REFLECTIONMAP_PROJECTION: boolean;
  26128. REFLECTIONMAP_SKYBOX: boolean;
  26129. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26130. REFLECTIONMAP_EXPLICIT: boolean;
  26131. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26132. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26133. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26134. INVERTCUBICMAP: boolean;
  26135. LOGARITHMICDEPTH: boolean;
  26136. REFRACTION: boolean;
  26137. REFRACTIONMAP_3D: boolean;
  26138. REFLECTIONOVERALPHA: boolean;
  26139. TWOSIDEDLIGHTING: boolean;
  26140. SHADOWFLOAT: boolean;
  26141. MORPHTARGETS: boolean;
  26142. MORPHTARGETS_NORMAL: boolean;
  26143. MORPHTARGETS_TANGENT: boolean;
  26144. MORPHTARGETS_UV: boolean;
  26145. NUM_MORPH_INFLUENCERS: number;
  26146. NONUNIFORMSCALING: boolean;
  26147. PREMULTIPLYALPHA: boolean;
  26148. IMAGEPROCESSING: boolean;
  26149. VIGNETTE: boolean;
  26150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26151. VIGNETTEBLENDMODEOPAQUE: boolean;
  26152. TONEMAPPING: boolean;
  26153. TONEMAPPING_ACES: boolean;
  26154. CONTRAST: boolean;
  26155. COLORCURVES: boolean;
  26156. COLORGRADING: boolean;
  26157. COLORGRADING3D: boolean;
  26158. SAMPLER3DGREENDEPTH: boolean;
  26159. SAMPLER3DBGRMAP: boolean;
  26160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26161. MULTIVIEW: boolean;
  26162. /**
  26163. * If the reflection texture on this material is in linear color space
  26164. * @hidden
  26165. */
  26166. IS_REFLECTION_LINEAR: boolean;
  26167. /**
  26168. * If the refraction texture on this material is in linear color space
  26169. * @hidden
  26170. */
  26171. IS_REFRACTION_LINEAR: boolean;
  26172. EXPOSURE: boolean;
  26173. constructor();
  26174. setReflectionMode(modeToEnable: string): void;
  26175. }
  26176. /**
  26177. * This is the default material used in Babylon. It is the best trade off between quality
  26178. * and performances.
  26179. * @see http://doc.babylonjs.com/babylon101/materials
  26180. */
  26181. export class StandardMaterial extends PushMaterial {
  26182. private _diffuseTexture;
  26183. /**
  26184. * The basic texture of the material as viewed under a light.
  26185. */
  26186. diffuseTexture: Nullable<BaseTexture>;
  26187. private _ambientTexture;
  26188. /**
  26189. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26190. */
  26191. ambientTexture: Nullable<BaseTexture>;
  26192. private _opacityTexture;
  26193. /**
  26194. * Define the transparency of the material from a texture.
  26195. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26196. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26197. */
  26198. opacityTexture: Nullable<BaseTexture>;
  26199. private _reflectionTexture;
  26200. /**
  26201. * Define the texture used to display the reflection.
  26202. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26203. */
  26204. reflectionTexture: Nullable<BaseTexture>;
  26205. private _emissiveTexture;
  26206. /**
  26207. * Define texture of the material as if self lit.
  26208. * This will be mixed in the final result even in the absence of light.
  26209. */
  26210. emissiveTexture: Nullable<BaseTexture>;
  26211. private _specularTexture;
  26212. /**
  26213. * Define how the color and intensity of the highlight given by the light in the material.
  26214. */
  26215. specularTexture: Nullable<BaseTexture>;
  26216. private _bumpTexture;
  26217. /**
  26218. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26219. * 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.
  26220. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26221. */
  26222. bumpTexture: Nullable<BaseTexture>;
  26223. private _lightmapTexture;
  26224. /**
  26225. * Complex lighting can be computationally expensive to compute at runtime.
  26226. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26227. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26228. */
  26229. lightmapTexture: Nullable<BaseTexture>;
  26230. private _refractionTexture;
  26231. /**
  26232. * Define the texture used to display the refraction.
  26233. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26234. */
  26235. refractionTexture: Nullable<BaseTexture>;
  26236. /**
  26237. * The color of the material lit by the environmental background lighting.
  26238. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26239. */
  26240. ambientColor: Color3;
  26241. /**
  26242. * The basic color of the material as viewed under a light.
  26243. */
  26244. diffuseColor: Color3;
  26245. /**
  26246. * Define how the color and intensity of the highlight given by the light in the material.
  26247. */
  26248. specularColor: Color3;
  26249. /**
  26250. * Define the color of the material as if self lit.
  26251. * This will be mixed in the final result even in the absence of light.
  26252. */
  26253. emissiveColor: Color3;
  26254. /**
  26255. * Defines how sharp are the highlights in the material.
  26256. * The bigger the value the sharper giving a more glossy feeling to the result.
  26257. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26258. */
  26259. specularPower: number;
  26260. private _useAlphaFromDiffuseTexture;
  26261. /**
  26262. * Does the transparency come from the diffuse texture alpha channel.
  26263. */
  26264. useAlphaFromDiffuseTexture: boolean;
  26265. private _useEmissiveAsIllumination;
  26266. /**
  26267. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26268. */
  26269. useEmissiveAsIllumination: boolean;
  26270. private _linkEmissiveWithDiffuse;
  26271. /**
  26272. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26273. * the emissive level when the final color is close to one.
  26274. */
  26275. linkEmissiveWithDiffuse: boolean;
  26276. private _useSpecularOverAlpha;
  26277. /**
  26278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26280. */
  26281. useSpecularOverAlpha: boolean;
  26282. private _useReflectionOverAlpha;
  26283. /**
  26284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26286. */
  26287. useReflectionOverAlpha: boolean;
  26288. private _disableLighting;
  26289. /**
  26290. * Does lights from the scene impacts this material.
  26291. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26292. */
  26293. disableLighting: boolean;
  26294. private _useObjectSpaceNormalMap;
  26295. /**
  26296. * Allows using an object space normal map (instead of tangent space).
  26297. */
  26298. useObjectSpaceNormalMap: boolean;
  26299. private _useParallax;
  26300. /**
  26301. * Is parallax enabled or not.
  26302. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26303. */
  26304. useParallax: boolean;
  26305. private _useParallaxOcclusion;
  26306. /**
  26307. * Is parallax occlusion enabled or not.
  26308. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26309. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26310. */
  26311. useParallaxOcclusion: boolean;
  26312. /**
  26313. * 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.
  26314. */
  26315. parallaxScaleBias: number;
  26316. private _roughness;
  26317. /**
  26318. * Helps to define how blurry the reflections should appears in the material.
  26319. */
  26320. roughness: number;
  26321. /**
  26322. * In case of refraction, define the value of the index of refraction.
  26323. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26324. */
  26325. indexOfRefraction: number;
  26326. /**
  26327. * Invert the refraction texture alongside the y axis.
  26328. * It can be useful with procedural textures or probe for instance.
  26329. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26330. */
  26331. invertRefractionY: boolean;
  26332. /**
  26333. * Defines the alpha limits in alpha test mode.
  26334. */
  26335. alphaCutOff: number;
  26336. private _useLightmapAsShadowmap;
  26337. /**
  26338. * In case of light mapping, define whether the map contains light or shadow informations.
  26339. */
  26340. useLightmapAsShadowmap: boolean;
  26341. private _diffuseFresnelParameters;
  26342. /**
  26343. * Define the diffuse fresnel parameters of the material.
  26344. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26345. */
  26346. diffuseFresnelParameters: FresnelParameters;
  26347. private _opacityFresnelParameters;
  26348. /**
  26349. * Define the opacity fresnel parameters of the material.
  26350. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26351. */
  26352. opacityFresnelParameters: FresnelParameters;
  26353. private _reflectionFresnelParameters;
  26354. /**
  26355. * Define the reflection fresnel parameters of the material.
  26356. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26357. */
  26358. reflectionFresnelParameters: FresnelParameters;
  26359. private _refractionFresnelParameters;
  26360. /**
  26361. * Define the refraction fresnel parameters of the material.
  26362. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26363. */
  26364. refractionFresnelParameters: FresnelParameters;
  26365. private _emissiveFresnelParameters;
  26366. /**
  26367. * Define the emissive fresnel parameters of the material.
  26368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26369. */
  26370. emissiveFresnelParameters: FresnelParameters;
  26371. private _useReflectionFresnelFromSpecular;
  26372. /**
  26373. * If true automatically deducts the fresnels values from the material specularity.
  26374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26375. */
  26376. useReflectionFresnelFromSpecular: boolean;
  26377. private _useGlossinessFromSpecularMapAlpha;
  26378. /**
  26379. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26380. */
  26381. useGlossinessFromSpecularMapAlpha: boolean;
  26382. private _maxSimultaneousLights;
  26383. /**
  26384. * Defines the maximum number of lights that can be used in the material
  26385. */
  26386. maxSimultaneousLights: number;
  26387. private _invertNormalMapX;
  26388. /**
  26389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26390. */
  26391. invertNormalMapX: boolean;
  26392. private _invertNormalMapY;
  26393. /**
  26394. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26395. */
  26396. invertNormalMapY: boolean;
  26397. private _twoSidedLighting;
  26398. /**
  26399. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26400. */
  26401. twoSidedLighting: boolean;
  26402. /**
  26403. * Default configuration related to image processing available in the standard Material.
  26404. */
  26405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26406. /**
  26407. * Gets the image processing configuration used either in this material.
  26408. */
  26409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26410. /**
  26411. * Sets the Default image processing configuration used either in the this material.
  26412. *
  26413. * If sets to null, the scene one is in use.
  26414. */
  26415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26416. /**
  26417. * Keep track of the image processing observer to allow dispose and replace.
  26418. */
  26419. private _imageProcessingObserver;
  26420. /**
  26421. * Attaches a new image processing configuration to the Standard Material.
  26422. * @param configuration
  26423. */
  26424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26425. /**
  26426. * Gets wether the color curves effect is enabled.
  26427. */
  26428. get cameraColorCurvesEnabled(): boolean;
  26429. /**
  26430. * Sets wether the color curves effect is enabled.
  26431. */
  26432. set cameraColorCurvesEnabled(value: boolean);
  26433. /**
  26434. * Gets wether the color grading effect is enabled.
  26435. */
  26436. get cameraColorGradingEnabled(): boolean;
  26437. /**
  26438. * Gets wether the color grading effect is enabled.
  26439. */
  26440. set cameraColorGradingEnabled(value: boolean);
  26441. /**
  26442. * Gets wether tonemapping is enabled or not.
  26443. */
  26444. get cameraToneMappingEnabled(): boolean;
  26445. /**
  26446. * Sets wether tonemapping is enabled or not
  26447. */
  26448. set cameraToneMappingEnabled(value: boolean);
  26449. /**
  26450. * The camera exposure used on this material.
  26451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26452. * This corresponds to a photographic exposure.
  26453. */
  26454. get cameraExposure(): number;
  26455. /**
  26456. * The camera exposure used on this material.
  26457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26458. * This corresponds to a photographic exposure.
  26459. */
  26460. set cameraExposure(value: number);
  26461. /**
  26462. * Gets The camera contrast used on this material.
  26463. */
  26464. get cameraContrast(): number;
  26465. /**
  26466. * Sets The camera contrast used on this material.
  26467. */
  26468. set cameraContrast(value: number);
  26469. /**
  26470. * Gets the Color Grading 2D Lookup Texture.
  26471. */
  26472. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26473. /**
  26474. * Sets the Color Grading 2D Lookup Texture.
  26475. */
  26476. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26477. /**
  26478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26480. * 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;
  26481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26482. */
  26483. get cameraColorCurves(): Nullable<ColorCurves>;
  26484. /**
  26485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26487. * 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;
  26488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26489. */
  26490. set cameraColorCurves(value: Nullable<ColorCurves>);
  26491. /**
  26492. * Custom callback helping to override the default shader used in the material.
  26493. */
  26494. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26495. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26496. protected _worldViewProjectionMatrix: Matrix;
  26497. protected _globalAmbientColor: Color3;
  26498. protected _useLogarithmicDepth: boolean;
  26499. protected _rebuildInParallel: boolean;
  26500. /**
  26501. * Instantiates a new standard material.
  26502. * This is the default material used in Babylon. It is the best trade off between quality
  26503. * and performances.
  26504. * @see http://doc.babylonjs.com/babylon101/materials
  26505. * @param name Define the name of the material in the scene
  26506. * @param scene Define the scene the material belong to
  26507. */
  26508. constructor(name: string, scene: Scene);
  26509. /**
  26510. * Gets a boolean indicating that current material needs to register RTT
  26511. */
  26512. get hasRenderTargetTextures(): boolean;
  26513. /**
  26514. * Gets the current class name of the material e.g. "StandardMaterial"
  26515. * Mainly use in serialization.
  26516. * @returns the class name
  26517. */
  26518. getClassName(): string;
  26519. /**
  26520. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26521. * You can try switching to logarithmic depth.
  26522. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26523. */
  26524. get useLogarithmicDepth(): boolean;
  26525. set useLogarithmicDepth(value: boolean);
  26526. /**
  26527. * Specifies if the material will require alpha blending
  26528. * @returns a boolean specifying if alpha blending is needed
  26529. */
  26530. needAlphaBlending(): boolean;
  26531. /**
  26532. * Specifies if this material should be rendered in alpha test mode
  26533. * @returns a boolean specifying if an alpha test is needed.
  26534. */
  26535. needAlphaTesting(): boolean;
  26536. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26537. /**
  26538. * Get the texture used for alpha test purpose.
  26539. * @returns the diffuse texture in case of the standard material.
  26540. */
  26541. getAlphaTestTexture(): Nullable<BaseTexture>;
  26542. /**
  26543. * Get if the submesh is ready to be used and all its information available.
  26544. * Child classes can use it to update shaders
  26545. * @param mesh defines the mesh to check
  26546. * @param subMesh defines which submesh to check
  26547. * @param useInstances specifies that instances should be used
  26548. * @returns a boolean indicating that the submesh is ready or not
  26549. */
  26550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26551. /**
  26552. * Builds the material UBO layouts.
  26553. * Used internally during the effect preparation.
  26554. */
  26555. buildUniformLayout(): void;
  26556. /**
  26557. * Unbinds the material from the mesh
  26558. */
  26559. unbind(): void;
  26560. /**
  26561. * Binds the submesh to this material by preparing the effect and shader to draw
  26562. * @param world defines the world transformation matrix
  26563. * @param mesh defines the mesh containing the submesh
  26564. * @param subMesh defines the submesh to bind the material to
  26565. */
  26566. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26567. /**
  26568. * Get the list of animatables in the material.
  26569. * @returns the list of animatables object used in the material
  26570. */
  26571. getAnimatables(): IAnimatable[];
  26572. /**
  26573. * Gets the active textures from the material
  26574. * @returns an array of textures
  26575. */
  26576. getActiveTextures(): BaseTexture[];
  26577. /**
  26578. * Specifies if the material uses a texture
  26579. * @param texture defines the texture to check against the material
  26580. * @returns a boolean specifying if the material uses the texture
  26581. */
  26582. hasTexture(texture: BaseTexture): boolean;
  26583. /**
  26584. * Disposes the material
  26585. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26586. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26587. */
  26588. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26589. /**
  26590. * Makes a duplicate of the material, and gives it a new name
  26591. * @param name defines the new name for the duplicated material
  26592. * @returns the cloned material
  26593. */
  26594. clone(name: string): StandardMaterial;
  26595. /**
  26596. * Serializes this material in a JSON representation
  26597. * @returns the serialized material object
  26598. */
  26599. serialize(): any;
  26600. /**
  26601. * Creates a standard material from parsed material data
  26602. * @param source defines the JSON representation of the material
  26603. * @param scene defines the hosting scene
  26604. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26605. * @returns a new standard material
  26606. */
  26607. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26608. /**
  26609. * Are diffuse textures enabled in the application.
  26610. */
  26611. static get DiffuseTextureEnabled(): boolean;
  26612. static set DiffuseTextureEnabled(value: boolean);
  26613. /**
  26614. * Are ambient textures enabled in the application.
  26615. */
  26616. static get AmbientTextureEnabled(): boolean;
  26617. static set AmbientTextureEnabled(value: boolean);
  26618. /**
  26619. * Are opacity textures enabled in the application.
  26620. */
  26621. static get OpacityTextureEnabled(): boolean;
  26622. static set OpacityTextureEnabled(value: boolean);
  26623. /**
  26624. * Are reflection textures enabled in the application.
  26625. */
  26626. static get ReflectionTextureEnabled(): boolean;
  26627. static set ReflectionTextureEnabled(value: boolean);
  26628. /**
  26629. * Are emissive textures enabled in the application.
  26630. */
  26631. static get EmissiveTextureEnabled(): boolean;
  26632. static set EmissiveTextureEnabled(value: boolean);
  26633. /**
  26634. * Are specular textures enabled in the application.
  26635. */
  26636. static get SpecularTextureEnabled(): boolean;
  26637. static set SpecularTextureEnabled(value: boolean);
  26638. /**
  26639. * Are bump textures enabled in the application.
  26640. */
  26641. static get BumpTextureEnabled(): boolean;
  26642. static set BumpTextureEnabled(value: boolean);
  26643. /**
  26644. * Are lightmap textures enabled in the application.
  26645. */
  26646. static get LightmapTextureEnabled(): boolean;
  26647. static set LightmapTextureEnabled(value: boolean);
  26648. /**
  26649. * Are refraction textures enabled in the application.
  26650. */
  26651. static get RefractionTextureEnabled(): boolean;
  26652. static set RefractionTextureEnabled(value: boolean);
  26653. /**
  26654. * Are color grading textures enabled in the application.
  26655. */
  26656. static get ColorGradingTextureEnabled(): boolean;
  26657. static set ColorGradingTextureEnabled(value: boolean);
  26658. /**
  26659. * Are fresnels enabled in the application.
  26660. */
  26661. static get FresnelEnabled(): boolean;
  26662. static set FresnelEnabled(value: boolean);
  26663. }
  26664. }
  26665. declare module BABYLON {
  26666. /**
  26667. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26668. *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.
  26669. * The SPS is also a particle system. It provides some methods to manage the particles.
  26670. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26671. *
  26672. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26673. */
  26674. export class SolidParticleSystem implements IDisposable {
  26675. /**
  26676. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26677. * Example : var p = SPS.particles[i];
  26678. */
  26679. particles: SolidParticle[];
  26680. /**
  26681. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26682. */
  26683. nbParticles: number;
  26684. /**
  26685. * If the particles must ever face the camera (default false). Useful for planar particles.
  26686. */
  26687. billboard: boolean;
  26688. /**
  26689. * Recompute normals when adding a shape
  26690. */
  26691. recomputeNormals: boolean;
  26692. /**
  26693. * This a counter ofr your own usage. It's not set by any SPS functions.
  26694. */
  26695. counter: number;
  26696. /**
  26697. * The SPS name. This name is also given to the underlying mesh.
  26698. */
  26699. name: string;
  26700. /**
  26701. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26702. */
  26703. mesh: Mesh;
  26704. /**
  26705. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26706. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26707. */
  26708. vars: any;
  26709. /**
  26710. * This array is populated when the SPS is set as 'pickable'.
  26711. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26712. * Each element of this array is an object `{idx: int, faceId: int}`.
  26713. * `idx` is the picked particle index in the `SPS.particles` array
  26714. * `faceId` is the picked face index counted within this particle.
  26715. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26716. */
  26717. pickedParticles: {
  26718. idx: number;
  26719. faceId: number;
  26720. }[];
  26721. /**
  26722. * This array is populated when `enableDepthSort` is set to true.
  26723. * Each element of this array is an instance of the class DepthSortedParticle.
  26724. */
  26725. depthSortedParticles: DepthSortedParticle[];
  26726. /**
  26727. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26728. * @hidden
  26729. */
  26730. _bSphereOnly: boolean;
  26731. /**
  26732. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26733. * @hidden
  26734. */
  26735. _bSphereRadiusFactor: number;
  26736. private _scene;
  26737. private _positions;
  26738. private _indices;
  26739. private _normals;
  26740. private _colors;
  26741. private _uvs;
  26742. private _indices32;
  26743. private _positions32;
  26744. private _normals32;
  26745. private _fixedNormal32;
  26746. private _colors32;
  26747. private _uvs32;
  26748. private _index;
  26749. private _updatable;
  26750. private _pickable;
  26751. private _isVisibilityBoxLocked;
  26752. private _alwaysVisible;
  26753. private _depthSort;
  26754. private _expandable;
  26755. private _shapeCounter;
  26756. private _copy;
  26757. private _color;
  26758. private _computeParticleColor;
  26759. private _computeParticleTexture;
  26760. private _computeParticleRotation;
  26761. private _computeParticleVertex;
  26762. private _computeBoundingBox;
  26763. private _depthSortParticles;
  26764. private _camera;
  26765. private _mustUnrotateFixedNormals;
  26766. private _particlesIntersect;
  26767. private _needs32Bits;
  26768. private _isNotBuilt;
  26769. private _lastParticleId;
  26770. private _idxOfId;
  26771. private _multimaterialEnabled;
  26772. private _useModelMaterial;
  26773. private _indicesByMaterial;
  26774. private _materialIndexes;
  26775. private _depthSortFunction;
  26776. private _materialSortFunction;
  26777. private _materials;
  26778. private _multimaterial;
  26779. private _materialIndexesById;
  26780. private _defaultMaterial;
  26781. private _autoUpdateSubMeshes;
  26782. /**
  26783. * Creates a SPS (Solid Particle System) object.
  26784. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26785. * @param scene (Scene) is the scene in which the SPS is added.
  26786. * @param options defines the options of the sps e.g.
  26787. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26788. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26789. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26790. * * 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.
  26791. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26792. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26793. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26794. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26795. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26796. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26797. */
  26798. constructor(name: string, scene: Scene, options?: {
  26799. updatable?: boolean;
  26800. isPickable?: boolean;
  26801. enableDepthSort?: boolean;
  26802. particleIntersection?: boolean;
  26803. boundingSphereOnly?: boolean;
  26804. bSphereRadiusFactor?: number;
  26805. expandable?: boolean;
  26806. useModelMaterial?: boolean;
  26807. enableMultiMaterial?: boolean;
  26808. });
  26809. /**
  26810. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26811. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26812. * @returns the created mesh
  26813. */
  26814. buildMesh(): Mesh;
  26815. /**
  26816. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26817. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26818. * Thus the particles generated from `digest()` have their property `position` set yet.
  26819. * @param mesh ( Mesh ) is the mesh to be digested
  26820. * @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
  26821. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26822. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26823. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26824. * @returns the current SPS
  26825. */
  26826. digest(mesh: Mesh, options?: {
  26827. facetNb?: number;
  26828. number?: number;
  26829. delta?: number;
  26830. storage?: [];
  26831. }): SolidParticleSystem;
  26832. /**
  26833. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26834. * @hidden
  26835. */
  26836. private _unrotateFixedNormals;
  26837. /**
  26838. * Resets the temporary working copy particle
  26839. * @hidden
  26840. */
  26841. private _resetCopy;
  26842. /**
  26843. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26844. * @param p the current index in the positions array to be updated
  26845. * @param ind the current index in the indices array
  26846. * @param shape a Vector3 array, the shape geometry
  26847. * @param positions the positions array to be updated
  26848. * @param meshInd the shape indices array
  26849. * @param indices the indices array to be updated
  26850. * @param meshUV the shape uv array
  26851. * @param uvs the uv array to be updated
  26852. * @param meshCol the shape color array
  26853. * @param colors the color array to be updated
  26854. * @param meshNor the shape normals array
  26855. * @param normals the normals array to be updated
  26856. * @param idx the particle index
  26857. * @param idxInShape the particle index in its shape
  26858. * @param options the addShape() method passed options
  26859. * @model the particle model
  26860. * @hidden
  26861. */
  26862. private _meshBuilder;
  26863. /**
  26864. * Returns a shape Vector3 array from positions float array
  26865. * @param positions float array
  26866. * @returns a vector3 array
  26867. * @hidden
  26868. */
  26869. private _posToShape;
  26870. /**
  26871. * Returns a shapeUV array from a float uvs (array deep copy)
  26872. * @param uvs as a float array
  26873. * @returns a shapeUV array
  26874. * @hidden
  26875. */
  26876. private _uvsToShapeUV;
  26877. /**
  26878. * Adds a new particle object in the particles array
  26879. * @param idx particle index in particles array
  26880. * @param id particle id
  26881. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26882. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26883. * @param model particle ModelShape object
  26884. * @param shapeId model shape identifier
  26885. * @param idxInShape index of the particle in the current model
  26886. * @param bInfo model bounding info object
  26887. * @param storage target storage array, if any
  26888. * @hidden
  26889. */
  26890. private _addParticle;
  26891. /**
  26892. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26893. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26894. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26895. * @param nb (positive integer) the number of particles to be created from this model
  26896. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26897. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26898. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26899. * @returns the number of shapes in the system
  26900. */
  26901. addShape(mesh: Mesh, nb: number, options?: {
  26902. positionFunction?: any;
  26903. vertexFunction?: any;
  26904. storage?: [];
  26905. }): number;
  26906. /**
  26907. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26908. * @hidden
  26909. */
  26910. private _rebuildParticle;
  26911. /**
  26912. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26913. * @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.
  26914. * @returns the SPS.
  26915. */
  26916. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26917. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26918. * Returns an array with the removed particles.
  26919. * 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.
  26920. * The SPS can't be empty so at least one particle needs to remain in place.
  26921. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26922. * @param start index of the first particle to remove
  26923. * @param end index of the last particle to remove (included)
  26924. * @returns an array populated with the removed particles
  26925. */
  26926. removeParticles(start: number, end: number): SolidParticle[];
  26927. /**
  26928. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26929. * @param solidParticleArray an array populated with Solid Particles objects
  26930. * @returns the SPS
  26931. */
  26932. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26933. /**
  26934. * Creates a new particle and modifies the SPS mesh geometry :
  26935. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26936. * - calls _addParticle() to populate the particle array
  26937. * factorized code from addShape() and insertParticlesFromArray()
  26938. * @param idx particle index in the particles array
  26939. * @param i particle index in its shape
  26940. * @param modelShape particle ModelShape object
  26941. * @param shape shape vertex array
  26942. * @param meshInd shape indices array
  26943. * @param meshUV shape uv array
  26944. * @param meshCol shape color array
  26945. * @param meshNor shape normals array
  26946. * @param bbInfo shape bounding info
  26947. * @param storage target particle storage
  26948. * @options addShape() passed options
  26949. * @hidden
  26950. */
  26951. private _insertNewParticle;
  26952. /**
  26953. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26954. * This method calls `updateParticle()` for each particle of the SPS.
  26955. * For an animated SPS, it is usually called within the render loop.
  26956. * 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.
  26957. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26958. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26959. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26960. * @returns the SPS.
  26961. */
  26962. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26963. /**
  26964. * Disposes the SPS.
  26965. */
  26966. dispose(): void;
  26967. /**
  26968. * Returns a SolidParticle object from its identifier : particle.id
  26969. * @param id (integer) the particle Id
  26970. * @returns the searched particle or null if not found in the SPS.
  26971. */
  26972. getParticleById(id: number): Nullable<SolidParticle>;
  26973. /**
  26974. * Returns a new array populated with the particles having the passed shapeId.
  26975. * @param shapeId (integer) the shape identifier
  26976. * @returns a new solid particle array
  26977. */
  26978. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26979. /**
  26980. * Populates the passed array "ref" with the particles having the passed shapeId.
  26981. * @param shapeId the shape identifier
  26982. * @returns the SPS
  26983. * @param ref
  26984. */
  26985. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26986. /**
  26987. * Computes the required SubMeshes according the materials assigned to the particles.
  26988. * @returns the solid particle system.
  26989. * Does nothing if called before the SPS mesh is built.
  26990. */
  26991. computeSubMeshes(): SolidParticleSystem;
  26992. /**
  26993. * Sorts the solid particles by material when MultiMaterial is enabled.
  26994. * Updates the indices32 array.
  26995. * Updates the indicesByMaterial array.
  26996. * Updates the mesh indices array.
  26997. * @returns the SPS
  26998. * @hidden
  26999. */
  27000. private _sortParticlesByMaterial;
  27001. /**
  27002. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27003. * @hidden
  27004. */
  27005. private _setMaterialIndexesById;
  27006. /**
  27007. * Returns an array with unique values of Materials from the passed array
  27008. * @param array the material array to be checked and filtered
  27009. * @hidden
  27010. */
  27011. private _filterUniqueMaterialId;
  27012. /**
  27013. * Sets a new Standard Material as _defaultMaterial if not already set.
  27014. * @hidden
  27015. */
  27016. private _setDefaultMaterial;
  27017. /**
  27018. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27019. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27020. * @returns the SPS.
  27021. */
  27022. refreshVisibleSize(): SolidParticleSystem;
  27023. /**
  27024. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27025. * @param size the size (float) of the visibility box
  27026. * note : this doesn't lock the SPS mesh bounding box.
  27027. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27028. */
  27029. setVisibilityBox(size: number): void;
  27030. /**
  27031. * Gets whether the SPS as always visible or not
  27032. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27033. */
  27034. get isAlwaysVisible(): boolean;
  27035. /**
  27036. * Sets the SPS as always visible or not
  27037. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27038. */
  27039. set isAlwaysVisible(val: boolean);
  27040. /**
  27041. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27042. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27043. */
  27044. set isVisibilityBoxLocked(val: boolean);
  27045. /**
  27046. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27047. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27048. */
  27049. get isVisibilityBoxLocked(): boolean;
  27050. /**
  27051. * Tells to `setParticles()` to compute the particle rotations or not.
  27052. * Default value : true. The SPS is faster when it's set to false.
  27053. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27054. */
  27055. set computeParticleRotation(val: boolean);
  27056. /**
  27057. * Tells to `setParticles()` to compute the particle colors or not.
  27058. * Default value : true. The SPS is faster when it's set to false.
  27059. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27060. */
  27061. set computeParticleColor(val: boolean);
  27062. set computeParticleTexture(val: boolean);
  27063. /**
  27064. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27065. * Default value : false. The SPS is faster when it's set to false.
  27066. * Note : the particle custom vertex positions aren't stored values.
  27067. */
  27068. set computeParticleVertex(val: boolean);
  27069. /**
  27070. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27071. */
  27072. set computeBoundingBox(val: boolean);
  27073. /**
  27074. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27075. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27076. * Default : `true`
  27077. */
  27078. set depthSortParticles(val: boolean);
  27079. /**
  27080. * Gets if `setParticles()` computes the particle rotations or not.
  27081. * Default value : true. The SPS is faster when it's set to false.
  27082. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27083. */
  27084. get computeParticleRotation(): boolean;
  27085. /**
  27086. * Gets if `setParticles()` computes the particle colors or not.
  27087. * Default value : true. The SPS is faster when it's set to false.
  27088. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27089. */
  27090. get computeParticleColor(): boolean;
  27091. /**
  27092. * Gets if `setParticles()` computes the particle textures or not.
  27093. * Default value : true. The SPS is faster when it's set to false.
  27094. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27095. */
  27096. get computeParticleTexture(): boolean;
  27097. /**
  27098. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27099. * Default value : false. The SPS is faster when it's set to false.
  27100. * Note : the particle custom vertex positions aren't stored values.
  27101. */
  27102. get computeParticleVertex(): boolean;
  27103. /**
  27104. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27105. */
  27106. get computeBoundingBox(): boolean;
  27107. /**
  27108. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27109. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27110. * Default : `true`
  27111. */
  27112. get depthSortParticles(): boolean;
  27113. /**
  27114. * Gets if the SPS is created as expandable at construction time.
  27115. * Default : `false`
  27116. */
  27117. get expandable(): boolean;
  27118. /**
  27119. * Gets if the SPS supports the Multi Materials
  27120. */
  27121. get multimaterialEnabled(): boolean;
  27122. /**
  27123. * Gets if the SPS uses the model materials for its own multimaterial.
  27124. */
  27125. get useModelMaterial(): boolean;
  27126. /**
  27127. * The SPS used material array.
  27128. */
  27129. get materials(): Material[];
  27130. /**
  27131. * Sets the SPS MultiMaterial from the passed materials.
  27132. * Note : the passed array is internally copied and not used then by reference.
  27133. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27134. */
  27135. setMultiMaterial(materials: Material[]): void;
  27136. /**
  27137. * The SPS computed multimaterial object
  27138. */
  27139. get multimaterial(): MultiMaterial;
  27140. set multimaterial(mm: MultiMaterial);
  27141. /**
  27142. * If the subMeshes must be updated on the next call to setParticles()
  27143. */
  27144. get autoUpdateSubMeshes(): boolean;
  27145. set autoUpdateSubMeshes(val: boolean);
  27146. /**
  27147. * This function does nothing. It may be overwritten to set all the particle first values.
  27148. * The SPS doesn't call this function, you may have to call it by your own.
  27149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27150. */
  27151. initParticles(): void;
  27152. /**
  27153. * This function does nothing. It may be overwritten to recycle a particle.
  27154. * The SPS doesn't call this function, you may have to call it by your own.
  27155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27156. * @param particle The particle to recycle
  27157. * @returns the recycled particle
  27158. */
  27159. recycleParticle(particle: SolidParticle): SolidParticle;
  27160. /**
  27161. * Updates a particle : this function should be overwritten by the user.
  27162. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27163. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27164. * @example : just set a particle position or velocity and recycle conditions
  27165. * @param particle The particle to update
  27166. * @returns the updated particle
  27167. */
  27168. updateParticle(particle: SolidParticle): SolidParticle;
  27169. /**
  27170. * Updates a vertex of a particle : it can be overwritten by the user.
  27171. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27172. * @param particle the current particle
  27173. * @param vertex the current index of the current particle
  27174. * @param pt the index of the current vertex in the particle shape
  27175. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27176. * @example : just set a vertex particle position
  27177. * @returns the updated vertex
  27178. */
  27179. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27180. /**
  27181. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27182. * This does nothing and may be overwritten by the user.
  27183. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27184. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27185. * @param update the boolean update value actually passed to setParticles()
  27186. */
  27187. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27188. /**
  27189. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27190. * This will be passed three parameters.
  27191. * This does nothing and may be overwritten by the user.
  27192. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27193. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27194. * @param update the boolean update value actually passed to setParticles()
  27195. */
  27196. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27197. }
  27198. }
  27199. declare module BABYLON {
  27200. /**
  27201. * Represents one particle of a solid particle system.
  27202. */
  27203. export class SolidParticle {
  27204. /**
  27205. * particle global index
  27206. */
  27207. idx: number;
  27208. /**
  27209. * particle identifier
  27210. */
  27211. id: number;
  27212. /**
  27213. * The color of the particle
  27214. */
  27215. color: Nullable<Color4>;
  27216. /**
  27217. * The world space position of the particle.
  27218. */
  27219. position: Vector3;
  27220. /**
  27221. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27222. */
  27223. rotation: Vector3;
  27224. /**
  27225. * The world space rotation quaternion of the particle.
  27226. */
  27227. rotationQuaternion: Nullable<Quaternion>;
  27228. /**
  27229. * The scaling of the particle.
  27230. */
  27231. scaling: Vector3;
  27232. /**
  27233. * The uvs of the particle.
  27234. */
  27235. uvs: Vector4;
  27236. /**
  27237. * The current speed of the particle.
  27238. */
  27239. velocity: Vector3;
  27240. /**
  27241. * The pivot point in the particle local space.
  27242. */
  27243. pivot: Vector3;
  27244. /**
  27245. * Must the particle be translated from its pivot point in its local space ?
  27246. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27247. * Default : false
  27248. */
  27249. translateFromPivot: boolean;
  27250. /**
  27251. * Is the particle active or not ?
  27252. */
  27253. alive: boolean;
  27254. /**
  27255. * Is the particle visible or not ?
  27256. */
  27257. isVisible: boolean;
  27258. /**
  27259. * Index of this particle in the global "positions" array (Internal use)
  27260. * @hidden
  27261. */
  27262. _pos: number;
  27263. /**
  27264. * @hidden Index of this particle in the global "indices" array (Internal use)
  27265. */
  27266. _ind: number;
  27267. /**
  27268. * @hidden ModelShape of this particle (Internal use)
  27269. */
  27270. _model: ModelShape;
  27271. /**
  27272. * ModelShape id of this particle
  27273. */
  27274. shapeId: number;
  27275. /**
  27276. * Index of the particle in its shape id
  27277. */
  27278. idxInShape: number;
  27279. /**
  27280. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27281. */
  27282. _modelBoundingInfo: BoundingInfo;
  27283. /**
  27284. * @hidden Particle BoundingInfo object (Internal use)
  27285. */
  27286. _boundingInfo: BoundingInfo;
  27287. /**
  27288. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27289. */
  27290. _sps: SolidParticleSystem;
  27291. /**
  27292. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27293. */
  27294. _stillInvisible: boolean;
  27295. /**
  27296. * @hidden Last computed particle rotation matrix
  27297. */
  27298. _rotationMatrix: number[];
  27299. /**
  27300. * Parent particle Id, if any.
  27301. * Default null.
  27302. */
  27303. parentId: Nullable<number>;
  27304. /**
  27305. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27306. */
  27307. materialIndex: Nullable<number>;
  27308. /**
  27309. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27310. * The possible values are :
  27311. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27312. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27313. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27314. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27315. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27316. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27317. * */
  27318. cullingStrategy: number;
  27319. /**
  27320. * @hidden Internal global position in the SPS.
  27321. */
  27322. _globalPosition: Vector3;
  27323. /**
  27324. * Creates a Solid Particle object.
  27325. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27326. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27327. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27328. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27329. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27330. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27331. * @param shapeId (integer) is the model shape identifier in the SPS.
  27332. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27333. * @param sps defines the sps it is associated to
  27334. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27335. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27336. */
  27337. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27338. /**
  27339. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27340. * @param target the particle target
  27341. * @returns the current particle
  27342. */
  27343. copyToRef(target: SolidParticle): SolidParticle;
  27344. /**
  27345. * Legacy support, changed scale to scaling
  27346. */
  27347. get scale(): Vector3;
  27348. /**
  27349. * Legacy support, changed scale to scaling
  27350. */
  27351. set scale(scale: Vector3);
  27352. /**
  27353. * Legacy support, changed quaternion to rotationQuaternion
  27354. */
  27355. get quaternion(): Nullable<Quaternion>;
  27356. /**
  27357. * Legacy support, changed quaternion to rotationQuaternion
  27358. */
  27359. set quaternion(q: Nullable<Quaternion>);
  27360. /**
  27361. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27362. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27363. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27364. * @returns true if it intersects
  27365. */
  27366. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27367. /**
  27368. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27369. * A particle is in the frustum if its bounding box intersects the frustum
  27370. * @param frustumPlanes defines the frustum to test
  27371. * @returns true if the particle is in the frustum planes
  27372. */
  27373. isInFrustum(frustumPlanes: Plane[]): boolean;
  27374. /**
  27375. * get the rotation matrix of the particle
  27376. * @hidden
  27377. */
  27378. getRotationMatrix(m: Matrix): void;
  27379. }
  27380. /**
  27381. * Represents the shape of the model used by one particle of a solid particle system.
  27382. * SPS internal tool, don't use it manually.
  27383. */
  27384. export class ModelShape {
  27385. /**
  27386. * The shape id
  27387. * @hidden
  27388. */
  27389. shapeID: number;
  27390. /**
  27391. * flat array of model positions (internal use)
  27392. * @hidden
  27393. */
  27394. _shape: Vector3[];
  27395. /**
  27396. * flat array of model UVs (internal use)
  27397. * @hidden
  27398. */
  27399. _shapeUV: number[];
  27400. /**
  27401. * color array of the model
  27402. * @hidden
  27403. */
  27404. _shapeColors: number[];
  27405. /**
  27406. * indices array of the model
  27407. * @hidden
  27408. */
  27409. _indices: number[];
  27410. /**
  27411. * normals array of the model
  27412. * @hidden
  27413. */
  27414. _normals: number[];
  27415. /**
  27416. * length of the shape in the model indices array (internal use)
  27417. * @hidden
  27418. */
  27419. _indicesLength: number;
  27420. /**
  27421. * Custom position function (internal use)
  27422. * @hidden
  27423. */
  27424. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27425. /**
  27426. * Custom vertex function (internal use)
  27427. * @hidden
  27428. */
  27429. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27430. /**
  27431. * Model material (internal use)
  27432. * @hidden
  27433. */
  27434. _material: Nullable<Material>;
  27435. /**
  27436. * 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.
  27437. * SPS internal tool, don't use it manually.
  27438. * @hidden
  27439. */
  27440. 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>);
  27441. }
  27442. /**
  27443. * Represents a Depth Sorted Particle in the solid particle system.
  27444. * @hidden
  27445. */
  27446. export class DepthSortedParticle {
  27447. /**
  27448. * Index of the particle in the "indices" array
  27449. */
  27450. ind: number;
  27451. /**
  27452. * Length of the particle shape in the "indices" array
  27453. */
  27454. indicesLength: number;
  27455. /**
  27456. * Squared distance from the particle to the camera
  27457. */
  27458. sqDistance: number;
  27459. /**
  27460. * Material index when used with MultiMaterials
  27461. */
  27462. materialIndex: number;
  27463. /**
  27464. * Creates a new sorted particle
  27465. * @param materialIndex
  27466. */
  27467. constructor(ind: number, indLength: number, materialIndex: number);
  27468. }
  27469. }
  27470. declare module BABYLON {
  27471. /**
  27472. * @hidden
  27473. */
  27474. export class _MeshCollisionData {
  27475. _checkCollisions: boolean;
  27476. _collisionMask: number;
  27477. _collisionGroup: number;
  27478. _collider: Nullable<Collider>;
  27479. _oldPositionForCollisions: Vector3;
  27480. _diffPositionForCollisions: Vector3;
  27481. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27482. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27483. }
  27484. }
  27485. declare module BABYLON {
  27486. /** @hidden */
  27487. class _FacetDataStorage {
  27488. facetPositions: Vector3[];
  27489. facetNormals: Vector3[];
  27490. facetPartitioning: number[][];
  27491. facetNb: number;
  27492. partitioningSubdivisions: number;
  27493. partitioningBBoxRatio: number;
  27494. facetDataEnabled: boolean;
  27495. facetParameters: any;
  27496. bbSize: Vector3;
  27497. subDiv: {
  27498. max: number;
  27499. X: number;
  27500. Y: number;
  27501. Z: number;
  27502. };
  27503. facetDepthSort: boolean;
  27504. facetDepthSortEnabled: boolean;
  27505. depthSortedIndices: IndicesArray;
  27506. depthSortedFacets: {
  27507. ind: number;
  27508. sqDistance: number;
  27509. }[];
  27510. facetDepthSortFunction: (f1: {
  27511. ind: number;
  27512. sqDistance: number;
  27513. }, f2: {
  27514. ind: number;
  27515. sqDistance: number;
  27516. }) => number;
  27517. facetDepthSortFrom: Vector3;
  27518. facetDepthSortOrigin: Vector3;
  27519. invertedMatrix: Matrix;
  27520. }
  27521. /**
  27522. * @hidden
  27523. **/
  27524. class _InternalAbstractMeshDataInfo {
  27525. _hasVertexAlpha: boolean;
  27526. _useVertexColors: boolean;
  27527. _numBoneInfluencers: number;
  27528. _applyFog: boolean;
  27529. _receiveShadows: boolean;
  27530. _facetData: _FacetDataStorage;
  27531. _visibility: number;
  27532. _skeleton: Nullable<Skeleton>;
  27533. _layerMask: number;
  27534. _computeBonesUsingShaders: boolean;
  27535. _isActive: boolean;
  27536. _onlyForInstances: boolean;
  27537. _isActiveIntermediate: boolean;
  27538. _onlyForInstancesIntermediate: boolean;
  27539. _actAsRegularMesh: boolean;
  27540. }
  27541. /**
  27542. * Class used to store all common mesh properties
  27543. */
  27544. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27545. /** No occlusion */
  27546. static OCCLUSION_TYPE_NONE: number;
  27547. /** Occlusion set to optimisitic */
  27548. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27549. /** Occlusion set to strict */
  27550. static OCCLUSION_TYPE_STRICT: number;
  27551. /** Use an accurante occlusion algorithm */
  27552. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27553. /** Use a conservative occlusion algorithm */
  27554. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27555. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27556. * Test order :
  27557. * Is the bounding sphere outside the frustum ?
  27558. * If not, are the bounding box vertices outside the frustum ?
  27559. * It not, then the cullable object is in the frustum.
  27560. */
  27561. static readonly CULLINGSTRATEGY_STANDARD: number;
  27562. /** Culling strategy : Bounding Sphere Only.
  27563. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27564. * It's also less accurate than the standard because some not visible objects can still be selected.
  27565. * Test : is the bounding sphere outside the frustum ?
  27566. * If not, then the cullable object is in the frustum.
  27567. */
  27568. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27569. /** Culling strategy : Optimistic Inclusion.
  27570. * This in an inclusion test first, then the standard exclusion test.
  27571. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27572. * 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.
  27573. * Anyway, it's as accurate as the standard strategy.
  27574. * Test :
  27575. * Is the cullable object bounding sphere center in the frustum ?
  27576. * If not, apply the default culling strategy.
  27577. */
  27578. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27579. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27580. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27581. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27582. * 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.
  27583. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27584. * Test :
  27585. * Is the cullable object bounding sphere center in the frustum ?
  27586. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27587. */
  27588. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27589. /**
  27590. * No billboard
  27591. */
  27592. static get BILLBOARDMODE_NONE(): number;
  27593. /** Billboard on X axis */
  27594. static get BILLBOARDMODE_X(): number;
  27595. /** Billboard on Y axis */
  27596. static get BILLBOARDMODE_Y(): number;
  27597. /** Billboard on Z axis */
  27598. static get BILLBOARDMODE_Z(): number;
  27599. /** Billboard on all axes */
  27600. static get BILLBOARDMODE_ALL(): number;
  27601. /** Billboard on using position instead of orientation */
  27602. static get BILLBOARDMODE_USE_POSITION(): number;
  27603. /** @hidden */
  27604. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27605. /**
  27606. * The culling strategy to use to check whether the mesh must be rendered or not.
  27607. * This value can be changed at any time and will be used on the next render mesh selection.
  27608. * The possible values are :
  27609. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27610. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27611. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27612. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27613. * Please read each static variable documentation to get details about the culling process.
  27614. * */
  27615. cullingStrategy: number;
  27616. /**
  27617. * Gets the number of facets in the mesh
  27618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27619. */
  27620. get facetNb(): number;
  27621. /**
  27622. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27624. */
  27625. get partitioningSubdivisions(): number;
  27626. set partitioningSubdivisions(nb: number);
  27627. /**
  27628. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27629. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27631. */
  27632. get partitioningBBoxRatio(): number;
  27633. set partitioningBBoxRatio(ratio: number);
  27634. /**
  27635. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27636. * Works only for updatable meshes.
  27637. * Doesn't work with multi-materials
  27638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27639. */
  27640. get mustDepthSortFacets(): boolean;
  27641. set mustDepthSortFacets(sort: boolean);
  27642. /**
  27643. * The location (Vector3) where the facet depth sort must be computed from.
  27644. * By default, the active camera position.
  27645. * Used only when facet depth sort is enabled
  27646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27647. */
  27648. get facetDepthSortFrom(): Vector3;
  27649. set facetDepthSortFrom(location: Vector3);
  27650. /**
  27651. * gets a boolean indicating if facetData is enabled
  27652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27653. */
  27654. get isFacetDataEnabled(): boolean;
  27655. /** @hidden */
  27656. _updateNonUniformScalingState(value: boolean): boolean;
  27657. /**
  27658. * An event triggered when this mesh collides with another one
  27659. */
  27660. onCollideObservable: Observable<AbstractMesh>;
  27661. /** Set a function to call when this mesh collides with another one */
  27662. set onCollide(callback: () => void);
  27663. /**
  27664. * An event triggered when the collision's position changes
  27665. */
  27666. onCollisionPositionChangeObservable: Observable<Vector3>;
  27667. /** Set a function to call when the collision's position changes */
  27668. set onCollisionPositionChange(callback: () => void);
  27669. /**
  27670. * An event triggered when material is changed
  27671. */
  27672. onMaterialChangedObservable: Observable<AbstractMesh>;
  27673. /**
  27674. * Gets or sets the orientation for POV movement & rotation
  27675. */
  27676. definedFacingForward: boolean;
  27677. /** @hidden */
  27678. _occlusionQuery: Nullable<WebGLQuery>;
  27679. /** @hidden */
  27680. _renderingGroup: Nullable<RenderingGroup>;
  27681. /**
  27682. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27683. */
  27684. get visibility(): number;
  27685. /**
  27686. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27687. */
  27688. set visibility(value: number);
  27689. /** Gets or sets the alpha index used to sort transparent meshes
  27690. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27691. */
  27692. alphaIndex: number;
  27693. /**
  27694. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27695. */
  27696. isVisible: boolean;
  27697. /**
  27698. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27699. */
  27700. isPickable: boolean;
  27701. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27702. showSubMeshesBoundingBox: boolean;
  27703. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27705. */
  27706. isBlocker: boolean;
  27707. /**
  27708. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27709. */
  27710. enablePointerMoveEvents: boolean;
  27711. /**
  27712. * Specifies the rendering group id for this mesh (0 by default)
  27713. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27714. */
  27715. renderingGroupId: number;
  27716. private _material;
  27717. /** Gets or sets current material */
  27718. get material(): Nullable<Material>;
  27719. set material(value: Nullable<Material>);
  27720. /**
  27721. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27722. * @see http://doc.babylonjs.com/babylon101/shadows
  27723. */
  27724. get receiveShadows(): boolean;
  27725. set receiveShadows(value: boolean);
  27726. /** Defines color to use when rendering outline */
  27727. outlineColor: Color3;
  27728. /** Define width to use when rendering outline */
  27729. outlineWidth: number;
  27730. /** Defines color to use when rendering overlay */
  27731. overlayColor: Color3;
  27732. /** Defines alpha to use when rendering overlay */
  27733. overlayAlpha: number;
  27734. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27735. get hasVertexAlpha(): boolean;
  27736. set hasVertexAlpha(value: boolean);
  27737. /** 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) */
  27738. get useVertexColors(): boolean;
  27739. set useVertexColors(value: boolean);
  27740. /**
  27741. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27742. */
  27743. get computeBonesUsingShaders(): boolean;
  27744. set computeBonesUsingShaders(value: boolean);
  27745. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27746. get numBoneInfluencers(): number;
  27747. set numBoneInfluencers(value: number);
  27748. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27749. get applyFog(): boolean;
  27750. set applyFog(value: boolean);
  27751. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27752. useOctreeForRenderingSelection: boolean;
  27753. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27754. useOctreeForPicking: boolean;
  27755. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27756. useOctreeForCollisions: boolean;
  27757. /**
  27758. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27759. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27760. */
  27761. get layerMask(): number;
  27762. set layerMask(value: number);
  27763. /**
  27764. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27765. */
  27766. alwaysSelectAsActiveMesh: boolean;
  27767. /**
  27768. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27769. */
  27770. doNotSyncBoundingInfo: boolean;
  27771. /**
  27772. * Gets or sets the current action manager
  27773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27774. */
  27775. actionManager: Nullable<AbstractActionManager>;
  27776. private _meshCollisionData;
  27777. /**
  27778. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27780. */
  27781. ellipsoid: Vector3;
  27782. /**
  27783. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27785. */
  27786. ellipsoidOffset: Vector3;
  27787. /**
  27788. * Gets or sets a collision mask used to mask collisions (default is -1).
  27789. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27790. */
  27791. get collisionMask(): number;
  27792. set collisionMask(mask: number);
  27793. /**
  27794. * Gets or sets the current collision group mask (-1 by default).
  27795. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27796. */
  27797. get collisionGroup(): number;
  27798. set collisionGroup(mask: number);
  27799. /**
  27800. * Defines edge width used when edgesRenderer is enabled
  27801. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27802. */
  27803. edgesWidth: number;
  27804. /**
  27805. * Defines edge color used when edgesRenderer is enabled
  27806. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27807. */
  27808. edgesColor: Color4;
  27809. /** @hidden */
  27810. _edgesRenderer: Nullable<IEdgesRenderer>;
  27811. /** @hidden */
  27812. _masterMesh: Nullable<AbstractMesh>;
  27813. /** @hidden */
  27814. _boundingInfo: Nullable<BoundingInfo>;
  27815. /** @hidden */
  27816. _renderId: number;
  27817. /**
  27818. * Gets or sets the list of subMeshes
  27819. * @see http://doc.babylonjs.com/how_to/multi_materials
  27820. */
  27821. subMeshes: SubMesh[];
  27822. /** @hidden */
  27823. _intersectionsInProgress: AbstractMesh[];
  27824. /** @hidden */
  27825. _unIndexed: boolean;
  27826. /** @hidden */
  27827. _lightSources: Light[];
  27828. /** Gets the list of lights affecting that mesh */
  27829. get lightSources(): Light[];
  27830. /** @hidden */
  27831. get _positions(): Nullable<Vector3[]>;
  27832. /** @hidden */
  27833. _waitingData: {
  27834. lods: Nullable<any>;
  27835. actions: Nullable<any>;
  27836. freezeWorldMatrix: Nullable<boolean>;
  27837. };
  27838. /** @hidden */
  27839. _bonesTransformMatrices: Nullable<Float32Array>;
  27840. /** @hidden */
  27841. _transformMatrixTexture: Nullable<RawTexture>;
  27842. /**
  27843. * Gets or sets a skeleton to apply skining transformations
  27844. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27845. */
  27846. set skeleton(value: Nullable<Skeleton>);
  27847. get skeleton(): Nullable<Skeleton>;
  27848. /**
  27849. * An event triggered when the mesh is rebuilt.
  27850. */
  27851. onRebuildObservable: Observable<AbstractMesh>;
  27852. /**
  27853. * Creates a new AbstractMesh
  27854. * @param name defines the name of the mesh
  27855. * @param scene defines the hosting scene
  27856. */
  27857. constructor(name: string, scene?: Nullable<Scene>);
  27858. /**
  27859. * Returns the string "AbstractMesh"
  27860. * @returns "AbstractMesh"
  27861. */
  27862. getClassName(): string;
  27863. /**
  27864. * Gets a string representation of the current mesh
  27865. * @param fullDetails defines a boolean indicating if full details must be included
  27866. * @returns a string representation of the current mesh
  27867. */
  27868. toString(fullDetails?: boolean): string;
  27869. /**
  27870. * @hidden
  27871. */
  27872. protected _getEffectiveParent(): Nullable<Node>;
  27873. /** @hidden */
  27874. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27875. /** @hidden */
  27876. _rebuild(): void;
  27877. /** @hidden */
  27878. _resyncLightSources(): void;
  27879. /** @hidden */
  27880. _resyncLightSource(light: Light): void;
  27881. /** @hidden */
  27882. _unBindEffect(): void;
  27883. /** @hidden */
  27884. _removeLightSource(light: Light, dispose: boolean): void;
  27885. private _markSubMeshesAsDirty;
  27886. /** @hidden */
  27887. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27888. /** @hidden */
  27889. _markSubMeshesAsAttributesDirty(): void;
  27890. /** @hidden */
  27891. _markSubMeshesAsMiscDirty(): void;
  27892. /**
  27893. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27894. */
  27895. get scaling(): Vector3;
  27896. set scaling(newScaling: Vector3);
  27897. /**
  27898. * Returns true if the mesh is blocked. Implemented by child classes
  27899. */
  27900. get isBlocked(): boolean;
  27901. /**
  27902. * Returns the mesh itself by default. Implemented by child classes
  27903. * @param camera defines the camera to use to pick the right LOD level
  27904. * @returns the currentAbstractMesh
  27905. */
  27906. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27907. /**
  27908. * Returns 0 by default. Implemented by child classes
  27909. * @returns an integer
  27910. */
  27911. getTotalVertices(): number;
  27912. /**
  27913. * Returns a positive integer : the total number of indices in this mesh geometry.
  27914. * @returns the numner of indices or zero if the mesh has no geometry.
  27915. */
  27916. getTotalIndices(): number;
  27917. /**
  27918. * Returns null by default. Implemented by child classes
  27919. * @returns null
  27920. */
  27921. getIndices(): Nullable<IndicesArray>;
  27922. /**
  27923. * Returns the array of the requested vertex data kind. Implemented by child classes
  27924. * @param kind defines the vertex data kind to use
  27925. * @returns null
  27926. */
  27927. getVerticesData(kind: string): Nullable<FloatArray>;
  27928. /**
  27929. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27930. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27931. * Note that a new underlying VertexBuffer object is created each call.
  27932. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27933. * @param kind defines vertex data kind:
  27934. * * VertexBuffer.PositionKind
  27935. * * VertexBuffer.UVKind
  27936. * * VertexBuffer.UV2Kind
  27937. * * VertexBuffer.UV3Kind
  27938. * * VertexBuffer.UV4Kind
  27939. * * VertexBuffer.UV5Kind
  27940. * * VertexBuffer.UV6Kind
  27941. * * VertexBuffer.ColorKind
  27942. * * VertexBuffer.MatricesIndicesKind
  27943. * * VertexBuffer.MatricesIndicesExtraKind
  27944. * * VertexBuffer.MatricesWeightsKind
  27945. * * VertexBuffer.MatricesWeightsExtraKind
  27946. * @param data defines the data source
  27947. * @param updatable defines if the data must be flagged as updatable (or static)
  27948. * @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
  27949. * @returns the current mesh
  27950. */
  27951. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27952. /**
  27953. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27954. * If the mesh has no geometry, it is simply returned as it is.
  27955. * @param kind defines vertex data kind:
  27956. * * VertexBuffer.PositionKind
  27957. * * VertexBuffer.UVKind
  27958. * * VertexBuffer.UV2Kind
  27959. * * VertexBuffer.UV3Kind
  27960. * * VertexBuffer.UV4Kind
  27961. * * VertexBuffer.UV5Kind
  27962. * * VertexBuffer.UV6Kind
  27963. * * VertexBuffer.ColorKind
  27964. * * VertexBuffer.MatricesIndicesKind
  27965. * * VertexBuffer.MatricesIndicesExtraKind
  27966. * * VertexBuffer.MatricesWeightsKind
  27967. * * VertexBuffer.MatricesWeightsExtraKind
  27968. * @param data defines the data source
  27969. * @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
  27970. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27971. * @returns the current mesh
  27972. */
  27973. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27974. /**
  27975. * Sets the mesh indices,
  27976. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27977. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27978. * @param totalVertices Defines the total number of vertices
  27979. * @returns the current mesh
  27980. */
  27981. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27982. /**
  27983. * Gets a boolean indicating if specific vertex data is present
  27984. * @param kind defines the vertex data kind to use
  27985. * @returns true is data kind is present
  27986. */
  27987. isVerticesDataPresent(kind: string): boolean;
  27988. /**
  27989. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27990. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27991. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27992. * @returns a BoundingInfo
  27993. */
  27994. getBoundingInfo(): BoundingInfo;
  27995. /**
  27996. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27997. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27998. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27999. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28000. * @returns the current mesh
  28001. */
  28002. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28003. /**
  28004. * Overwrite the current bounding info
  28005. * @param boundingInfo defines the new bounding info
  28006. * @returns the current mesh
  28007. */
  28008. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28009. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28010. get useBones(): boolean;
  28011. /** @hidden */
  28012. _preActivate(): void;
  28013. /** @hidden */
  28014. _preActivateForIntermediateRendering(renderId: number): void;
  28015. /** @hidden */
  28016. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28017. /** @hidden */
  28018. _postActivate(): void;
  28019. /** @hidden */
  28020. _freeze(): void;
  28021. /** @hidden */
  28022. _unFreeze(): void;
  28023. /**
  28024. * Gets the current world matrix
  28025. * @returns a Matrix
  28026. */
  28027. getWorldMatrix(): Matrix;
  28028. /** @hidden */
  28029. _getWorldMatrixDeterminant(): number;
  28030. /**
  28031. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28032. */
  28033. get isAnInstance(): boolean;
  28034. /**
  28035. * Gets a boolean indicating if this mesh has instances
  28036. */
  28037. get hasInstances(): boolean;
  28038. /**
  28039. * Perform relative position change from the point of view of behind the front of the mesh.
  28040. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28041. * Supports definition of mesh facing forward or backward
  28042. * @param amountRight defines the distance on the right axis
  28043. * @param amountUp defines the distance on the up axis
  28044. * @param amountForward defines the distance on the forward axis
  28045. * @returns the current mesh
  28046. */
  28047. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28048. /**
  28049. * Calculate relative position change from the point of view of behind the front of the mesh.
  28050. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28051. * Supports definition of mesh facing forward or backward
  28052. * @param amountRight defines the distance on the right axis
  28053. * @param amountUp defines the distance on the up axis
  28054. * @param amountForward defines the distance on the forward axis
  28055. * @returns the new displacement vector
  28056. */
  28057. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28058. /**
  28059. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28060. * Supports definition of mesh facing forward or backward
  28061. * @param flipBack defines the flip
  28062. * @param twirlClockwise defines the twirl
  28063. * @param tiltRight defines the tilt
  28064. * @returns the current mesh
  28065. */
  28066. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28067. /**
  28068. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28069. * Supports definition of mesh facing forward or backward.
  28070. * @param flipBack defines the flip
  28071. * @param twirlClockwise defines the twirl
  28072. * @param tiltRight defines the tilt
  28073. * @returns the new rotation vector
  28074. */
  28075. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28076. /**
  28077. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28078. * This means the mesh underlying bounding box and sphere are recomputed.
  28079. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28080. * @returns the current mesh
  28081. */
  28082. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28083. /** @hidden */
  28084. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28085. /** @hidden */
  28086. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28087. /** @hidden */
  28088. _updateBoundingInfo(): AbstractMesh;
  28089. /** @hidden */
  28090. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28091. /** @hidden */
  28092. protected _afterComputeWorldMatrix(): void;
  28093. /** @hidden */
  28094. get _effectiveMesh(): AbstractMesh;
  28095. /**
  28096. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28097. * A mesh is in the frustum if its bounding box intersects the frustum
  28098. * @param frustumPlanes defines the frustum to test
  28099. * @returns true if the mesh is in the frustum planes
  28100. */
  28101. isInFrustum(frustumPlanes: Plane[]): boolean;
  28102. /**
  28103. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28104. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28105. * @param frustumPlanes defines the frustum to test
  28106. * @returns true if the mesh is completely in the frustum planes
  28107. */
  28108. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28109. /**
  28110. * True if the mesh intersects another mesh or a SolidParticle object
  28111. * @param mesh defines a target mesh or SolidParticle to test
  28112. * @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)
  28113. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28114. * @returns true if there is an intersection
  28115. */
  28116. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28117. /**
  28118. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28119. * @param point defines the point to test
  28120. * @returns true if there is an intersection
  28121. */
  28122. intersectsPoint(point: Vector3): boolean;
  28123. /**
  28124. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28126. */
  28127. get checkCollisions(): boolean;
  28128. set checkCollisions(collisionEnabled: boolean);
  28129. /**
  28130. * Gets Collider object used to compute collisions (not physics)
  28131. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28132. */
  28133. get collider(): Nullable<Collider>;
  28134. /**
  28135. * Move the mesh using collision engine
  28136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28137. * @param displacement defines the requested displacement vector
  28138. * @returns the current mesh
  28139. */
  28140. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28141. private _onCollisionPositionChange;
  28142. /** @hidden */
  28143. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28144. /** @hidden */
  28145. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28146. /** @hidden */
  28147. _checkCollision(collider: Collider): AbstractMesh;
  28148. /** @hidden */
  28149. _generatePointsArray(): boolean;
  28150. /**
  28151. * Checks if the passed Ray intersects with the mesh
  28152. * @param ray defines the ray to use
  28153. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28154. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28155. * @returns the picking info
  28156. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28157. */
  28158. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28159. /**
  28160. * Clones the current mesh
  28161. * @param name defines the mesh name
  28162. * @param newParent defines the new mesh parent
  28163. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28164. * @returns the new mesh
  28165. */
  28166. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28167. /**
  28168. * Disposes all the submeshes of the current meshnp
  28169. * @returns the current mesh
  28170. */
  28171. releaseSubMeshes(): AbstractMesh;
  28172. /**
  28173. * Releases resources associated with this abstract mesh.
  28174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28176. */
  28177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28178. /**
  28179. * Adds the passed mesh as a child to the current mesh
  28180. * @param mesh defines the child mesh
  28181. * @returns the current mesh
  28182. */
  28183. addChild(mesh: AbstractMesh): AbstractMesh;
  28184. /**
  28185. * Removes the passed mesh from the current mesh children list
  28186. * @param mesh defines the child mesh
  28187. * @returns the current mesh
  28188. */
  28189. removeChild(mesh: AbstractMesh): AbstractMesh;
  28190. /** @hidden */
  28191. private _initFacetData;
  28192. /**
  28193. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28194. * This method can be called within the render loop.
  28195. * 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
  28196. * @returns the current mesh
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28198. */
  28199. updateFacetData(): AbstractMesh;
  28200. /**
  28201. * Returns the facetLocalNormals array.
  28202. * The normals are expressed in the mesh local spac
  28203. * @returns an array of Vector3
  28204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28205. */
  28206. getFacetLocalNormals(): Vector3[];
  28207. /**
  28208. * Returns the facetLocalPositions array.
  28209. * The facet positions are expressed in the mesh local space
  28210. * @returns an array of Vector3
  28211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28212. */
  28213. getFacetLocalPositions(): Vector3[];
  28214. /**
  28215. * Returns the facetLocalPartioning array
  28216. * @returns an array of array of numbers
  28217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28218. */
  28219. getFacetLocalPartitioning(): number[][];
  28220. /**
  28221. * Returns the i-th facet position in the world system.
  28222. * This method allocates a new Vector3 per call
  28223. * @param i defines the facet index
  28224. * @returns a new Vector3
  28225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28226. */
  28227. getFacetPosition(i: number): Vector3;
  28228. /**
  28229. * Sets the reference Vector3 with the i-th facet position in the world system
  28230. * @param i defines the facet index
  28231. * @param ref defines the target vector
  28232. * @returns the current mesh
  28233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28234. */
  28235. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28236. /**
  28237. * Returns the i-th facet normal in the world system.
  28238. * This method allocates a new Vector3 per call
  28239. * @param i defines the facet index
  28240. * @returns a new Vector3
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28242. */
  28243. getFacetNormal(i: number): Vector3;
  28244. /**
  28245. * Sets the reference Vector3 with the i-th facet normal in the world system
  28246. * @param i defines the facet index
  28247. * @param ref defines the target vector
  28248. * @returns the current mesh
  28249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28250. */
  28251. getFacetNormalToRef(i: number, ref: Vector3): this;
  28252. /**
  28253. * 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)
  28254. * @param x defines x coordinate
  28255. * @param y defines y coordinate
  28256. * @param z defines z coordinate
  28257. * @returns the array of facet indexes
  28258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28259. */
  28260. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28261. /**
  28262. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28263. * @param projected sets as the (x,y,z) world projection on the facet
  28264. * @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
  28265. * @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
  28266. * @param x defines x coordinate
  28267. * @param y defines y coordinate
  28268. * @param z defines z coordinate
  28269. * @returns the face index if found (or null instead)
  28270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28271. */
  28272. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28273. /**
  28274. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28275. * @param projected sets as the (x,y,z) local projection on the facet
  28276. * @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
  28277. * @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
  28278. * @param x defines x coordinate
  28279. * @param y defines y coordinate
  28280. * @param z defines z coordinate
  28281. * @returns the face index if found (or null instead)
  28282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28283. */
  28284. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28285. /**
  28286. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28287. * @returns the parameters
  28288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28289. */
  28290. getFacetDataParameters(): any;
  28291. /**
  28292. * Disables the feature FacetData and frees the related memory
  28293. * @returns the current mesh
  28294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28295. */
  28296. disableFacetData(): AbstractMesh;
  28297. /**
  28298. * Updates the AbstractMesh indices array
  28299. * @param indices defines the data source
  28300. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28301. * @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)
  28302. * @returns the current mesh
  28303. */
  28304. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28305. /**
  28306. * Creates new normals data for the mesh
  28307. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28308. * @returns the current mesh
  28309. */
  28310. createNormals(updatable: boolean): AbstractMesh;
  28311. /**
  28312. * Align the mesh with a normal
  28313. * @param normal defines the normal to use
  28314. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28315. * @returns the current mesh
  28316. */
  28317. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28318. /** @hidden */
  28319. _checkOcclusionQuery(): boolean;
  28320. /**
  28321. * Disables the mesh edge rendering mode
  28322. * @returns the currentAbstractMesh
  28323. */
  28324. disableEdgesRendering(): AbstractMesh;
  28325. /**
  28326. * Enables the edge rendering mode on the mesh.
  28327. * This mode makes the mesh edges visible
  28328. * @param epsilon defines the maximal distance between two angles to detect a face
  28329. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28330. * @returns the currentAbstractMesh
  28331. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28332. */
  28333. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28334. }
  28335. }
  28336. declare module BABYLON {
  28337. /**
  28338. * Interface used to define ActionEvent
  28339. */
  28340. export interface IActionEvent {
  28341. /** The mesh or sprite that triggered the action */
  28342. source: any;
  28343. /** The X mouse cursor position at the time of the event */
  28344. pointerX: number;
  28345. /** The Y mouse cursor position at the time of the event */
  28346. pointerY: number;
  28347. /** The mesh that is currently pointed at (can be null) */
  28348. meshUnderPointer: Nullable<AbstractMesh>;
  28349. /** the original (browser) event that triggered the ActionEvent */
  28350. sourceEvent?: any;
  28351. /** additional data for the event */
  28352. additionalData?: any;
  28353. }
  28354. /**
  28355. * ActionEvent is the event being sent when an action is triggered.
  28356. */
  28357. export class ActionEvent implements IActionEvent {
  28358. /** The mesh or sprite that triggered the action */
  28359. source: any;
  28360. /** The X mouse cursor position at the time of the event */
  28361. pointerX: number;
  28362. /** The Y mouse cursor position at the time of the event */
  28363. pointerY: number;
  28364. /** The mesh that is currently pointed at (can be null) */
  28365. meshUnderPointer: Nullable<AbstractMesh>;
  28366. /** the original (browser) event that triggered the ActionEvent */
  28367. sourceEvent?: any;
  28368. /** additional data for the event */
  28369. additionalData?: any;
  28370. /**
  28371. * Creates a new ActionEvent
  28372. * @param source The mesh or sprite that triggered the action
  28373. * @param pointerX The X mouse cursor position at the time of the event
  28374. * @param pointerY The Y mouse cursor position at the time of the event
  28375. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28376. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28377. * @param additionalData additional data for the event
  28378. */
  28379. constructor(
  28380. /** The mesh or sprite that triggered the action */
  28381. source: any,
  28382. /** The X mouse cursor position at the time of the event */
  28383. pointerX: number,
  28384. /** The Y mouse cursor position at the time of the event */
  28385. pointerY: number,
  28386. /** The mesh that is currently pointed at (can be null) */
  28387. meshUnderPointer: Nullable<AbstractMesh>,
  28388. /** the original (browser) event that triggered the ActionEvent */
  28389. sourceEvent?: any,
  28390. /** additional data for the event */
  28391. additionalData?: any);
  28392. /**
  28393. * Helper function to auto-create an ActionEvent from a source mesh.
  28394. * @param source The source mesh that triggered the event
  28395. * @param evt The original (browser) event
  28396. * @param additionalData additional data for the event
  28397. * @returns the new ActionEvent
  28398. */
  28399. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28400. /**
  28401. * Helper function to auto-create an ActionEvent from a source sprite
  28402. * @param source The source sprite that triggered the event
  28403. * @param scene Scene associated with the sprite
  28404. * @param evt The original (browser) event
  28405. * @param additionalData additional data for the event
  28406. * @returns the new ActionEvent
  28407. */
  28408. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28409. /**
  28410. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28411. * @param scene the scene where the event occurred
  28412. * @param evt The original (browser) event
  28413. * @returns the new ActionEvent
  28414. */
  28415. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28416. /**
  28417. * Helper function to auto-create an ActionEvent from a primitive
  28418. * @param prim defines the target primitive
  28419. * @param pointerPos defines the pointer position
  28420. * @param evt The original (browser) event
  28421. * @param additionalData additional data for the event
  28422. * @returns the new ActionEvent
  28423. */
  28424. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28425. }
  28426. }
  28427. declare module BABYLON {
  28428. /**
  28429. * Abstract class used to decouple action Manager from scene and meshes.
  28430. * Do not instantiate.
  28431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28432. */
  28433. export abstract class AbstractActionManager implements IDisposable {
  28434. /** Gets the list of active triggers */
  28435. static Triggers: {
  28436. [key: string]: number;
  28437. };
  28438. /** Gets the cursor to use when hovering items */
  28439. hoverCursor: string;
  28440. /** Gets the list of actions */
  28441. actions: IAction[];
  28442. /**
  28443. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28444. */
  28445. isRecursive: boolean;
  28446. /**
  28447. * Releases all associated resources
  28448. */
  28449. abstract dispose(): void;
  28450. /**
  28451. * Does this action manager has pointer triggers
  28452. */
  28453. abstract get hasPointerTriggers(): boolean;
  28454. /**
  28455. * Does this action manager has pick triggers
  28456. */
  28457. abstract get hasPickTriggers(): boolean;
  28458. /**
  28459. * Process a specific trigger
  28460. * @param trigger defines the trigger to process
  28461. * @param evt defines the event details to be processed
  28462. */
  28463. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28464. /**
  28465. * Does this action manager handles actions of any of the given triggers
  28466. * @param triggers defines the triggers to be tested
  28467. * @return a boolean indicating whether one (or more) of the triggers is handled
  28468. */
  28469. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28470. /**
  28471. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28472. * speed.
  28473. * @param triggerA defines the trigger to be tested
  28474. * @param triggerB defines the trigger to be tested
  28475. * @return a boolean indicating whether one (or more) of the triggers is handled
  28476. */
  28477. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28478. /**
  28479. * Does this action manager handles actions of a given trigger
  28480. * @param trigger defines the trigger to be tested
  28481. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28482. * @return whether the trigger is handled
  28483. */
  28484. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28485. /**
  28486. * Serialize this manager to a JSON object
  28487. * @param name defines the property name to store this manager
  28488. * @returns a JSON representation of this manager
  28489. */
  28490. abstract serialize(name: string): any;
  28491. /**
  28492. * Registers an action to this action manager
  28493. * @param action defines the action to be registered
  28494. * @return the action amended (prepared) after registration
  28495. */
  28496. abstract registerAction(action: IAction): Nullable<IAction>;
  28497. /**
  28498. * Unregisters an action to this action manager
  28499. * @param action defines the action to be unregistered
  28500. * @return a boolean indicating whether the action has been unregistered
  28501. */
  28502. abstract unregisterAction(action: IAction): Boolean;
  28503. /**
  28504. * Does exist one action manager with at least one trigger
  28505. **/
  28506. static get HasTriggers(): boolean;
  28507. /**
  28508. * Does exist one action manager with at least one pick trigger
  28509. **/
  28510. static get HasPickTriggers(): boolean;
  28511. /**
  28512. * Does exist one action manager that handles actions of a given trigger
  28513. * @param trigger defines the trigger to be tested
  28514. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28515. **/
  28516. static HasSpecificTrigger(trigger: number): boolean;
  28517. }
  28518. }
  28519. declare module BABYLON {
  28520. /**
  28521. * Defines how a node can be built from a string name.
  28522. */
  28523. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28524. /**
  28525. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28526. */
  28527. export class Node implements IBehaviorAware<Node> {
  28528. /** @hidden */
  28529. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28530. private static _NodeConstructors;
  28531. /**
  28532. * Add a new node constructor
  28533. * @param type defines the type name of the node to construct
  28534. * @param constructorFunc defines the constructor function
  28535. */
  28536. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28537. /**
  28538. * Returns a node constructor based on type name
  28539. * @param type defines the type name
  28540. * @param name defines the new node name
  28541. * @param scene defines the hosting scene
  28542. * @param options defines optional options to transmit to constructors
  28543. * @returns the new constructor or null
  28544. */
  28545. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28546. /**
  28547. * Gets or sets the name of the node
  28548. */
  28549. name: string;
  28550. /**
  28551. * Gets or sets the id of the node
  28552. */
  28553. id: string;
  28554. /**
  28555. * Gets or sets the unique id of the node
  28556. */
  28557. uniqueId: number;
  28558. /**
  28559. * Gets or sets a string used to store user defined state for the node
  28560. */
  28561. state: string;
  28562. /**
  28563. * Gets or sets an object used to store user defined information for the node
  28564. */
  28565. metadata: any;
  28566. /**
  28567. * For internal use only. Please do not use.
  28568. */
  28569. reservedDataStore: any;
  28570. /**
  28571. * List of inspectable custom properties (used by the Inspector)
  28572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28573. */
  28574. inspectableCustomProperties: IInspectable[];
  28575. private _doNotSerialize;
  28576. /**
  28577. * Gets or sets a boolean used to define if the node must be serialized
  28578. */
  28579. get doNotSerialize(): boolean;
  28580. set doNotSerialize(value: boolean);
  28581. /** @hidden */
  28582. _isDisposed: boolean;
  28583. /**
  28584. * Gets a list of Animations associated with the node
  28585. */
  28586. animations: Animation[];
  28587. protected _ranges: {
  28588. [name: string]: Nullable<AnimationRange>;
  28589. };
  28590. /**
  28591. * Callback raised when the node is ready to be used
  28592. */
  28593. onReady: Nullable<(node: Node) => void>;
  28594. private _isEnabled;
  28595. private _isParentEnabled;
  28596. private _isReady;
  28597. /** @hidden */
  28598. _currentRenderId: number;
  28599. private _parentUpdateId;
  28600. /** @hidden */
  28601. _childUpdateId: number;
  28602. /** @hidden */
  28603. _waitingParentId: Nullable<string>;
  28604. /** @hidden */
  28605. _scene: Scene;
  28606. /** @hidden */
  28607. _cache: any;
  28608. private _parentNode;
  28609. private _children;
  28610. /** @hidden */
  28611. _worldMatrix: Matrix;
  28612. /** @hidden */
  28613. _worldMatrixDeterminant: number;
  28614. /** @hidden */
  28615. _worldMatrixDeterminantIsDirty: boolean;
  28616. /** @hidden */
  28617. private _sceneRootNodesIndex;
  28618. /**
  28619. * Gets a boolean indicating if the node has been disposed
  28620. * @returns true if the node was disposed
  28621. */
  28622. isDisposed(): boolean;
  28623. /**
  28624. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28625. * @see https://doc.babylonjs.com/how_to/parenting
  28626. */
  28627. set parent(parent: Nullable<Node>);
  28628. get parent(): Nullable<Node>;
  28629. /** @hidden */
  28630. _addToSceneRootNodes(): void;
  28631. /** @hidden */
  28632. _removeFromSceneRootNodes(): void;
  28633. private _animationPropertiesOverride;
  28634. /**
  28635. * Gets or sets the animation properties override
  28636. */
  28637. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28638. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28639. /**
  28640. * Gets a string idenfifying the name of the class
  28641. * @returns "Node" string
  28642. */
  28643. getClassName(): string;
  28644. /** @hidden */
  28645. readonly _isNode: boolean;
  28646. /**
  28647. * An event triggered when the mesh is disposed
  28648. */
  28649. onDisposeObservable: Observable<Node>;
  28650. private _onDisposeObserver;
  28651. /**
  28652. * Sets a callback that will be raised when the node will be disposed
  28653. */
  28654. set onDispose(callback: () => void);
  28655. /**
  28656. * Creates a new Node
  28657. * @param name the name and id to be given to this node
  28658. * @param scene the scene this node will be added to
  28659. */
  28660. constructor(name: string, scene?: Nullable<Scene>);
  28661. /**
  28662. * Gets the scene of the node
  28663. * @returns a scene
  28664. */
  28665. getScene(): Scene;
  28666. /**
  28667. * Gets the engine of the node
  28668. * @returns a Engine
  28669. */
  28670. getEngine(): Engine;
  28671. private _behaviors;
  28672. /**
  28673. * Attach a behavior to the node
  28674. * @see http://doc.babylonjs.com/features/behaviour
  28675. * @param behavior defines the behavior to attach
  28676. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28677. * @returns the current Node
  28678. */
  28679. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28680. /**
  28681. * Remove an attached behavior
  28682. * @see http://doc.babylonjs.com/features/behaviour
  28683. * @param behavior defines the behavior to attach
  28684. * @returns the current Node
  28685. */
  28686. removeBehavior(behavior: Behavior<Node>): Node;
  28687. /**
  28688. * Gets the list of attached behaviors
  28689. * @see http://doc.babylonjs.com/features/behaviour
  28690. */
  28691. get behaviors(): Behavior<Node>[];
  28692. /**
  28693. * Gets an attached behavior by name
  28694. * @param name defines the name of the behavior to look for
  28695. * @see http://doc.babylonjs.com/features/behaviour
  28696. * @returns null if behavior was not found else the requested behavior
  28697. */
  28698. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28699. /**
  28700. * Returns the latest update of the World matrix
  28701. * @returns a Matrix
  28702. */
  28703. getWorldMatrix(): Matrix;
  28704. /** @hidden */
  28705. _getWorldMatrixDeterminant(): number;
  28706. /**
  28707. * Returns directly the latest state of the mesh World matrix.
  28708. * A Matrix is returned.
  28709. */
  28710. get worldMatrixFromCache(): Matrix;
  28711. /** @hidden */
  28712. _initCache(): void;
  28713. /** @hidden */
  28714. updateCache(force?: boolean): void;
  28715. /** @hidden */
  28716. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28717. /** @hidden */
  28718. _updateCache(ignoreParentClass?: boolean): void;
  28719. /** @hidden */
  28720. _isSynchronized(): boolean;
  28721. /** @hidden */
  28722. _markSyncedWithParent(): void;
  28723. /** @hidden */
  28724. isSynchronizedWithParent(): boolean;
  28725. /** @hidden */
  28726. isSynchronized(): boolean;
  28727. /**
  28728. * Is this node ready to be used/rendered
  28729. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28730. * @return true if the node is ready
  28731. */
  28732. isReady(completeCheck?: boolean): boolean;
  28733. /**
  28734. * Is this node enabled?
  28735. * 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
  28736. * @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
  28737. * @return whether this node (and its parent) is enabled
  28738. */
  28739. isEnabled(checkAncestors?: boolean): boolean;
  28740. /** @hidden */
  28741. protected _syncParentEnabledState(): void;
  28742. /**
  28743. * Set the enabled state of this node
  28744. * @param value defines the new enabled state
  28745. */
  28746. setEnabled(value: boolean): void;
  28747. /**
  28748. * Is this node a descendant of the given node?
  28749. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28750. * @param ancestor defines the parent node to inspect
  28751. * @returns a boolean indicating if this node is a descendant of the given node
  28752. */
  28753. isDescendantOf(ancestor: Node): boolean;
  28754. /** @hidden */
  28755. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28756. /**
  28757. * Will return all nodes that have this node as ascendant
  28758. * @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
  28759. * @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
  28760. * @return all children nodes of all types
  28761. */
  28762. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28763. /**
  28764. * Get all child-meshes of this node
  28765. * @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)
  28766. * @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
  28767. * @returns an array of AbstractMesh
  28768. */
  28769. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28770. /**
  28771. * Get all direct children of this node
  28772. * @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
  28773. * @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)
  28774. * @returns an array of Node
  28775. */
  28776. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28777. /** @hidden */
  28778. _setReady(state: boolean): void;
  28779. /**
  28780. * Get an animation by name
  28781. * @param name defines the name of the animation to look for
  28782. * @returns null if not found else the requested animation
  28783. */
  28784. getAnimationByName(name: string): Nullable<Animation>;
  28785. /**
  28786. * Creates an animation range for this node
  28787. * @param name defines the name of the range
  28788. * @param from defines the starting key
  28789. * @param to defines the end key
  28790. */
  28791. createAnimationRange(name: string, from: number, to: number): void;
  28792. /**
  28793. * Delete a specific animation range
  28794. * @param name defines the name of the range to delete
  28795. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28796. */
  28797. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28798. /**
  28799. * Get an animation range by name
  28800. * @param name defines the name of the animation range to look for
  28801. * @returns null if not found else the requested animation range
  28802. */
  28803. getAnimationRange(name: string): Nullable<AnimationRange>;
  28804. /**
  28805. * Gets the list of all animation ranges defined on this node
  28806. * @returns an array
  28807. */
  28808. getAnimationRanges(): Nullable<AnimationRange>[];
  28809. /**
  28810. * Will start the animation sequence
  28811. * @param name defines the range frames for animation sequence
  28812. * @param loop defines if the animation should loop (false by default)
  28813. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28814. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28815. * @returns the object created for this animation. If range does not exist, it will return null
  28816. */
  28817. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28818. /**
  28819. * Serialize animation ranges into a JSON compatible object
  28820. * @returns serialization object
  28821. */
  28822. serializeAnimationRanges(): any;
  28823. /**
  28824. * Computes the world matrix of the node
  28825. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28826. * @returns the world matrix
  28827. */
  28828. computeWorldMatrix(force?: boolean): Matrix;
  28829. /**
  28830. * Releases resources associated with this node.
  28831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28833. */
  28834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28835. /**
  28836. * Parse animation range data from a serialization object and store them into a given node
  28837. * @param node defines where to store the animation ranges
  28838. * @param parsedNode defines the serialization object to read data from
  28839. * @param scene defines the hosting scene
  28840. */
  28841. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28842. /**
  28843. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28844. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28845. * @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
  28846. * @returns the new bounding vectors
  28847. */
  28848. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28849. min: Vector3;
  28850. max: Vector3;
  28851. };
  28852. }
  28853. }
  28854. declare module BABYLON {
  28855. /**
  28856. * @hidden
  28857. */
  28858. export class _IAnimationState {
  28859. key: number;
  28860. repeatCount: number;
  28861. workValue?: any;
  28862. loopMode?: number;
  28863. offsetValue?: any;
  28864. highLimitValue?: any;
  28865. }
  28866. /**
  28867. * Class used to store any kind of animation
  28868. */
  28869. export class Animation {
  28870. /**Name of the animation */
  28871. name: string;
  28872. /**Property to animate */
  28873. targetProperty: string;
  28874. /**The frames per second of the animation */
  28875. framePerSecond: number;
  28876. /**The data type of the animation */
  28877. dataType: number;
  28878. /**The loop mode of the animation */
  28879. loopMode?: number | undefined;
  28880. /**Specifies if blending should be enabled */
  28881. enableBlending?: boolean | undefined;
  28882. /**
  28883. * Use matrix interpolation instead of using direct key value when animating matrices
  28884. */
  28885. static AllowMatricesInterpolation: boolean;
  28886. /**
  28887. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28888. */
  28889. static AllowMatrixDecomposeForInterpolation: boolean;
  28890. /**
  28891. * Stores the key frames of the animation
  28892. */
  28893. private _keys;
  28894. /**
  28895. * Stores the easing function of the animation
  28896. */
  28897. private _easingFunction;
  28898. /**
  28899. * @hidden Internal use only
  28900. */
  28901. _runtimeAnimations: RuntimeAnimation[];
  28902. /**
  28903. * The set of event that will be linked to this animation
  28904. */
  28905. private _events;
  28906. /**
  28907. * Stores an array of target property paths
  28908. */
  28909. targetPropertyPath: string[];
  28910. /**
  28911. * Stores the blending speed of the animation
  28912. */
  28913. blendingSpeed: number;
  28914. /**
  28915. * Stores the animation ranges for the animation
  28916. */
  28917. private _ranges;
  28918. /**
  28919. * @hidden Internal use
  28920. */
  28921. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28922. /**
  28923. * Sets up an animation
  28924. * @param property The property to animate
  28925. * @param animationType The animation type to apply
  28926. * @param framePerSecond The frames per second of the animation
  28927. * @param easingFunction The easing function used in the animation
  28928. * @returns The created animation
  28929. */
  28930. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28931. /**
  28932. * Create and start an animation on a node
  28933. * @param name defines the name of the global animation that will be run on all nodes
  28934. * @param node defines the root node where the animation will take place
  28935. * @param targetProperty defines property to animate
  28936. * @param framePerSecond defines the number of frame per second yo use
  28937. * @param totalFrame defines the number of frames in total
  28938. * @param from defines the initial value
  28939. * @param to defines the final value
  28940. * @param loopMode defines which loop mode you want to use (off by default)
  28941. * @param easingFunction defines the easing function to use (linear by default)
  28942. * @param onAnimationEnd defines the callback to call when animation end
  28943. * @returns the animatable created for this animation
  28944. */
  28945. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28946. /**
  28947. * Create and start an animation on a node and its descendants
  28948. * @param name defines the name of the global animation that will be run on all nodes
  28949. * @param node defines the root node where the animation will take place
  28950. * @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
  28951. * @param targetProperty defines property to animate
  28952. * @param framePerSecond defines the number of frame per second to use
  28953. * @param totalFrame defines the number of frames in total
  28954. * @param from defines the initial value
  28955. * @param to defines the final value
  28956. * @param loopMode defines which loop mode you want to use (off by default)
  28957. * @param easingFunction defines the easing function to use (linear by default)
  28958. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28959. * @returns the list of animatables created for all nodes
  28960. * @example https://www.babylonjs-playground.com/#MH0VLI
  28961. */
  28962. 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[]>;
  28963. /**
  28964. * Creates a new animation, merges it with the existing animations and starts it
  28965. * @param name Name of the animation
  28966. * @param node Node which contains the scene that begins the animations
  28967. * @param targetProperty Specifies which property to animate
  28968. * @param framePerSecond The frames per second of the animation
  28969. * @param totalFrame The total number of frames
  28970. * @param from The frame at the beginning of the animation
  28971. * @param to The frame at the end of the animation
  28972. * @param loopMode Specifies the loop mode of the animation
  28973. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28974. * @param onAnimationEnd Callback to run once the animation is complete
  28975. * @returns Nullable animation
  28976. */
  28977. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28978. /**
  28979. * Transition property of an host to the target Value
  28980. * @param property The property to transition
  28981. * @param targetValue The target Value of the property
  28982. * @param host The object where the property to animate belongs
  28983. * @param scene Scene used to run the animation
  28984. * @param frameRate Framerate (in frame/s) to use
  28985. * @param transition The transition type we want to use
  28986. * @param duration The duration of the animation, in milliseconds
  28987. * @param onAnimationEnd Callback trigger at the end of the animation
  28988. * @returns Nullable animation
  28989. */
  28990. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28991. /**
  28992. * Return the array of runtime animations currently using this animation
  28993. */
  28994. get runtimeAnimations(): RuntimeAnimation[];
  28995. /**
  28996. * Specifies if any of the runtime animations are currently running
  28997. */
  28998. get hasRunningRuntimeAnimations(): boolean;
  28999. /**
  29000. * Initializes the animation
  29001. * @param name Name of the animation
  29002. * @param targetProperty Property to animate
  29003. * @param framePerSecond The frames per second of the animation
  29004. * @param dataType The data type of the animation
  29005. * @param loopMode The loop mode of the animation
  29006. * @param enableBlending Specifies if blending should be enabled
  29007. */
  29008. constructor(
  29009. /**Name of the animation */
  29010. name: string,
  29011. /**Property to animate */
  29012. targetProperty: string,
  29013. /**The frames per second of the animation */
  29014. framePerSecond: number,
  29015. /**The data type of the animation */
  29016. dataType: number,
  29017. /**The loop mode of the animation */
  29018. loopMode?: number | undefined,
  29019. /**Specifies if blending should be enabled */
  29020. enableBlending?: boolean | undefined);
  29021. /**
  29022. * Converts the animation to a string
  29023. * @param fullDetails support for multiple levels of logging within scene loading
  29024. * @returns String form of the animation
  29025. */
  29026. toString(fullDetails?: boolean): string;
  29027. /**
  29028. * Add an event to this animation
  29029. * @param event Event to add
  29030. */
  29031. addEvent(event: AnimationEvent): void;
  29032. /**
  29033. * Remove all events found at the given frame
  29034. * @param frame The frame to remove events from
  29035. */
  29036. removeEvents(frame: number): void;
  29037. /**
  29038. * Retrieves all the events from the animation
  29039. * @returns Events from the animation
  29040. */
  29041. getEvents(): AnimationEvent[];
  29042. /**
  29043. * Creates an animation range
  29044. * @param name Name of the animation range
  29045. * @param from Starting frame of the animation range
  29046. * @param to Ending frame of the animation
  29047. */
  29048. createRange(name: string, from: number, to: number): void;
  29049. /**
  29050. * Deletes an animation range by name
  29051. * @param name Name of the animation range to delete
  29052. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29053. */
  29054. deleteRange(name: string, deleteFrames?: boolean): void;
  29055. /**
  29056. * Gets the animation range by name, or null if not defined
  29057. * @param name Name of the animation range
  29058. * @returns Nullable animation range
  29059. */
  29060. getRange(name: string): Nullable<AnimationRange>;
  29061. /**
  29062. * Gets the key frames from the animation
  29063. * @returns The key frames of the animation
  29064. */
  29065. getKeys(): Array<IAnimationKey>;
  29066. /**
  29067. * Gets the highest frame rate of the animation
  29068. * @returns Highest frame rate of the animation
  29069. */
  29070. getHighestFrame(): number;
  29071. /**
  29072. * Gets the easing function of the animation
  29073. * @returns Easing function of the animation
  29074. */
  29075. getEasingFunction(): IEasingFunction;
  29076. /**
  29077. * Sets the easing function of the animation
  29078. * @param easingFunction A custom mathematical formula for animation
  29079. */
  29080. setEasingFunction(easingFunction: EasingFunction): void;
  29081. /**
  29082. * Interpolates a scalar linearly
  29083. * @param startValue Start value of the animation curve
  29084. * @param endValue End value of the animation curve
  29085. * @param gradient Scalar amount to interpolate
  29086. * @returns Interpolated scalar value
  29087. */
  29088. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29089. /**
  29090. * Interpolates a scalar cubically
  29091. * @param startValue Start value of the animation curve
  29092. * @param outTangent End tangent of the animation
  29093. * @param endValue End value of the animation curve
  29094. * @param inTangent Start tangent of the animation curve
  29095. * @param gradient Scalar amount to interpolate
  29096. * @returns Interpolated scalar value
  29097. */
  29098. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29099. /**
  29100. * Interpolates a quaternion using a spherical linear interpolation
  29101. * @param startValue Start value of the animation curve
  29102. * @param endValue End value of the animation curve
  29103. * @param gradient Scalar amount to interpolate
  29104. * @returns Interpolated quaternion value
  29105. */
  29106. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29107. /**
  29108. * Interpolates a quaternion cubically
  29109. * @param startValue Start value of the animation curve
  29110. * @param outTangent End tangent of the animation curve
  29111. * @param endValue End value of the animation curve
  29112. * @param inTangent Start tangent of the animation curve
  29113. * @param gradient Scalar amount to interpolate
  29114. * @returns Interpolated quaternion value
  29115. */
  29116. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29117. /**
  29118. * Interpolates a Vector3 linearl
  29119. * @param startValue Start value of the animation curve
  29120. * @param endValue End value of the animation curve
  29121. * @param gradient Scalar amount to interpolate
  29122. * @returns Interpolated scalar value
  29123. */
  29124. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29125. /**
  29126. * Interpolates a Vector3 cubically
  29127. * @param startValue Start value of the animation curve
  29128. * @param outTangent End tangent of the animation
  29129. * @param endValue End value of the animation curve
  29130. * @param inTangent Start tangent of the animation curve
  29131. * @param gradient Scalar amount to interpolate
  29132. * @returns InterpolatedVector3 value
  29133. */
  29134. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29135. /**
  29136. * Interpolates a Vector2 linearly
  29137. * @param startValue Start value of the animation curve
  29138. * @param endValue End value of the animation curve
  29139. * @param gradient Scalar amount to interpolate
  29140. * @returns Interpolated Vector2 value
  29141. */
  29142. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29143. /**
  29144. * Interpolates a Vector2 cubically
  29145. * @param startValue Start value of the animation curve
  29146. * @param outTangent End tangent of the animation
  29147. * @param endValue End value of the animation curve
  29148. * @param inTangent Start tangent of the animation curve
  29149. * @param gradient Scalar amount to interpolate
  29150. * @returns Interpolated Vector2 value
  29151. */
  29152. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29153. /**
  29154. * Interpolates a size linearly
  29155. * @param startValue Start value of the animation curve
  29156. * @param endValue End value of the animation curve
  29157. * @param gradient Scalar amount to interpolate
  29158. * @returns Interpolated Size value
  29159. */
  29160. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29161. /**
  29162. * Interpolates a Color3 linearly
  29163. * @param startValue Start value of the animation curve
  29164. * @param endValue End value of the animation curve
  29165. * @param gradient Scalar amount to interpolate
  29166. * @returns Interpolated Color3 value
  29167. */
  29168. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29169. /**
  29170. * Interpolates a Color4 linearly
  29171. * @param startValue Start value of the animation curve
  29172. * @param endValue End value of the animation curve
  29173. * @param gradient Scalar amount to interpolate
  29174. * @returns Interpolated Color3 value
  29175. */
  29176. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29177. /**
  29178. * @hidden Internal use only
  29179. */
  29180. _getKeyValue(value: any): any;
  29181. /**
  29182. * @hidden Internal use only
  29183. */
  29184. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29185. /**
  29186. * Defines the function to use to interpolate matrices
  29187. * @param startValue defines the start matrix
  29188. * @param endValue defines the end matrix
  29189. * @param gradient defines the gradient between both matrices
  29190. * @param result defines an optional target matrix where to store the interpolation
  29191. * @returns the interpolated matrix
  29192. */
  29193. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29194. /**
  29195. * Makes a copy of the animation
  29196. * @returns Cloned animation
  29197. */
  29198. clone(): Animation;
  29199. /**
  29200. * Sets the key frames of the animation
  29201. * @param values The animation key frames to set
  29202. */
  29203. setKeys(values: Array<IAnimationKey>): void;
  29204. /**
  29205. * Serializes the animation to an object
  29206. * @returns Serialized object
  29207. */
  29208. serialize(): any;
  29209. /**
  29210. * Float animation type
  29211. */
  29212. static readonly ANIMATIONTYPE_FLOAT: number;
  29213. /**
  29214. * Vector3 animation type
  29215. */
  29216. static readonly ANIMATIONTYPE_VECTOR3: number;
  29217. /**
  29218. * Quaternion animation type
  29219. */
  29220. static readonly ANIMATIONTYPE_QUATERNION: number;
  29221. /**
  29222. * Matrix animation type
  29223. */
  29224. static readonly ANIMATIONTYPE_MATRIX: number;
  29225. /**
  29226. * Color3 animation type
  29227. */
  29228. static readonly ANIMATIONTYPE_COLOR3: number;
  29229. /**
  29230. * Color3 animation type
  29231. */
  29232. static readonly ANIMATIONTYPE_COLOR4: number;
  29233. /**
  29234. * Vector2 animation type
  29235. */
  29236. static readonly ANIMATIONTYPE_VECTOR2: number;
  29237. /**
  29238. * Size animation type
  29239. */
  29240. static readonly ANIMATIONTYPE_SIZE: number;
  29241. /**
  29242. * Relative Loop Mode
  29243. */
  29244. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29245. /**
  29246. * Cycle Loop Mode
  29247. */
  29248. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29249. /**
  29250. * Constant Loop Mode
  29251. */
  29252. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29253. /** @hidden */
  29254. static _UniversalLerp(left: any, right: any, amount: number): any;
  29255. /**
  29256. * Parses an animation object and creates an animation
  29257. * @param parsedAnimation Parsed animation object
  29258. * @returns Animation object
  29259. */
  29260. static Parse(parsedAnimation: any): Animation;
  29261. /**
  29262. * Appends the serialized animations from the source animations
  29263. * @param source Source containing the animations
  29264. * @param destination Target to store the animations
  29265. */
  29266. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29267. }
  29268. }
  29269. declare module BABYLON {
  29270. /**
  29271. * Interface containing an array of animations
  29272. */
  29273. export interface IAnimatable {
  29274. /**
  29275. * Array of animations
  29276. */
  29277. animations: Nullable<Array<Animation>>;
  29278. }
  29279. }
  29280. declare module BABYLON {
  29281. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29282. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29283. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29284. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29285. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29286. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29287. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29288. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29289. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29290. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29291. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29292. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29293. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29294. /**
  29295. * Decorator used to define property that can be serialized as reference to a camera
  29296. * @param sourceName defines the name of the property to decorate
  29297. */
  29298. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29299. /**
  29300. * Class used to help serialization objects
  29301. */
  29302. export class SerializationHelper {
  29303. /** @hidden */
  29304. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29305. /** @hidden */
  29306. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29307. /** @hidden */
  29308. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29309. /** @hidden */
  29310. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29311. /**
  29312. * Appends the serialized animations from the source animations
  29313. * @param source Source containing the animations
  29314. * @param destination Target to store the animations
  29315. */
  29316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29317. /**
  29318. * Static function used to serialized a specific entity
  29319. * @param entity defines the entity to serialize
  29320. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29321. * @returns a JSON compatible object representing the serialization of the entity
  29322. */
  29323. static Serialize<T>(entity: T, serializationObject?: any): any;
  29324. /**
  29325. * Creates a new entity from a serialization data object
  29326. * @param creationFunction defines a function used to instanciated the new entity
  29327. * @param source defines the source serialization data
  29328. * @param scene defines the hosting scene
  29329. * @param rootUrl defines the root url for resources
  29330. * @returns a new entity
  29331. */
  29332. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29333. /**
  29334. * Clones an object
  29335. * @param creationFunction defines the function used to instanciate the new object
  29336. * @param source defines the source object
  29337. * @returns the cloned object
  29338. */
  29339. static Clone<T>(creationFunction: () => T, source: T): T;
  29340. /**
  29341. * Instanciates a new object based on a source one (some data will be shared between both object)
  29342. * @param creationFunction defines the function used to instanciate the new object
  29343. * @param source defines the source object
  29344. * @returns the new object
  29345. */
  29346. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29347. }
  29348. }
  29349. declare module BABYLON {
  29350. /**
  29351. * Class used to manipulate GUIDs
  29352. */
  29353. export class GUID {
  29354. /**
  29355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29356. * Be aware Math.random() could cause collisions, but:
  29357. * "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"
  29358. * @returns a pseudo random id
  29359. */
  29360. static RandomId(): string;
  29361. }
  29362. }
  29363. declare module BABYLON {
  29364. /**
  29365. * Base class of all the textures in babylon.
  29366. * It groups all the common properties the materials, post process, lights... might need
  29367. * in order to make a correct use of the texture.
  29368. */
  29369. export class BaseTexture implements IAnimatable {
  29370. /**
  29371. * Default anisotropic filtering level for the application.
  29372. * It is set to 4 as a good tradeoff between perf and quality.
  29373. */
  29374. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29375. /**
  29376. * Gets or sets the unique id of the texture
  29377. */
  29378. uniqueId: number;
  29379. /**
  29380. * Define the name of the texture.
  29381. */
  29382. name: string;
  29383. /**
  29384. * Gets or sets an object used to store user defined information.
  29385. */
  29386. metadata: any;
  29387. /**
  29388. * For internal use only. Please do not use.
  29389. */
  29390. reservedDataStore: any;
  29391. private _hasAlpha;
  29392. /**
  29393. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29394. */
  29395. set hasAlpha(value: boolean);
  29396. get hasAlpha(): boolean;
  29397. /**
  29398. * Defines if the alpha value should be determined via the rgb values.
  29399. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29400. */
  29401. getAlphaFromRGB: boolean;
  29402. /**
  29403. * Intensity or strength of the texture.
  29404. * It is commonly used by materials to fine tune the intensity of the texture
  29405. */
  29406. level: number;
  29407. /**
  29408. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29409. * This is part of the texture as textures usually maps to one uv set.
  29410. */
  29411. coordinatesIndex: number;
  29412. private _coordinatesMode;
  29413. /**
  29414. * How a texture is mapped.
  29415. *
  29416. * | Value | Type | Description |
  29417. * | ----- | ----------------------------------- | ----------- |
  29418. * | 0 | EXPLICIT_MODE | |
  29419. * | 1 | SPHERICAL_MODE | |
  29420. * | 2 | PLANAR_MODE | |
  29421. * | 3 | CUBIC_MODE | |
  29422. * | 4 | PROJECTION_MODE | |
  29423. * | 5 | SKYBOX_MODE | |
  29424. * | 6 | INVCUBIC_MODE | |
  29425. * | 7 | EQUIRECTANGULAR_MODE | |
  29426. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29427. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29428. */
  29429. set coordinatesMode(value: number);
  29430. get coordinatesMode(): number;
  29431. /**
  29432. * | Value | Type | Description |
  29433. * | ----- | ------------------ | ----------- |
  29434. * | 0 | CLAMP_ADDRESSMODE | |
  29435. * | 1 | WRAP_ADDRESSMODE | |
  29436. * | 2 | MIRROR_ADDRESSMODE | |
  29437. */
  29438. wrapU: number;
  29439. /**
  29440. * | Value | Type | Description |
  29441. * | ----- | ------------------ | ----------- |
  29442. * | 0 | CLAMP_ADDRESSMODE | |
  29443. * | 1 | WRAP_ADDRESSMODE | |
  29444. * | 2 | MIRROR_ADDRESSMODE | |
  29445. */
  29446. wrapV: number;
  29447. /**
  29448. * | Value | Type | Description |
  29449. * | ----- | ------------------ | ----------- |
  29450. * | 0 | CLAMP_ADDRESSMODE | |
  29451. * | 1 | WRAP_ADDRESSMODE | |
  29452. * | 2 | MIRROR_ADDRESSMODE | |
  29453. */
  29454. wrapR: number;
  29455. /**
  29456. * With compliant hardware and browser (supporting anisotropic filtering)
  29457. * this defines the level of anisotropic filtering in the texture.
  29458. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29459. */
  29460. anisotropicFilteringLevel: number;
  29461. /**
  29462. * Define if the texture is a cube texture or if false a 2d texture.
  29463. */
  29464. get isCube(): boolean;
  29465. set isCube(value: boolean);
  29466. /**
  29467. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29468. */
  29469. get is3D(): boolean;
  29470. set is3D(value: boolean);
  29471. /**
  29472. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29473. */
  29474. get is2DArray(): boolean;
  29475. set is2DArray(value: boolean);
  29476. /**
  29477. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29478. * HDR texture are usually stored in linear space.
  29479. * This only impacts the PBR and Background materials
  29480. */
  29481. gammaSpace: boolean;
  29482. /**
  29483. * Gets or sets whether or not the texture contains RGBD data.
  29484. */
  29485. get isRGBD(): boolean;
  29486. set isRGBD(value: boolean);
  29487. /**
  29488. * Is Z inverted in the texture (useful in a cube texture).
  29489. */
  29490. invertZ: boolean;
  29491. /**
  29492. * Are mip maps generated for this texture or not.
  29493. */
  29494. get noMipmap(): boolean;
  29495. /**
  29496. * @hidden
  29497. */
  29498. lodLevelInAlpha: boolean;
  29499. /**
  29500. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29501. */
  29502. get lodGenerationOffset(): number;
  29503. set lodGenerationOffset(value: number);
  29504. /**
  29505. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29506. */
  29507. get lodGenerationScale(): number;
  29508. set lodGenerationScale(value: number);
  29509. /**
  29510. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29511. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29512. * average roughness values.
  29513. */
  29514. get linearSpecularLOD(): boolean;
  29515. set linearSpecularLOD(value: boolean);
  29516. /**
  29517. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29518. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29519. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29520. */
  29521. get irradianceTexture(): Nullable<BaseTexture>;
  29522. set irradianceTexture(value: Nullable<BaseTexture>);
  29523. /**
  29524. * Define if the texture is a render target.
  29525. */
  29526. isRenderTarget: boolean;
  29527. /**
  29528. * Define the unique id of the texture in the scene.
  29529. */
  29530. get uid(): string;
  29531. /**
  29532. * Return a string representation of the texture.
  29533. * @returns the texture as a string
  29534. */
  29535. toString(): string;
  29536. /**
  29537. * Get the class name of the texture.
  29538. * @returns "BaseTexture"
  29539. */
  29540. getClassName(): string;
  29541. /**
  29542. * Define the list of animation attached to the texture.
  29543. */
  29544. animations: Animation[];
  29545. /**
  29546. * An event triggered when the texture is disposed.
  29547. */
  29548. onDisposeObservable: Observable<BaseTexture>;
  29549. private _onDisposeObserver;
  29550. /**
  29551. * Callback triggered when the texture has been disposed.
  29552. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29553. */
  29554. set onDispose(callback: () => void);
  29555. /**
  29556. * Define the current state of the loading sequence when in delayed load mode.
  29557. */
  29558. delayLoadState: number;
  29559. private _scene;
  29560. /** @hidden */
  29561. _texture: Nullable<InternalTexture>;
  29562. private _uid;
  29563. /**
  29564. * Define if the texture is preventinga material to render or not.
  29565. * If not and the texture is not ready, the engine will use a default black texture instead.
  29566. */
  29567. get isBlocking(): boolean;
  29568. /**
  29569. * Instantiates a new BaseTexture.
  29570. * Base class of all the textures in babylon.
  29571. * It groups all the common properties the materials, post process, lights... might need
  29572. * in order to make a correct use of the texture.
  29573. * @param scene Define the scene the texture blongs to
  29574. */
  29575. constructor(scene: Nullable<Scene>);
  29576. /**
  29577. * Get the scene the texture belongs to.
  29578. * @returns the scene or null if undefined
  29579. */
  29580. getScene(): Nullable<Scene>;
  29581. /**
  29582. * Get the texture transform matrix used to offset tile the texture for istance.
  29583. * @returns the transformation matrix
  29584. */
  29585. getTextureMatrix(): Matrix;
  29586. /**
  29587. * Get the texture reflection matrix used to rotate/transform the reflection.
  29588. * @returns the reflection matrix
  29589. */
  29590. getReflectionTextureMatrix(): Matrix;
  29591. /**
  29592. * Get the underlying lower level texture from Babylon.
  29593. * @returns the insternal texture
  29594. */
  29595. getInternalTexture(): Nullable<InternalTexture>;
  29596. /**
  29597. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29598. * @returns true if ready or not blocking
  29599. */
  29600. isReadyOrNotBlocking(): boolean;
  29601. /**
  29602. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29603. * @returns true if fully ready
  29604. */
  29605. isReady(): boolean;
  29606. private _cachedSize;
  29607. /**
  29608. * Get the size of the texture.
  29609. * @returns the texture size.
  29610. */
  29611. getSize(): ISize;
  29612. /**
  29613. * Get the base size of the texture.
  29614. * It can be different from the size if the texture has been resized for POT for instance
  29615. * @returns the base size
  29616. */
  29617. getBaseSize(): ISize;
  29618. /**
  29619. * Update the sampling mode of the texture.
  29620. * Default is Trilinear mode.
  29621. *
  29622. * | Value | Type | Description |
  29623. * | ----- | ------------------ | ----------- |
  29624. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29625. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29626. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29627. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29628. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29629. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29630. * | 7 | NEAREST_LINEAR | |
  29631. * | 8 | NEAREST_NEAREST | |
  29632. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29633. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29634. * | 11 | LINEAR_LINEAR | |
  29635. * | 12 | LINEAR_NEAREST | |
  29636. *
  29637. * > _mag_: magnification filter (close to the viewer)
  29638. * > _min_: minification filter (far from the viewer)
  29639. * > _mip_: filter used between mip map levels
  29640. *@param samplingMode Define the new sampling mode of the texture
  29641. */
  29642. updateSamplingMode(samplingMode: number): void;
  29643. /**
  29644. * Scales the texture if is `canRescale()`
  29645. * @param ratio the resize factor we want to use to rescale
  29646. */
  29647. scale(ratio: number): void;
  29648. /**
  29649. * Get if the texture can rescale.
  29650. */
  29651. get canRescale(): boolean;
  29652. /** @hidden */
  29653. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29654. /** @hidden */
  29655. _rebuild(): void;
  29656. /**
  29657. * Triggers the load sequence in delayed load mode.
  29658. */
  29659. delayLoad(): void;
  29660. /**
  29661. * Clones the texture.
  29662. * @returns the cloned texture
  29663. */
  29664. clone(): Nullable<BaseTexture>;
  29665. /**
  29666. * Get the texture underlying type (INT, FLOAT...)
  29667. */
  29668. get textureType(): number;
  29669. /**
  29670. * Get the texture underlying format (RGB, RGBA...)
  29671. */
  29672. get textureFormat(): number;
  29673. /**
  29674. * Indicates that textures need to be re-calculated for all materials
  29675. */
  29676. protected _markAllSubMeshesAsTexturesDirty(): void;
  29677. /**
  29678. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29679. * This will returns an RGBA array buffer containing either in values (0-255) or
  29680. * float values (0-1) depending of the underlying buffer type.
  29681. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29682. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29683. * @param buffer defines a user defined buffer to fill with data (can be null)
  29684. * @returns The Array buffer containing the pixels data.
  29685. */
  29686. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29687. /**
  29688. * Release and destroy the underlying lower level texture aka internalTexture.
  29689. */
  29690. releaseInternalTexture(): void;
  29691. /** @hidden */
  29692. get _lodTextureHigh(): Nullable<BaseTexture>;
  29693. /** @hidden */
  29694. get _lodTextureMid(): Nullable<BaseTexture>;
  29695. /** @hidden */
  29696. get _lodTextureLow(): Nullable<BaseTexture>;
  29697. /**
  29698. * Dispose the texture and release its associated resources.
  29699. */
  29700. dispose(): void;
  29701. /**
  29702. * Serialize the texture into a JSON representation that can be parsed later on.
  29703. * @returns the JSON representation of the texture
  29704. */
  29705. serialize(): any;
  29706. /**
  29707. * Helper function to be called back once a list of texture contains only ready textures.
  29708. * @param textures Define the list of textures to wait for
  29709. * @param callback Define the callback triggered once the entire list will be ready
  29710. */
  29711. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29712. }
  29713. }
  29714. declare module BABYLON {
  29715. /**
  29716. * Options to be used when creating an effect.
  29717. */
  29718. export interface IEffectCreationOptions {
  29719. /**
  29720. * Atrributes that will be used in the shader.
  29721. */
  29722. attributes: string[];
  29723. /**
  29724. * Uniform varible names that will be set in the shader.
  29725. */
  29726. uniformsNames: string[];
  29727. /**
  29728. * Uniform buffer variable names that will be set in the shader.
  29729. */
  29730. uniformBuffersNames: string[];
  29731. /**
  29732. * Sampler texture variable names that will be set in the shader.
  29733. */
  29734. samplers: string[];
  29735. /**
  29736. * Define statements that will be set in the shader.
  29737. */
  29738. defines: any;
  29739. /**
  29740. * Possible fallbacks for this effect to improve performance when needed.
  29741. */
  29742. fallbacks: Nullable<IEffectFallbacks>;
  29743. /**
  29744. * Callback that will be called when the shader is compiled.
  29745. */
  29746. onCompiled: Nullable<(effect: Effect) => void>;
  29747. /**
  29748. * Callback that will be called if an error occurs during shader compilation.
  29749. */
  29750. onError: Nullable<(effect: Effect, errors: string) => void>;
  29751. /**
  29752. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29753. */
  29754. indexParameters?: any;
  29755. /**
  29756. * Max number of lights that can be used in the shader.
  29757. */
  29758. maxSimultaneousLights?: number;
  29759. /**
  29760. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29761. */
  29762. transformFeedbackVaryings?: Nullable<string[]>;
  29763. }
  29764. /**
  29765. * Effect containing vertex and fragment shader that can be executed on an object.
  29766. */
  29767. export class Effect implements IDisposable {
  29768. /**
  29769. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29770. */
  29771. static ShadersRepository: string;
  29772. /**
  29773. * Name of the effect.
  29774. */
  29775. name: any;
  29776. /**
  29777. * String container all the define statements that should be set on the shader.
  29778. */
  29779. defines: string;
  29780. /**
  29781. * Callback that will be called when the shader is compiled.
  29782. */
  29783. onCompiled: Nullable<(effect: Effect) => void>;
  29784. /**
  29785. * Callback that will be called if an error occurs during shader compilation.
  29786. */
  29787. onError: Nullable<(effect: Effect, errors: string) => void>;
  29788. /**
  29789. * Callback that will be called when effect is bound.
  29790. */
  29791. onBind: Nullable<(effect: Effect) => void>;
  29792. /**
  29793. * Unique ID of the effect.
  29794. */
  29795. uniqueId: number;
  29796. /**
  29797. * Observable that will be called when the shader is compiled.
  29798. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29799. */
  29800. onCompileObservable: Observable<Effect>;
  29801. /**
  29802. * Observable that will be called if an error occurs during shader compilation.
  29803. */
  29804. onErrorObservable: Observable<Effect>;
  29805. /** @hidden */
  29806. _onBindObservable: Nullable<Observable<Effect>>;
  29807. /**
  29808. * @hidden
  29809. * Specifies if the effect was previously ready
  29810. */
  29811. _wasPreviouslyReady: boolean;
  29812. /**
  29813. * Observable that will be called when effect is bound.
  29814. */
  29815. get onBindObservable(): Observable<Effect>;
  29816. /** @hidden */
  29817. _bonesComputationForcedToCPU: boolean;
  29818. private static _uniqueIdSeed;
  29819. private _engine;
  29820. private _uniformBuffersNames;
  29821. private _uniformsNames;
  29822. private _samplerList;
  29823. private _samplers;
  29824. private _isReady;
  29825. private _compilationError;
  29826. private _allFallbacksProcessed;
  29827. private _attributesNames;
  29828. private _attributes;
  29829. private _attributeLocationByName;
  29830. private _uniforms;
  29831. /**
  29832. * Key for the effect.
  29833. * @hidden
  29834. */
  29835. _key: string;
  29836. private _indexParameters;
  29837. private _fallbacks;
  29838. private _vertexSourceCode;
  29839. private _fragmentSourceCode;
  29840. private _vertexSourceCodeOverride;
  29841. private _fragmentSourceCodeOverride;
  29842. private _transformFeedbackVaryings;
  29843. /**
  29844. * Compiled shader to webGL program.
  29845. * @hidden
  29846. */
  29847. _pipelineContext: Nullable<IPipelineContext>;
  29848. private _valueCache;
  29849. private static _baseCache;
  29850. /**
  29851. * Instantiates an effect.
  29852. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29853. * @param baseName Name of the effect.
  29854. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29855. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29856. * @param samplers List of sampler variables that will be passed to the shader.
  29857. * @param engine Engine to be used to render the effect
  29858. * @param defines Define statements to be added to the shader.
  29859. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29860. * @param onCompiled Callback that will be called when the shader is compiled.
  29861. * @param onError Callback that will be called if an error occurs during shader compilation.
  29862. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29863. */
  29864. 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);
  29865. private _useFinalCode;
  29866. /**
  29867. * Unique key for this effect
  29868. */
  29869. get key(): string;
  29870. /**
  29871. * If the effect has been compiled and prepared.
  29872. * @returns if the effect is compiled and prepared.
  29873. */
  29874. isReady(): boolean;
  29875. private _isReadyInternal;
  29876. /**
  29877. * The engine the effect was initialized with.
  29878. * @returns the engine.
  29879. */
  29880. getEngine(): Engine;
  29881. /**
  29882. * The pipeline context for this effect
  29883. * @returns the associated pipeline context
  29884. */
  29885. getPipelineContext(): Nullable<IPipelineContext>;
  29886. /**
  29887. * The set of names of attribute variables for the shader.
  29888. * @returns An array of attribute names.
  29889. */
  29890. getAttributesNames(): string[];
  29891. /**
  29892. * Returns the attribute at the given index.
  29893. * @param index The index of the attribute.
  29894. * @returns The location of the attribute.
  29895. */
  29896. getAttributeLocation(index: number): number;
  29897. /**
  29898. * Returns the attribute based on the name of the variable.
  29899. * @param name of the attribute to look up.
  29900. * @returns the attribute location.
  29901. */
  29902. getAttributeLocationByName(name: string): number;
  29903. /**
  29904. * The number of attributes.
  29905. * @returns the numnber of attributes.
  29906. */
  29907. getAttributesCount(): number;
  29908. /**
  29909. * Gets the index of a uniform variable.
  29910. * @param uniformName of the uniform to look up.
  29911. * @returns the index.
  29912. */
  29913. getUniformIndex(uniformName: string): number;
  29914. /**
  29915. * Returns the attribute based on the name of the variable.
  29916. * @param uniformName of the uniform to look up.
  29917. * @returns the location of the uniform.
  29918. */
  29919. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29920. /**
  29921. * Returns an array of sampler variable names
  29922. * @returns The array of sampler variable neames.
  29923. */
  29924. getSamplers(): string[];
  29925. /**
  29926. * The error from the last compilation.
  29927. * @returns the error string.
  29928. */
  29929. getCompilationError(): string;
  29930. /**
  29931. * Gets a boolean indicating that all fallbacks were used during compilation
  29932. * @returns true if all fallbacks were used
  29933. */
  29934. allFallbacksProcessed(): boolean;
  29935. /**
  29936. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29937. * @param func The callback to be used.
  29938. */
  29939. executeWhenCompiled(func: (effect: Effect) => void): void;
  29940. private _checkIsReady;
  29941. private _loadShader;
  29942. /**
  29943. * Recompiles the webGL program
  29944. * @param vertexSourceCode The source code for the vertex shader.
  29945. * @param fragmentSourceCode The source code for the fragment shader.
  29946. * @param onCompiled Callback called when completed.
  29947. * @param onError Callback called on error.
  29948. * @hidden
  29949. */
  29950. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29951. /**
  29952. * Prepares the effect
  29953. * @hidden
  29954. */
  29955. _prepareEffect(): void;
  29956. private _processCompilationErrors;
  29957. /**
  29958. * Checks if the effect is supported. (Must be called after compilation)
  29959. */
  29960. get isSupported(): boolean;
  29961. /**
  29962. * Binds a texture to the engine to be used as output of the shader.
  29963. * @param channel Name of the output variable.
  29964. * @param texture Texture to bind.
  29965. * @hidden
  29966. */
  29967. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29968. /**
  29969. * Sets a texture on the engine to be used in the shader.
  29970. * @param channel Name of the sampler variable.
  29971. * @param texture Texture to set.
  29972. */
  29973. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29974. /**
  29975. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29976. * @param channel Name of the sampler variable.
  29977. * @param texture Texture to set.
  29978. */
  29979. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29980. /**
  29981. * Sets an array of textures on the engine to be used in the shader.
  29982. * @param channel Name of the variable.
  29983. * @param textures Textures to set.
  29984. */
  29985. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29986. /**
  29987. * 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)
  29988. * @param channel Name of the sampler variable.
  29989. * @param postProcess Post process to get the input texture from.
  29990. */
  29991. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29992. /**
  29993. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29994. * 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)
  29995. * @param channel Name of the sampler variable.
  29996. * @param postProcess Post process to get the output texture from.
  29997. */
  29998. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29999. /** @hidden */
  30000. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30001. /** @hidden */
  30002. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30003. /** @hidden */
  30004. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30005. /** @hidden */
  30006. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30007. /**
  30008. * Binds a buffer to a uniform.
  30009. * @param buffer Buffer to bind.
  30010. * @param name Name of the uniform variable to bind to.
  30011. */
  30012. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30013. /**
  30014. * Binds block to a uniform.
  30015. * @param blockName Name of the block to bind.
  30016. * @param index Index to bind.
  30017. */
  30018. bindUniformBlock(blockName: string, index: number): void;
  30019. /**
  30020. * Sets an interger value on a uniform variable.
  30021. * @param uniformName Name of the variable.
  30022. * @param value Value to be set.
  30023. * @returns this effect.
  30024. */
  30025. setInt(uniformName: string, value: number): Effect;
  30026. /**
  30027. * Sets an int array on a uniform variable.
  30028. * @param uniformName Name of the variable.
  30029. * @param array array to be set.
  30030. * @returns this effect.
  30031. */
  30032. setIntArray(uniformName: string, array: Int32Array): Effect;
  30033. /**
  30034. * 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)
  30035. * @param uniformName Name of the variable.
  30036. * @param array array to be set.
  30037. * @returns this effect.
  30038. */
  30039. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30040. /**
  30041. * 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)
  30042. * @param uniformName Name of the variable.
  30043. * @param array array to be set.
  30044. * @returns this effect.
  30045. */
  30046. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30047. /**
  30048. * 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)
  30049. * @param uniformName Name of the variable.
  30050. * @param array array to be set.
  30051. * @returns this effect.
  30052. */
  30053. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30054. /**
  30055. * Sets an float array on a uniform variable.
  30056. * @param uniformName Name of the variable.
  30057. * @param array array to be set.
  30058. * @returns this effect.
  30059. */
  30060. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30061. /**
  30062. * 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)
  30063. * @param uniformName Name of the variable.
  30064. * @param array array to be set.
  30065. * @returns this effect.
  30066. */
  30067. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30068. /**
  30069. * 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)
  30070. * @param uniformName Name of the variable.
  30071. * @param array array to be set.
  30072. * @returns this effect.
  30073. */
  30074. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30075. /**
  30076. * 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)
  30077. * @param uniformName Name of the variable.
  30078. * @param array array to be set.
  30079. * @returns this effect.
  30080. */
  30081. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30082. /**
  30083. * Sets an array on a uniform variable.
  30084. * @param uniformName Name of the variable.
  30085. * @param array array to be set.
  30086. * @returns this effect.
  30087. */
  30088. setArray(uniformName: string, array: number[]): Effect;
  30089. /**
  30090. * 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)
  30091. * @param uniformName Name of the variable.
  30092. * @param array array to be set.
  30093. * @returns this effect.
  30094. */
  30095. setArray2(uniformName: string, array: number[]): Effect;
  30096. /**
  30097. * 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)
  30098. * @param uniformName Name of the variable.
  30099. * @param array array to be set.
  30100. * @returns this effect.
  30101. */
  30102. setArray3(uniformName: string, array: number[]): Effect;
  30103. /**
  30104. * 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)
  30105. * @param uniformName Name of the variable.
  30106. * @param array array to be set.
  30107. * @returns this effect.
  30108. */
  30109. setArray4(uniformName: string, array: number[]): Effect;
  30110. /**
  30111. * Sets matrices on a uniform variable.
  30112. * @param uniformName Name of the variable.
  30113. * @param matrices matrices to be set.
  30114. * @returns this effect.
  30115. */
  30116. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30117. /**
  30118. * Sets matrix on a uniform variable.
  30119. * @param uniformName Name of the variable.
  30120. * @param matrix matrix to be set.
  30121. * @returns this effect.
  30122. */
  30123. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30124. /**
  30125. * 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)
  30126. * @param uniformName Name of the variable.
  30127. * @param matrix matrix to be set.
  30128. * @returns this effect.
  30129. */
  30130. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30131. /**
  30132. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30133. * @param uniformName Name of the variable.
  30134. * @param matrix matrix to be set.
  30135. * @returns this effect.
  30136. */
  30137. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30138. /**
  30139. * Sets a float on a uniform variable.
  30140. * @param uniformName Name of the variable.
  30141. * @param value value to be set.
  30142. * @returns this effect.
  30143. */
  30144. setFloat(uniformName: string, value: number): Effect;
  30145. /**
  30146. * Sets a boolean on a uniform variable.
  30147. * @param uniformName Name of the variable.
  30148. * @param bool value to be set.
  30149. * @returns this effect.
  30150. */
  30151. setBool(uniformName: string, bool: boolean): Effect;
  30152. /**
  30153. * Sets a Vector2 on a uniform variable.
  30154. * @param uniformName Name of the variable.
  30155. * @param vector2 vector2 to be set.
  30156. * @returns this effect.
  30157. */
  30158. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30159. /**
  30160. * Sets a float2 on a uniform variable.
  30161. * @param uniformName Name of the variable.
  30162. * @param x First float in float2.
  30163. * @param y Second float in float2.
  30164. * @returns this effect.
  30165. */
  30166. setFloat2(uniformName: string, x: number, y: number): Effect;
  30167. /**
  30168. * Sets a Vector3 on a uniform variable.
  30169. * @param uniformName Name of the variable.
  30170. * @param vector3 Value to be set.
  30171. * @returns this effect.
  30172. */
  30173. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30174. /**
  30175. * Sets a float3 on a uniform variable.
  30176. * @param uniformName Name of the variable.
  30177. * @param x First float in float3.
  30178. * @param y Second float in float3.
  30179. * @param z Third float in float3.
  30180. * @returns this effect.
  30181. */
  30182. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30183. /**
  30184. * Sets a Vector4 on a uniform variable.
  30185. * @param uniformName Name of the variable.
  30186. * @param vector4 Value to be set.
  30187. * @returns this effect.
  30188. */
  30189. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30190. /**
  30191. * Sets a float4 on a uniform variable.
  30192. * @param uniformName Name of the variable.
  30193. * @param x First float in float4.
  30194. * @param y Second float in float4.
  30195. * @param z Third float in float4.
  30196. * @param w Fourth float in float4.
  30197. * @returns this effect.
  30198. */
  30199. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30200. /**
  30201. * Sets a Color3 on a uniform variable.
  30202. * @param uniformName Name of the variable.
  30203. * @param color3 Value to be set.
  30204. * @returns this effect.
  30205. */
  30206. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30207. /**
  30208. * Sets a Color4 on a uniform variable.
  30209. * @param uniformName Name of the variable.
  30210. * @param color3 Value to be set.
  30211. * @param alpha Alpha value to be set.
  30212. * @returns this effect.
  30213. */
  30214. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30215. /**
  30216. * Sets a Color4 on a uniform variable
  30217. * @param uniformName defines the name of the variable
  30218. * @param color4 defines the value to be set
  30219. * @returns this effect.
  30220. */
  30221. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30222. /** Release all associated resources */
  30223. dispose(): void;
  30224. /**
  30225. * This function will add a new shader to the shader store
  30226. * @param name the name of the shader
  30227. * @param pixelShader optional pixel shader content
  30228. * @param vertexShader optional vertex shader content
  30229. */
  30230. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30231. /**
  30232. * Store of each shader (The can be looked up using effect.key)
  30233. */
  30234. static ShadersStore: {
  30235. [key: string]: string;
  30236. };
  30237. /**
  30238. * Store of each included file for a shader (The can be looked up using effect.key)
  30239. */
  30240. static IncludesShadersStore: {
  30241. [key: string]: string;
  30242. };
  30243. /**
  30244. * Resets the cache of effects.
  30245. */
  30246. static ResetCache(): void;
  30247. }
  30248. }
  30249. declare module BABYLON {
  30250. /**
  30251. * Interface used to describe the capabilities of the engine relatively to the current browser
  30252. */
  30253. export interface EngineCapabilities {
  30254. /** Maximum textures units per fragment shader */
  30255. maxTexturesImageUnits: number;
  30256. /** Maximum texture units per vertex shader */
  30257. maxVertexTextureImageUnits: number;
  30258. /** Maximum textures units in the entire pipeline */
  30259. maxCombinedTexturesImageUnits: number;
  30260. /** Maximum texture size */
  30261. maxTextureSize: number;
  30262. /** Maximum texture samples */
  30263. maxSamples?: number;
  30264. /** Maximum cube texture size */
  30265. maxCubemapTextureSize: number;
  30266. /** Maximum render texture size */
  30267. maxRenderTextureSize: number;
  30268. /** Maximum number of vertex attributes */
  30269. maxVertexAttribs: number;
  30270. /** Maximum number of varyings */
  30271. maxVaryingVectors: number;
  30272. /** Maximum number of uniforms per vertex shader */
  30273. maxVertexUniformVectors: number;
  30274. /** Maximum number of uniforms per fragment shader */
  30275. maxFragmentUniformVectors: number;
  30276. /** Defines if standard derivates (dx/dy) are supported */
  30277. standardDerivatives: boolean;
  30278. /** Defines if s3tc texture compression is supported */
  30279. s3tc?: WEBGL_compressed_texture_s3tc;
  30280. /** Defines if pvrtc texture compression is supported */
  30281. pvrtc: any;
  30282. /** Defines if etc1 texture compression is supported */
  30283. etc1: any;
  30284. /** Defines if etc2 texture compression is supported */
  30285. etc2: any;
  30286. /** Defines if astc texture compression is supported */
  30287. astc: any;
  30288. /** Defines if float textures are supported */
  30289. textureFloat: boolean;
  30290. /** Defines if vertex array objects are supported */
  30291. vertexArrayObject: boolean;
  30292. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30293. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30294. /** Gets the maximum level of anisotropy supported */
  30295. maxAnisotropy: number;
  30296. /** Defines if instancing is supported */
  30297. instancedArrays: boolean;
  30298. /** Defines if 32 bits indices are supported */
  30299. uintIndices: boolean;
  30300. /** Defines if high precision shaders are supported */
  30301. highPrecisionShaderSupported: boolean;
  30302. /** Defines if depth reading in the fragment shader is supported */
  30303. fragmentDepthSupported: boolean;
  30304. /** Defines if float texture linear filtering is supported*/
  30305. textureFloatLinearFiltering: boolean;
  30306. /** Defines if rendering to float textures is supported */
  30307. textureFloatRender: boolean;
  30308. /** Defines if half float textures are supported*/
  30309. textureHalfFloat: boolean;
  30310. /** Defines if half float texture linear filtering is supported*/
  30311. textureHalfFloatLinearFiltering: boolean;
  30312. /** Defines if rendering to half float textures is supported */
  30313. textureHalfFloatRender: boolean;
  30314. /** Defines if textureLOD shader command is supported */
  30315. textureLOD: boolean;
  30316. /** Defines if draw buffers extension is supported */
  30317. drawBuffersExtension: boolean;
  30318. /** Defines if depth textures are supported */
  30319. depthTextureExtension: boolean;
  30320. /** Defines if float color buffer are supported */
  30321. colorBufferFloat: boolean;
  30322. /** Gets disjoint timer query extension (null if not supported) */
  30323. timerQuery?: EXT_disjoint_timer_query;
  30324. /** Defines if timestamp can be used with timer query */
  30325. canUseTimestampForTimerQuery: boolean;
  30326. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30327. multiview?: any;
  30328. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30329. oculusMultiview?: any;
  30330. /** Function used to let the system compiles shaders in background */
  30331. parallelShaderCompile?: {
  30332. COMPLETION_STATUS_KHR: number;
  30333. };
  30334. /** Max number of texture samples for MSAA */
  30335. maxMSAASamples: number;
  30336. /** Defines if the blend min max extension is supported */
  30337. blendMinMax: boolean;
  30338. }
  30339. }
  30340. declare module BABYLON {
  30341. /**
  30342. * @hidden
  30343. **/
  30344. export class DepthCullingState {
  30345. private _isDepthTestDirty;
  30346. private _isDepthMaskDirty;
  30347. private _isDepthFuncDirty;
  30348. private _isCullFaceDirty;
  30349. private _isCullDirty;
  30350. private _isZOffsetDirty;
  30351. private _isFrontFaceDirty;
  30352. private _depthTest;
  30353. private _depthMask;
  30354. private _depthFunc;
  30355. private _cull;
  30356. private _cullFace;
  30357. private _zOffset;
  30358. private _frontFace;
  30359. /**
  30360. * Initializes the state.
  30361. */
  30362. constructor();
  30363. get isDirty(): boolean;
  30364. get zOffset(): number;
  30365. set zOffset(value: number);
  30366. get cullFace(): Nullable<number>;
  30367. set cullFace(value: Nullable<number>);
  30368. get cull(): Nullable<boolean>;
  30369. set cull(value: Nullable<boolean>);
  30370. get depthFunc(): Nullable<number>;
  30371. set depthFunc(value: Nullable<number>);
  30372. get depthMask(): boolean;
  30373. set depthMask(value: boolean);
  30374. get depthTest(): boolean;
  30375. set depthTest(value: boolean);
  30376. get frontFace(): Nullable<number>;
  30377. set frontFace(value: Nullable<number>);
  30378. reset(): void;
  30379. apply(gl: WebGLRenderingContext): void;
  30380. }
  30381. }
  30382. declare module BABYLON {
  30383. /**
  30384. * @hidden
  30385. **/
  30386. export class StencilState {
  30387. /** 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 */
  30388. static readonly ALWAYS: number;
  30389. /** Passed to stencilOperation to specify that stencil value must be kept */
  30390. static readonly KEEP: number;
  30391. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30392. static readonly REPLACE: number;
  30393. private _isStencilTestDirty;
  30394. private _isStencilMaskDirty;
  30395. private _isStencilFuncDirty;
  30396. private _isStencilOpDirty;
  30397. private _stencilTest;
  30398. private _stencilMask;
  30399. private _stencilFunc;
  30400. private _stencilFuncRef;
  30401. private _stencilFuncMask;
  30402. private _stencilOpStencilFail;
  30403. private _stencilOpDepthFail;
  30404. private _stencilOpStencilDepthPass;
  30405. get isDirty(): boolean;
  30406. get stencilFunc(): number;
  30407. set stencilFunc(value: number);
  30408. get stencilFuncRef(): number;
  30409. set stencilFuncRef(value: number);
  30410. get stencilFuncMask(): number;
  30411. set stencilFuncMask(value: number);
  30412. get stencilOpStencilFail(): number;
  30413. set stencilOpStencilFail(value: number);
  30414. get stencilOpDepthFail(): number;
  30415. set stencilOpDepthFail(value: number);
  30416. get stencilOpStencilDepthPass(): number;
  30417. set stencilOpStencilDepthPass(value: number);
  30418. get stencilMask(): number;
  30419. set stencilMask(value: number);
  30420. get stencilTest(): boolean;
  30421. set stencilTest(value: boolean);
  30422. constructor();
  30423. reset(): void;
  30424. apply(gl: WebGLRenderingContext): void;
  30425. }
  30426. }
  30427. declare module BABYLON {
  30428. /**
  30429. * @hidden
  30430. **/
  30431. export class AlphaState {
  30432. private _isAlphaBlendDirty;
  30433. private _isBlendFunctionParametersDirty;
  30434. private _isBlendEquationParametersDirty;
  30435. private _isBlendConstantsDirty;
  30436. private _alphaBlend;
  30437. private _blendFunctionParameters;
  30438. private _blendEquationParameters;
  30439. private _blendConstants;
  30440. /**
  30441. * Initializes the state.
  30442. */
  30443. constructor();
  30444. get isDirty(): boolean;
  30445. get alphaBlend(): boolean;
  30446. set alphaBlend(value: boolean);
  30447. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30448. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30449. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30450. reset(): void;
  30451. apply(gl: WebGLRenderingContext): void;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /** @hidden */
  30456. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30457. attributeProcessor(attribute: string): string;
  30458. varyingProcessor(varying: string, isFragment: boolean): string;
  30459. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30460. }
  30461. }
  30462. declare module BABYLON {
  30463. /**
  30464. * Interface for attribute information associated with buffer instanciation
  30465. */
  30466. export interface InstancingAttributeInfo {
  30467. /**
  30468. * Name of the GLSL attribute
  30469. * if attribute index is not specified, this is used to retrieve the index from the effect
  30470. */
  30471. attributeName: string;
  30472. /**
  30473. * Index/offset of the attribute in the vertex shader
  30474. * if not specified, this will be computes from the name.
  30475. */
  30476. index?: number;
  30477. /**
  30478. * size of the attribute, 1, 2, 3 or 4
  30479. */
  30480. attributeSize: number;
  30481. /**
  30482. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30483. */
  30484. offset: number;
  30485. /**
  30486. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30487. * default to 1
  30488. */
  30489. divisor?: number;
  30490. /**
  30491. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30492. * default is FLOAT
  30493. */
  30494. attributeType?: number;
  30495. /**
  30496. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30497. */
  30498. normalized?: boolean;
  30499. }
  30500. }
  30501. declare module BABYLON {
  30502. interface ThinEngine {
  30503. /**
  30504. * Update a video texture
  30505. * @param texture defines the texture to update
  30506. * @param video defines the video element to use
  30507. * @param invertY defines if data must be stored with Y axis inverted
  30508. */
  30509. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30510. }
  30511. }
  30512. declare module BABYLON {
  30513. /**
  30514. * Settings for finer control over video usage
  30515. */
  30516. export interface VideoTextureSettings {
  30517. /**
  30518. * Applies `autoplay` to video, if specified
  30519. */
  30520. autoPlay?: boolean;
  30521. /**
  30522. * Applies `loop` to video, if specified
  30523. */
  30524. loop?: boolean;
  30525. /**
  30526. * Automatically updates internal texture from video at every frame in the render loop
  30527. */
  30528. autoUpdateTexture: boolean;
  30529. /**
  30530. * Image src displayed during the video loading or until the user interacts with the video.
  30531. */
  30532. poster?: string;
  30533. }
  30534. /**
  30535. * If you want to display a video in your scene, this is the special texture for that.
  30536. * This special texture works similar to other textures, with the exception of a few parameters.
  30537. * @see https://doc.babylonjs.com/how_to/video_texture
  30538. */
  30539. export class VideoTexture extends Texture {
  30540. /**
  30541. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30542. */
  30543. readonly autoUpdateTexture: boolean;
  30544. /**
  30545. * The video instance used by the texture internally
  30546. */
  30547. readonly video: HTMLVideoElement;
  30548. private _onUserActionRequestedObservable;
  30549. /**
  30550. * Event triggerd when a dom action is required by the user to play the video.
  30551. * This happens due to recent changes in browser policies preventing video to auto start.
  30552. */
  30553. get onUserActionRequestedObservable(): Observable<Texture>;
  30554. private _generateMipMaps;
  30555. private _engine;
  30556. private _stillImageCaptured;
  30557. private _displayingPosterTexture;
  30558. private _settings;
  30559. private _createInternalTextureOnEvent;
  30560. private _frameId;
  30561. /**
  30562. * Creates a video texture.
  30563. * If you want to display a video in your scene, this is the special texture for that.
  30564. * This special texture works similar to other textures, with the exception of a few parameters.
  30565. * @see https://doc.babylonjs.com/how_to/video_texture
  30566. * @param name optional name, will detect from video source, if not defined
  30567. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30568. * @param scene is obviously the current scene.
  30569. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30570. * @param invertY is false by default but can be used to invert video on Y axis
  30571. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30572. * @param settings allows finer control over video usage
  30573. */
  30574. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30575. private _getName;
  30576. private _getVideo;
  30577. private _createInternalTexture;
  30578. private reset;
  30579. /**
  30580. * @hidden Internal method to initiate `update`.
  30581. */
  30582. _rebuild(): void;
  30583. /**
  30584. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30585. */
  30586. update(): void;
  30587. /**
  30588. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30589. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30590. */
  30591. updateTexture(isVisible: boolean): void;
  30592. protected _updateInternalTexture: () => void;
  30593. /**
  30594. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30595. * @param url New url.
  30596. */
  30597. updateURL(url: string): void;
  30598. /**
  30599. * Dispose the texture and release its associated resources.
  30600. */
  30601. dispose(): void;
  30602. /**
  30603. * Creates a video texture straight from a stream.
  30604. * @param scene Define the scene the texture should be created in
  30605. * @param stream Define the stream the texture should be created from
  30606. * @returns The created video texture as a promise
  30607. */
  30608. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30609. /**
  30610. * Creates a video texture straight from your WebCam video feed.
  30611. * @param scene Define the scene the texture should be created in
  30612. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30613. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30614. * @returns The created video texture as a promise
  30615. */
  30616. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30617. minWidth: number;
  30618. maxWidth: number;
  30619. minHeight: number;
  30620. maxHeight: number;
  30621. deviceId: string;
  30622. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30623. /**
  30624. * Creates a video texture straight from your WebCam video feed.
  30625. * @param scene Define the scene the texture should be created in
  30626. * @param onReady Define a callback to triggered once the texture will be ready
  30627. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30628. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30629. */
  30630. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30631. minWidth: number;
  30632. maxWidth: number;
  30633. minHeight: number;
  30634. maxHeight: number;
  30635. deviceId: string;
  30636. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30637. }
  30638. }
  30639. declare module BABYLON {
  30640. /**
  30641. * Defines the interface used by objects working like Scene
  30642. * @hidden
  30643. */
  30644. interface ISceneLike {
  30645. _addPendingData(data: any): void;
  30646. _removePendingData(data: any): void;
  30647. offlineProvider: IOfflineProvider;
  30648. }
  30649. /** Interface defining initialization parameters for Engine class */
  30650. export interface EngineOptions extends WebGLContextAttributes {
  30651. /**
  30652. * Defines if the engine should no exceed a specified device ratio
  30653. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30654. */
  30655. limitDeviceRatio?: number;
  30656. /**
  30657. * Defines if webvr should be enabled automatically
  30658. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30659. */
  30660. autoEnableWebVR?: boolean;
  30661. /**
  30662. * Defines if webgl2 should be turned off even if supported
  30663. * @see http://doc.babylonjs.com/features/webgl2
  30664. */
  30665. disableWebGL2Support?: boolean;
  30666. /**
  30667. * Defines if webaudio should be initialized as well
  30668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30669. */
  30670. audioEngine?: boolean;
  30671. /**
  30672. * Defines if animations should run using a deterministic lock step
  30673. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30674. */
  30675. deterministicLockstep?: boolean;
  30676. /** Defines the maximum steps to use with deterministic lock step mode */
  30677. lockstepMaxSteps?: number;
  30678. /** Defines the seconds between each deterministic lock step */
  30679. timeStep?: number;
  30680. /**
  30681. * Defines that engine should ignore context lost events
  30682. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30683. */
  30684. doNotHandleContextLost?: boolean;
  30685. /**
  30686. * Defines that engine should ignore modifying touch action attribute and style
  30687. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30688. */
  30689. doNotHandleTouchAction?: boolean;
  30690. /**
  30691. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30692. */
  30693. useHighPrecisionFloats?: boolean;
  30694. }
  30695. /**
  30696. * The base engine class (root of all engines)
  30697. */
  30698. export class ThinEngine {
  30699. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30700. static ExceptionList: ({
  30701. key: string;
  30702. capture: string;
  30703. captureConstraint: number;
  30704. targets: string[];
  30705. } | {
  30706. key: string;
  30707. capture: null;
  30708. captureConstraint: null;
  30709. targets: string[];
  30710. })[];
  30711. /** @hidden */
  30712. static _TextureLoaders: IInternalTextureLoader[];
  30713. /**
  30714. * Returns the current npm package of the sdk
  30715. */
  30716. static get NpmPackage(): string;
  30717. /**
  30718. * Returns the current version of the framework
  30719. */
  30720. static get Version(): string;
  30721. /**
  30722. * Returns a string describing the current engine
  30723. */
  30724. get description(): string;
  30725. /**
  30726. * Gets or sets the epsilon value used by collision engine
  30727. */
  30728. static CollisionsEpsilon: number;
  30729. /**
  30730. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30731. */
  30732. static get ShadersRepository(): string;
  30733. static set ShadersRepository(value: string);
  30734. /**
  30735. * Gets or sets the textures that the engine should not attempt to load as compressed
  30736. */
  30737. protected _excludedCompressedTextures: string[];
  30738. /**
  30739. * Filters the compressed texture formats to only include
  30740. * files that are not included in the skippable list
  30741. *
  30742. * @param url the current extension
  30743. * @param textureFormatInUse the current compressed texture format
  30744. * @returns "format" string
  30745. */
  30746. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30747. /** @hidden */
  30748. _shaderProcessor: IShaderProcessor;
  30749. /**
  30750. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30751. */
  30752. forcePOTTextures: boolean;
  30753. /**
  30754. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30755. */
  30756. isFullscreen: boolean;
  30757. /**
  30758. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30759. */
  30760. cullBackFaces: boolean;
  30761. /**
  30762. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30763. */
  30764. renderEvenInBackground: boolean;
  30765. /**
  30766. * Gets or sets a boolean indicating that cache can be kept between frames
  30767. */
  30768. preventCacheWipeBetweenFrames: boolean;
  30769. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30770. validateShaderPrograms: boolean;
  30771. /**
  30772. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30773. * This can provide greater z depth for distant objects.
  30774. */
  30775. useReverseDepthBuffer: boolean;
  30776. /**
  30777. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30778. */
  30779. disableUniformBuffers: boolean;
  30780. /** @hidden */
  30781. _uniformBuffers: UniformBuffer[];
  30782. /**
  30783. * Gets a boolean indicating that the engine supports uniform buffers
  30784. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30785. */
  30786. get supportsUniformBuffers(): boolean;
  30787. /** @hidden */
  30788. _gl: WebGLRenderingContext;
  30789. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30790. protected _windowIsBackground: boolean;
  30791. protected _webGLVersion: number;
  30792. protected _creationOptions: EngineOptions;
  30793. protected _highPrecisionShadersAllowed: boolean;
  30794. /** @hidden */
  30795. get _shouldUseHighPrecisionShader(): boolean;
  30796. /**
  30797. * Gets a boolean indicating that only power of 2 textures are supported
  30798. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30799. */
  30800. get needPOTTextures(): boolean;
  30801. /** @hidden */
  30802. _badOS: boolean;
  30803. /** @hidden */
  30804. _badDesktopOS: boolean;
  30805. private _hardwareScalingLevel;
  30806. /** @hidden */
  30807. _caps: EngineCapabilities;
  30808. private _isStencilEnable;
  30809. private _glVersion;
  30810. private _glRenderer;
  30811. private _glVendor;
  30812. /** @hidden */
  30813. _videoTextureSupported: boolean;
  30814. protected _renderingQueueLaunched: boolean;
  30815. protected _activeRenderLoops: (() => void)[];
  30816. /**
  30817. * Observable signaled when a context lost event is raised
  30818. */
  30819. onContextLostObservable: Observable<ThinEngine>;
  30820. /**
  30821. * Observable signaled when a context restored event is raised
  30822. */
  30823. onContextRestoredObservable: Observable<ThinEngine>;
  30824. private _onContextLost;
  30825. private _onContextRestored;
  30826. protected _contextWasLost: boolean;
  30827. /** @hidden */
  30828. _doNotHandleContextLost: boolean;
  30829. /**
  30830. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30832. */
  30833. get doNotHandleContextLost(): boolean;
  30834. set doNotHandleContextLost(value: boolean);
  30835. /**
  30836. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30837. */
  30838. disableVertexArrayObjects: boolean;
  30839. /** @hidden */
  30840. protected _colorWrite: boolean;
  30841. /** @hidden */
  30842. protected _colorWriteChanged: boolean;
  30843. /** @hidden */
  30844. protected _depthCullingState: DepthCullingState;
  30845. /** @hidden */
  30846. protected _stencilState: StencilState;
  30847. /** @hidden */
  30848. _alphaState: AlphaState;
  30849. /** @hidden */
  30850. _alphaMode: number;
  30851. /** @hidden */
  30852. _alphaEquation: number;
  30853. /** @hidden */
  30854. _internalTexturesCache: InternalTexture[];
  30855. /** @hidden */
  30856. protected _activeChannel: number;
  30857. private _currentTextureChannel;
  30858. /** @hidden */
  30859. protected _boundTexturesCache: {
  30860. [key: string]: Nullable<InternalTexture>;
  30861. };
  30862. /** @hidden */
  30863. protected _currentEffect: Nullable<Effect>;
  30864. /** @hidden */
  30865. protected _currentProgram: Nullable<WebGLProgram>;
  30866. private _compiledEffects;
  30867. private _vertexAttribArraysEnabled;
  30868. /** @hidden */
  30869. protected _cachedViewport: Nullable<IViewportLike>;
  30870. private _cachedVertexArrayObject;
  30871. /** @hidden */
  30872. protected _cachedVertexBuffers: any;
  30873. /** @hidden */
  30874. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30875. /** @hidden */
  30876. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30877. /** @hidden */
  30878. _currentRenderTarget: Nullable<InternalTexture>;
  30879. private _uintIndicesCurrentlySet;
  30880. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30881. /** @hidden */
  30882. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30883. private _currentBufferPointers;
  30884. private _currentInstanceLocations;
  30885. private _currentInstanceBuffers;
  30886. private _textureUnits;
  30887. /** @hidden */
  30888. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30889. /** @hidden */
  30890. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30891. /** @hidden */
  30892. _boundRenderFunction: any;
  30893. private _vaoRecordInProgress;
  30894. private _mustWipeVertexAttributes;
  30895. private _emptyTexture;
  30896. private _emptyCubeTexture;
  30897. private _emptyTexture3D;
  30898. private _emptyTexture2DArray;
  30899. /** @hidden */
  30900. _frameHandler: number;
  30901. private _nextFreeTextureSlots;
  30902. private _maxSimultaneousTextures;
  30903. private _activeRequests;
  30904. protected _texturesSupported: string[];
  30905. /** @hidden */
  30906. _textureFormatInUse: Nullable<string>;
  30907. protected get _supportsHardwareTextureRescaling(): boolean;
  30908. /**
  30909. * Gets the list of texture formats supported
  30910. */
  30911. get texturesSupported(): Array<string>;
  30912. /**
  30913. * Gets the list of texture formats in use
  30914. */
  30915. get textureFormatInUse(): Nullable<string>;
  30916. /**
  30917. * Gets the current viewport
  30918. */
  30919. get currentViewport(): Nullable<IViewportLike>;
  30920. /**
  30921. * Gets the default empty texture
  30922. */
  30923. get emptyTexture(): InternalTexture;
  30924. /**
  30925. * Gets the default empty 3D texture
  30926. */
  30927. get emptyTexture3D(): InternalTexture;
  30928. /**
  30929. * Gets the default empty 2D array texture
  30930. */
  30931. get emptyTexture2DArray(): InternalTexture;
  30932. /**
  30933. * Gets the default empty cube texture
  30934. */
  30935. get emptyCubeTexture(): InternalTexture;
  30936. /**
  30937. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30938. */
  30939. readonly premultipliedAlpha: boolean;
  30940. /**
  30941. * Observable event triggered before each texture is initialized
  30942. */
  30943. onBeforeTextureInitObservable: Observable<Texture>;
  30944. /**
  30945. * Creates a new engine
  30946. * @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
  30947. * @param antialias defines enable antialiasing (default: false)
  30948. * @param options defines further options to be sent to the getContext() function
  30949. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30950. */
  30951. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30952. private _rebuildInternalTextures;
  30953. private _rebuildEffects;
  30954. /**
  30955. * Gets a boolean indicating if all created effects are ready
  30956. * @returns true if all effects are ready
  30957. */
  30958. areAllEffectsReady(): boolean;
  30959. protected _rebuildBuffers(): void;
  30960. private _initGLContext;
  30961. /**
  30962. * Gets version of the current webGL context
  30963. */
  30964. get webGLVersion(): number;
  30965. /**
  30966. * Gets a string idenfifying the name of the class
  30967. * @returns "Engine" string
  30968. */
  30969. getClassName(): string;
  30970. /**
  30971. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30972. */
  30973. get isStencilEnable(): boolean;
  30974. /** @hidden */
  30975. _prepareWorkingCanvas(): void;
  30976. /**
  30977. * Reset the texture cache to empty state
  30978. */
  30979. resetTextureCache(): void;
  30980. /**
  30981. * Gets an object containing information about the current webGL context
  30982. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30983. */
  30984. getGlInfo(): {
  30985. vendor: string;
  30986. renderer: string;
  30987. version: string;
  30988. };
  30989. /**
  30990. * Defines the hardware scaling level.
  30991. * By default the hardware scaling level is computed from the window device ratio.
  30992. * 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.
  30993. * @param level defines the level to use
  30994. */
  30995. setHardwareScalingLevel(level: number): void;
  30996. /**
  30997. * Gets the current hardware scaling level.
  30998. * By default the hardware scaling level is computed from the window device ratio.
  30999. * 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.
  31000. * @returns a number indicating the current hardware scaling level
  31001. */
  31002. getHardwareScalingLevel(): number;
  31003. /**
  31004. * Gets the list of loaded textures
  31005. * @returns an array containing all loaded textures
  31006. */
  31007. getLoadedTexturesCache(): InternalTexture[];
  31008. /**
  31009. * Gets the object containing all engine capabilities
  31010. * @returns the EngineCapabilities object
  31011. */
  31012. getCaps(): EngineCapabilities;
  31013. /**
  31014. * stop executing a render loop function and remove it from the execution array
  31015. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31016. */
  31017. stopRenderLoop(renderFunction?: () => void): void;
  31018. /** @hidden */
  31019. _renderLoop(): void;
  31020. /**
  31021. * Gets the HTML canvas attached with the current webGL context
  31022. * @returns a HTML canvas
  31023. */
  31024. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31025. /**
  31026. * Gets host window
  31027. * @returns the host window object
  31028. */
  31029. getHostWindow(): Nullable<Window>;
  31030. /**
  31031. * Gets the current render width
  31032. * @param useScreen defines if screen size must be used (or the current render target if any)
  31033. * @returns a number defining the current render width
  31034. */
  31035. getRenderWidth(useScreen?: boolean): number;
  31036. /**
  31037. * Gets the current render height
  31038. * @param useScreen defines if screen size must be used (or the current render target if any)
  31039. * @returns a number defining the current render height
  31040. */
  31041. getRenderHeight(useScreen?: boolean): number;
  31042. /**
  31043. * Can be used to override the current requestAnimationFrame requester.
  31044. * @hidden
  31045. */
  31046. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31047. /**
  31048. * Register and execute a render loop. The engine can have more than one render function
  31049. * @param renderFunction defines the function to continuously execute
  31050. */
  31051. runRenderLoop(renderFunction: () => void): void;
  31052. /**
  31053. * Clear the current render buffer or the current render target (if any is set up)
  31054. * @param color defines the color to use
  31055. * @param backBuffer defines if the back buffer must be cleared
  31056. * @param depth defines if the depth buffer must be cleared
  31057. * @param stencil defines if the stencil buffer must be cleared
  31058. */
  31059. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31060. private _viewportCached;
  31061. /** @hidden */
  31062. _viewport(x: number, y: number, width: number, height: number): void;
  31063. /**
  31064. * Set the WebGL's viewport
  31065. * @param viewport defines the viewport element to be used
  31066. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31067. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31068. */
  31069. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31070. /**
  31071. * Begin a new frame
  31072. */
  31073. beginFrame(): void;
  31074. /**
  31075. * Enf the current frame
  31076. */
  31077. endFrame(): void;
  31078. /**
  31079. * Resize the view according to the canvas' size
  31080. */
  31081. resize(): void;
  31082. /**
  31083. * Force a specific size of the canvas
  31084. * @param width defines the new canvas' width
  31085. * @param height defines the new canvas' height
  31086. */
  31087. setSize(width: number, height: number): void;
  31088. /**
  31089. * Binds the frame buffer to the specified texture.
  31090. * @param texture The texture to render to or null for the default canvas
  31091. * @param faceIndex The face of the texture to render to in case of cube texture
  31092. * @param requiredWidth The width of the target to render to
  31093. * @param requiredHeight The height of the target to render to
  31094. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31095. * @param depthStencilTexture The depth stencil texture to use to render
  31096. * @param lodLevel defines le lod level to bind to the frame buffer
  31097. */
  31098. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31099. /** @hidden */
  31100. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31101. /**
  31102. * Unbind the current render target texture from the webGL context
  31103. * @param texture defines the render target texture to unbind
  31104. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31105. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31106. */
  31107. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31108. /**
  31109. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31110. */
  31111. flushFramebuffer(): void;
  31112. /**
  31113. * Unbind the current render target and bind the default framebuffer
  31114. */
  31115. restoreDefaultFramebuffer(): void;
  31116. /** @hidden */
  31117. protected _resetVertexBufferBinding(): void;
  31118. /**
  31119. * Creates a vertex buffer
  31120. * @param data the data for the vertex buffer
  31121. * @returns the new WebGL static buffer
  31122. */
  31123. createVertexBuffer(data: DataArray): DataBuffer;
  31124. private _createVertexBuffer;
  31125. /**
  31126. * Creates a dynamic vertex buffer
  31127. * @param data the data for the dynamic vertex buffer
  31128. * @returns the new WebGL dynamic buffer
  31129. */
  31130. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31131. protected _resetIndexBufferBinding(): void;
  31132. /**
  31133. * Creates a new index buffer
  31134. * @param indices defines the content of the index buffer
  31135. * @param updatable defines if the index buffer must be updatable
  31136. * @returns a new webGL buffer
  31137. */
  31138. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31139. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31140. /**
  31141. * Bind a webGL buffer to the webGL context
  31142. * @param buffer defines the buffer to bind
  31143. */
  31144. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31145. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31146. private bindBuffer;
  31147. /**
  31148. * update the bound buffer with the given data
  31149. * @param data defines the data to update
  31150. */
  31151. updateArrayBuffer(data: Float32Array): void;
  31152. private _vertexAttribPointer;
  31153. private _bindIndexBufferWithCache;
  31154. private _bindVertexBuffersAttributes;
  31155. /**
  31156. * Records a vertex array object
  31157. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31158. * @param vertexBuffers defines the list of vertex buffers to store
  31159. * @param indexBuffer defines the index buffer to store
  31160. * @param effect defines the effect to store
  31161. * @returns the new vertex array object
  31162. */
  31163. recordVertexArrayObject(vertexBuffers: {
  31164. [key: string]: VertexBuffer;
  31165. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31166. /**
  31167. * Bind a specific vertex array object
  31168. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31169. * @param vertexArrayObject defines the vertex array object to bind
  31170. * @param indexBuffer defines the index buffer to bind
  31171. */
  31172. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31173. /**
  31174. * Bind webGl buffers directly to the webGL context
  31175. * @param vertexBuffer defines the vertex buffer to bind
  31176. * @param indexBuffer defines the index buffer to bind
  31177. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31178. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31179. * @param effect defines the effect associated with the vertex buffer
  31180. */
  31181. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31182. private _unbindVertexArrayObject;
  31183. /**
  31184. * Bind a list of vertex buffers to the webGL context
  31185. * @param vertexBuffers defines the list of vertex buffers to bind
  31186. * @param indexBuffer defines the index buffer to bind
  31187. * @param effect defines the effect associated with the vertex buffers
  31188. */
  31189. bindBuffers(vertexBuffers: {
  31190. [key: string]: Nullable<VertexBuffer>;
  31191. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31192. /**
  31193. * Unbind all instance attributes
  31194. */
  31195. unbindInstanceAttributes(): void;
  31196. /**
  31197. * Release and free the memory of a vertex array object
  31198. * @param vao defines the vertex array object to delete
  31199. */
  31200. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31201. /** @hidden */
  31202. _releaseBuffer(buffer: DataBuffer): boolean;
  31203. protected _deleteBuffer(buffer: DataBuffer): void;
  31204. /**
  31205. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31206. * @param instancesBuffer defines the webGL buffer to update and bind
  31207. * @param data defines the data to store in the buffer
  31208. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31209. */
  31210. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31211. /**
  31212. * Bind the content of a webGL buffer used with instanciation
  31213. * @param instancesBuffer defines the webGL buffer to bind
  31214. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31215. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31216. */
  31217. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31218. /**
  31219. * Disable the instance attribute corresponding to the name in parameter
  31220. * @param name defines the name of the attribute to disable
  31221. */
  31222. disableInstanceAttributeByName(name: string): void;
  31223. /**
  31224. * Disable the instance attribute corresponding to the location in parameter
  31225. * @param attributeLocation defines the attribute location of the attribute to disable
  31226. */
  31227. disableInstanceAttribute(attributeLocation: number): void;
  31228. /**
  31229. * Disable the attribute corresponding to the location in parameter
  31230. * @param attributeLocation defines the attribute location of the attribute to disable
  31231. */
  31232. disableAttributeByIndex(attributeLocation: number): void;
  31233. /**
  31234. * Send a draw order
  31235. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31236. * @param indexStart defines the starting index
  31237. * @param indexCount defines the number of index to draw
  31238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31239. */
  31240. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31241. /**
  31242. * Draw a list of points
  31243. * @param verticesStart defines the index of first vertex to draw
  31244. * @param verticesCount defines the count of vertices to draw
  31245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31246. */
  31247. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31248. /**
  31249. * Draw a list of unindexed primitives
  31250. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31251. * @param verticesStart defines the index of first vertex to draw
  31252. * @param verticesCount defines the count of vertices to draw
  31253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31254. */
  31255. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31256. /**
  31257. * Draw a list of indexed primitives
  31258. * @param fillMode defines the primitive to use
  31259. * @param indexStart defines the starting index
  31260. * @param indexCount defines the number of index to draw
  31261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31262. */
  31263. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31264. /**
  31265. * Draw a list of unindexed primitives
  31266. * @param fillMode defines the primitive to use
  31267. * @param verticesStart defines the index of first vertex to draw
  31268. * @param verticesCount defines the count of vertices to draw
  31269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31270. */
  31271. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31272. private _drawMode;
  31273. /** @hidden */
  31274. protected _reportDrawCall(): void;
  31275. /** @hidden */
  31276. _releaseEffect(effect: Effect): void;
  31277. /** @hidden */
  31278. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31279. /**
  31280. * Create a new effect (used to store vertex/fragment shaders)
  31281. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31282. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31283. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31284. * @param samplers defines an array of string used to represent textures
  31285. * @param defines defines the string containing the defines to use to compile the shaders
  31286. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31287. * @param onCompiled defines a function to call when the effect creation is successful
  31288. * @param onError defines a function to call when the effect creation has failed
  31289. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31290. * @returns the new Effect
  31291. */
  31292. 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;
  31293. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31294. private _compileShader;
  31295. private _compileRawShader;
  31296. /**
  31297. * Directly creates a webGL program
  31298. * @param pipelineContext defines the pipeline context to attach to
  31299. * @param vertexCode defines the vertex shader code to use
  31300. * @param fragmentCode defines the fragment shader code to use
  31301. * @param context defines the webGL context to use (if not set, the current one will be used)
  31302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31303. * @returns the new webGL program
  31304. */
  31305. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31306. /**
  31307. * Creates a webGL program
  31308. * @param pipelineContext defines the pipeline context to attach to
  31309. * @param vertexCode defines the vertex shader code to use
  31310. * @param fragmentCode defines the fragment shader code to use
  31311. * @param defines defines the string containing the defines to use to compile the shaders
  31312. * @param context defines the webGL context to use (if not set, the current one will be used)
  31313. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31314. * @returns the new webGL program
  31315. */
  31316. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31317. /**
  31318. * Creates a new pipeline context
  31319. * @returns the new pipeline
  31320. */
  31321. createPipelineContext(): IPipelineContext;
  31322. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31323. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31324. /** @hidden */
  31325. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31326. /** @hidden */
  31327. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31328. /** @hidden */
  31329. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31330. /**
  31331. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31332. * @param pipelineContext defines the pipeline context to use
  31333. * @param uniformsNames defines the list of uniform names
  31334. * @returns an array of webGL uniform locations
  31335. */
  31336. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31337. /**
  31338. * Gets the lsit of active attributes for a given webGL program
  31339. * @param pipelineContext defines the pipeline context to use
  31340. * @param attributesNames defines the list of attribute names to get
  31341. * @returns an array of indices indicating the offset of each attribute
  31342. */
  31343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31344. /**
  31345. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31346. * @param effect defines the effect to activate
  31347. */
  31348. enableEffect(effect: Nullable<Effect>): void;
  31349. /**
  31350. * Set the value of an uniform to a number (int)
  31351. * @param uniform defines the webGL uniform location where to store the value
  31352. * @param value defines the int number to store
  31353. */
  31354. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31355. /**
  31356. * Set the value of an uniform to an array of int32
  31357. * @param uniform defines the webGL uniform location where to store the value
  31358. * @param array defines the array of int32 to store
  31359. */
  31360. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31361. /**
  31362. * Set the value of an uniform to an array of int32 (stored as vec2)
  31363. * @param uniform defines the webGL uniform location where to store the value
  31364. * @param array defines the array of int32 to store
  31365. */
  31366. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31367. /**
  31368. * Set the value of an uniform to an array of int32 (stored as vec3)
  31369. * @param uniform defines the webGL uniform location where to store the value
  31370. * @param array defines the array of int32 to store
  31371. */
  31372. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31373. /**
  31374. * Set the value of an uniform to an array of int32 (stored as vec4)
  31375. * @param uniform defines the webGL uniform location where to store the value
  31376. * @param array defines the array of int32 to store
  31377. */
  31378. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31379. /**
  31380. * Set the value of an uniform to an array of number
  31381. * @param uniform defines the webGL uniform location where to store the value
  31382. * @param array defines the array of number to store
  31383. */
  31384. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31385. /**
  31386. * Set the value of an uniform to an array of number (stored as vec2)
  31387. * @param uniform defines the webGL uniform location where to store the value
  31388. * @param array defines the array of number to store
  31389. */
  31390. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31391. /**
  31392. * Set the value of an uniform to an array of number (stored as vec3)
  31393. * @param uniform defines the webGL uniform location where to store the value
  31394. * @param array defines the array of number to store
  31395. */
  31396. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31397. /**
  31398. * Set the value of an uniform to an array of number (stored as vec4)
  31399. * @param uniform defines the webGL uniform location where to store the value
  31400. * @param array defines the array of number to store
  31401. */
  31402. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31403. /**
  31404. * Set the value of an uniform to an array of float32 (stored as matrices)
  31405. * @param uniform defines the webGL uniform location where to store the value
  31406. * @param matrices defines the array of float32 to store
  31407. */
  31408. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31409. /**
  31410. * Set the value of an uniform to a matrix (3x3)
  31411. * @param uniform defines the webGL uniform location where to store the value
  31412. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31413. */
  31414. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31415. /**
  31416. * Set the value of an uniform to a matrix (2x2)
  31417. * @param uniform defines the webGL uniform location where to store the value
  31418. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31419. */
  31420. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31421. /**
  31422. * Set the value of an uniform to a number (float)
  31423. * @param uniform defines the webGL uniform location where to store the value
  31424. * @param value defines the float number to store
  31425. */
  31426. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31427. /**
  31428. * Set the value of an uniform to a vec2
  31429. * @param uniform defines the webGL uniform location where to store the value
  31430. * @param x defines the 1st component of the value
  31431. * @param y defines the 2nd component of the value
  31432. */
  31433. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31434. /**
  31435. * Set the value of an uniform to a vec3
  31436. * @param uniform defines the webGL uniform location where to store the value
  31437. * @param x defines the 1st component of the value
  31438. * @param y defines the 2nd component of the value
  31439. * @param z defines the 3rd component of the value
  31440. */
  31441. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31442. /**
  31443. * Set the value of an uniform to a vec4
  31444. * @param uniform defines the webGL uniform location where to store the value
  31445. * @param x defines the 1st component of the value
  31446. * @param y defines the 2nd component of the value
  31447. * @param z defines the 3rd component of the value
  31448. * @param w defines the 4th component of the value
  31449. */
  31450. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31451. /**
  31452. * Apply all cached states (depth, culling, stencil and alpha)
  31453. */
  31454. applyStates(): void;
  31455. /**
  31456. * Enable or disable color writing
  31457. * @param enable defines the state to set
  31458. */
  31459. setColorWrite(enable: boolean): void;
  31460. /**
  31461. * Gets a boolean indicating if color writing is enabled
  31462. * @returns the current color writing state
  31463. */
  31464. getColorWrite(): boolean;
  31465. /**
  31466. * Gets the depth culling state manager
  31467. */
  31468. get depthCullingState(): DepthCullingState;
  31469. /**
  31470. * Gets the alpha state manager
  31471. */
  31472. get alphaState(): AlphaState;
  31473. /**
  31474. * Gets the stencil state manager
  31475. */
  31476. get stencilState(): StencilState;
  31477. /**
  31478. * Clears the list of texture accessible through engine.
  31479. * This can help preventing texture load conflict due to name collision.
  31480. */
  31481. clearInternalTexturesCache(): void;
  31482. /**
  31483. * Force the entire cache to be cleared
  31484. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31485. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31486. */
  31487. wipeCaches(bruteForce?: boolean): void;
  31488. /** @hidden */
  31489. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31490. min: number;
  31491. mag: number;
  31492. };
  31493. /** @hidden */
  31494. _createTexture(): WebGLTexture;
  31495. /**
  31496. * Usually called from Texture.ts.
  31497. * Passed information to create a WebGLTexture
  31498. * @param urlArg defines a value which contains one of the following:
  31499. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31500. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31501. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31503. * @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)
  31504. * @param scene needed for loading to the correct scene
  31505. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31506. * @param onLoad optional callback to be called upon successful completion
  31507. * @param onError optional callback to be called upon failure
  31508. * @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
  31509. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31510. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31511. * @param forcedExtension defines the extension to use to pick the right loader
  31512. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31513. * @param mimeType defines an optional mime type
  31514. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31515. */
  31516. 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;
  31517. /**
  31518. * Loads an image as an HTMLImageElement.
  31519. * @param input url string, ArrayBuffer, or Blob to load
  31520. * @param onLoad callback called when the image successfully loads
  31521. * @param onError callback called when the image fails to load
  31522. * @param offlineProvider offline provider for caching
  31523. * @param mimeType optional mime type
  31524. * @returns the HTMLImageElement of the loaded image
  31525. * @hidden
  31526. */
  31527. 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>;
  31528. /**
  31529. * @hidden
  31530. */
  31531. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31532. /**
  31533. * Creates a raw texture
  31534. * @param data defines the data to store in the texture
  31535. * @param width defines the width of the texture
  31536. * @param height defines the height of the texture
  31537. * @param format defines the format of the data
  31538. * @param generateMipMaps defines if the engine should generate the mip levels
  31539. * @param invertY defines if data must be stored with Y axis inverted
  31540. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31541. * @param compression defines the compression used (null by default)
  31542. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31543. * @returns the raw texture inside an InternalTexture
  31544. */
  31545. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31546. /**
  31547. * Creates a new raw cube texture
  31548. * @param data defines the array of data to use to create each face
  31549. * @param size defines the size of the textures
  31550. * @param format defines the format of the data
  31551. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31552. * @param generateMipMaps defines if the engine should generate the mip levels
  31553. * @param invertY defines if data must be stored with Y axis inverted
  31554. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31555. * @param compression defines the compression used (null by default)
  31556. * @returns the cube texture as an InternalTexture
  31557. */
  31558. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31559. /**
  31560. * Creates a new raw 3D texture
  31561. * @param data defines the data used to create the texture
  31562. * @param width defines the width of the texture
  31563. * @param height defines the height of the texture
  31564. * @param depth defines the depth of the texture
  31565. * @param format defines the format of the texture
  31566. * @param generateMipMaps defines if the engine must generate mip levels
  31567. * @param invertY defines if data must be stored with Y axis inverted
  31568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31569. * @param compression defines the compressed used (can be null)
  31570. * @param textureType defines the compressed used (can be null)
  31571. * @returns a new raw 3D texture (stored in an InternalTexture)
  31572. */
  31573. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31574. /**
  31575. * Creates a new raw 2D array texture
  31576. * @param data defines the data used to create the texture
  31577. * @param width defines the width of the texture
  31578. * @param height defines the height of the texture
  31579. * @param depth defines the number of layers of the texture
  31580. * @param format defines the format of the texture
  31581. * @param generateMipMaps defines if the engine must generate mip levels
  31582. * @param invertY defines if data must be stored with Y axis inverted
  31583. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31584. * @param compression defines the compressed used (can be null)
  31585. * @param textureType defines the compressed used (can be null)
  31586. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31587. */
  31588. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31589. private _unpackFlipYCached;
  31590. /**
  31591. * In case you are sharing the context with other applications, it might
  31592. * be interested to not cache the unpack flip y state to ensure a consistent
  31593. * value would be set.
  31594. */
  31595. enableUnpackFlipYCached: boolean;
  31596. /** @hidden */
  31597. _unpackFlipY(value: boolean): void;
  31598. /** @hidden */
  31599. _getUnpackAlignement(): number;
  31600. private _getTextureTarget;
  31601. /**
  31602. * Update the sampling mode of a given texture
  31603. * @param samplingMode defines the required sampling mode
  31604. * @param texture defines the texture to update
  31605. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31606. */
  31607. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31608. /**
  31609. * Update the sampling mode of a given texture
  31610. * @param texture defines the texture to update
  31611. * @param wrapU defines the texture wrap mode of the u coordinates
  31612. * @param wrapV defines the texture wrap mode of the v coordinates
  31613. * @param wrapR defines the texture wrap mode of the r coordinates
  31614. */
  31615. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31616. /** @hidden */
  31617. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31618. width: number;
  31619. height: number;
  31620. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31621. /** @hidden */
  31622. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31623. /** @hidden */
  31624. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31625. /** @hidden */
  31626. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31627. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31628. private _prepareWebGLTexture;
  31629. /** @hidden */
  31630. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31631. private _getDepthStencilBuffer;
  31632. /** @hidden */
  31633. _releaseFramebufferObjects(texture: InternalTexture): void;
  31634. /** @hidden */
  31635. _releaseTexture(texture: InternalTexture): void;
  31636. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31637. protected _setProgram(program: WebGLProgram): void;
  31638. protected _boundUniforms: {
  31639. [key: number]: WebGLUniformLocation;
  31640. };
  31641. /**
  31642. * Binds an effect to the webGL context
  31643. * @param effect defines the effect to bind
  31644. */
  31645. bindSamplers(effect: Effect): void;
  31646. private _activateCurrentTexture;
  31647. /** @hidden */
  31648. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31649. /** @hidden */
  31650. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31651. /**
  31652. * Unbind all textures from the webGL context
  31653. */
  31654. unbindAllTextures(): void;
  31655. /**
  31656. * Sets a texture to the according uniform.
  31657. * @param channel The texture channel
  31658. * @param uniform The uniform to set
  31659. * @param texture The texture to apply
  31660. */
  31661. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31662. private _bindSamplerUniformToChannel;
  31663. private _getTextureWrapMode;
  31664. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31665. /**
  31666. * Sets an array of texture to the webGL context
  31667. * @param channel defines the channel where the texture array must be set
  31668. * @param uniform defines the associated uniform location
  31669. * @param textures defines the array of textures to bind
  31670. */
  31671. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31672. /** @hidden */
  31673. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31674. private _setTextureParameterFloat;
  31675. private _setTextureParameterInteger;
  31676. /**
  31677. * Unbind all vertex attributes from the webGL context
  31678. */
  31679. unbindAllAttributes(): void;
  31680. /**
  31681. * 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
  31682. */
  31683. releaseEffects(): void;
  31684. /**
  31685. * Dispose and release all associated resources
  31686. */
  31687. dispose(): void;
  31688. /**
  31689. * Attach a new callback raised when context lost event is fired
  31690. * @param callback defines the callback to call
  31691. */
  31692. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31693. /**
  31694. * Attach a new callback raised when context restored event is fired
  31695. * @param callback defines the callback to call
  31696. */
  31697. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31698. /**
  31699. * Get the current error code of the webGL context
  31700. * @returns the error code
  31701. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31702. */
  31703. getError(): number;
  31704. private _canRenderToFloatFramebuffer;
  31705. private _canRenderToHalfFloatFramebuffer;
  31706. private _canRenderToFramebuffer;
  31707. /** @hidden */
  31708. _getWebGLTextureType(type: number): number;
  31709. /** @hidden */
  31710. _getInternalFormat(format: number): number;
  31711. /** @hidden */
  31712. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31713. /** @hidden */
  31714. _getRGBAMultiSampleBufferFormat(type: number): number;
  31715. /** @hidden */
  31716. _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;
  31717. /**
  31718. * Loads a file from a url
  31719. * @param url url to load
  31720. * @param onSuccess callback called when the file successfully loads
  31721. * @param onProgress callback called while file is loading (if the server supports this mode)
  31722. * @param offlineProvider defines the offline provider for caching
  31723. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31724. * @param onError callback called when the file fails to load
  31725. * @returns a file request object
  31726. * @hidden
  31727. */
  31728. 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;
  31729. /**
  31730. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31731. * @param x defines the x coordinate of the rectangle where pixels must be read
  31732. * @param y defines the y coordinate of the rectangle where pixels must be read
  31733. * @param width defines the width of the rectangle where pixels must be read
  31734. * @param height defines the height of the rectangle where pixels must be read
  31735. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31736. * @returns a Uint8Array containing RGBA colors
  31737. */
  31738. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31739. private static _isSupported;
  31740. /**
  31741. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31742. * @returns true if the engine can be created
  31743. * @ignorenaming
  31744. */
  31745. static isSupported(): boolean;
  31746. /**
  31747. * Find the next highest power of two.
  31748. * @param x Number to start search from.
  31749. * @return Next highest power of two.
  31750. */
  31751. static CeilingPOT(x: number): number;
  31752. /**
  31753. * Find the next lowest power of two.
  31754. * @param x Number to start search from.
  31755. * @return Next lowest power of two.
  31756. */
  31757. static FloorPOT(x: number): number;
  31758. /**
  31759. * Find the nearest power of two.
  31760. * @param x Number to start search from.
  31761. * @return Next nearest power of two.
  31762. */
  31763. static NearestPOT(x: number): number;
  31764. /**
  31765. * Get the closest exponent of two
  31766. * @param value defines the value to approximate
  31767. * @param max defines the maximum value to return
  31768. * @param mode defines how to define the closest value
  31769. * @returns closest exponent of two of the given value
  31770. */
  31771. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31772. /**
  31773. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31774. * @param func - the function to be called
  31775. * @param requester - the object that will request the next frame. Falls back to window.
  31776. * @returns frame number
  31777. */
  31778. static QueueNewFrame(func: () => void, requester?: any): number;
  31779. /**
  31780. * Gets host document
  31781. * @returns the host document object
  31782. */
  31783. getHostDocument(): Nullable<Document>;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. /**
  31788. * Class representing spherical harmonics coefficients to the 3rd degree
  31789. */
  31790. export class SphericalHarmonics {
  31791. /**
  31792. * Defines whether or not the harmonics have been prescaled for rendering.
  31793. */
  31794. preScaled: boolean;
  31795. /**
  31796. * The l0,0 coefficients of the spherical harmonics
  31797. */
  31798. l00: Vector3;
  31799. /**
  31800. * The l1,-1 coefficients of the spherical harmonics
  31801. */
  31802. l1_1: Vector3;
  31803. /**
  31804. * The l1,0 coefficients of the spherical harmonics
  31805. */
  31806. l10: Vector3;
  31807. /**
  31808. * The l1,1 coefficients of the spherical harmonics
  31809. */
  31810. l11: Vector3;
  31811. /**
  31812. * The l2,-2 coefficients of the spherical harmonics
  31813. */
  31814. l2_2: Vector3;
  31815. /**
  31816. * The l2,-1 coefficients of the spherical harmonics
  31817. */
  31818. l2_1: Vector3;
  31819. /**
  31820. * The l2,0 coefficients of the spherical harmonics
  31821. */
  31822. l20: Vector3;
  31823. /**
  31824. * The l2,1 coefficients of the spherical harmonics
  31825. */
  31826. l21: Vector3;
  31827. /**
  31828. * The l2,2 coefficients of the spherical harmonics
  31829. */
  31830. l22: Vector3;
  31831. /**
  31832. * Adds a light to the spherical harmonics
  31833. * @param direction the direction of the light
  31834. * @param color the color of the light
  31835. * @param deltaSolidAngle the delta solid angle of the light
  31836. */
  31837. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31838. /**
  31839. * Scales the spherical harmonics by the given amount
  31840. * @param scale the amount to scale
  31841. */
  31842. scaleInPlace(scale: number): void;
  31843. /**
  31844. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31845. *
  31846. * ```
  31847. * E_lm = A_l * L_lm
  31848. * ```
  31849. *
  31850. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31851. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31852. * the scaling factors are given in equation 9.
  31853. */
  31854. convertIncidentRadianceToIrradiance(): void;
  31855. /**
  31856. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31857. *
  31858. * ```
  31859. * L = (1/pi) * E * rho
  31860. * ```
  31861. *
  31862. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31863. */
  31864. convertIrradianceToLambertianRadiance(): void;
  31865. /**
  31866. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31867. * required operations at run time.
  31868. *
  31869. * This is simply done by scaling back the SH with Ylm constants parameter.
  31870. * The trigonometric part being applied by the shader at run time.
  31871. */
  31872. preScaleForRendering(): void;
  31873. /**
  31874. * Constructs a spherical harmonics from an array.
  31875. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31876. * @returns the spherical harmonics
  31877. */
  31878. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31879. /**
  31880. * Gets the spherical harmonics from polynomial
  31881. * @param polynomial the spherical polynomial
  31882. * @returns the spherical harmonics
  31883. */
  31884. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31885. }
  31886. /**
  31887. * Class representing spherical polynomial coefficients to the 3rd degree
  31888. */
  31889. export class SphericalPolynomial {
  31890. private _harmonics;
  31891. /**
  31892. * The spherical harmonics used to create the polynomials.
  31893. */
  31894. get preScaledHarmonics(): SphericalHarmonics;
  31895. /**
  31896. * The x coefficients of the spherical polynomial
  31897. */
  31898. x: Vector3;
  31899. /**
  31900. * The y coefficients of the spherical polynomial
  31901. */
  31902. y: Vector3;
  31903. /**
  31904. * The z coefficients of the spherical polynomial
  31905. */
  31906. z: Vector3;
  31907. /**
  31908. * The xx coefficients of the spherical polynomial
  31909. */
  31910. xx: Vector3;
  31911. /**
  31912. * The yy coefficients of the spherical polynomial
  31913. */
  31914. yy: Vector3;
  31915. /**
  31916. * The zz coefficients of the spherical polynomial
  31917. */
  31918. zz: Vector3;
  31919. /**
  31920. * The xy coefficients of the spherical polynomial
  31921. */
  31922. xy: Vector3;
  31923. /**
  31924. * The yz coefficients of the spherical polynomial
  31925. */
  31926. yz: Vector3;
  31927. /**
  31928. * The zx coefficients of the spherical polynomial
  31929. */
  31930. zx: Vector3;
  31931. /**
  31932. * Adds an ambient color to the spherical polynomial
  31933. * @param color the color to add
  31934. */
  31935. addAmbient(color: Color3): void;
  31936. /**
  31937. * Scales the spherical polynomial by the given amount
  31938. * @param scale the amount to scale
  31939. */
  31940. scaleInPlace(scale: number): void;
  31941. /**
  31942. * Gets the spherical polynomial from harmonics
  31943. * @param harmonics the spherical harmonics
  31944. * @returns the spherical polynomial
  31945. */
  31946. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31947. /**
  31948. * Constructs a spherical polynomial from an array.
  31949. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31950. * @returns the spherical polynomial
  31951. */
  31952. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31953. }
  31954. }
  31955. declare module BABYLON {
  31956. /**
  31957. * Defines the source of the internal texture
  31958. */
  31959. export enum InternalTextureSource {
  31960. /**
  31961. * The source of the texture data is unknown
  31962. */
  31963. Unknown = 0,
  31964. /**
  31965. * Texture data comes from an URL
  31966. */
  31967. Url = 1,
  31968. /**
  31969. * Texture data is only used for temporary storage
  31970. */
  31971. Temp = 2,
  31972. /**
  31973. * Texture data comes from raw data (ArrayBuffer)
  31974. */
  31975. Raw = 3,
  31976. /**
  31977. * Texture content is dynamic (video or dynamic texture)
  31978. */
  31979. Dynamic = 4,
  31980. /**
  31981. * Texture content is generated by rendering to it
  31982. */
  31983. RenderTarget = 5,
  31984. /**
  31985. * Texture content is part of a multi render target process
  31986. */
  31987. MultiRenderTarget = 6,
  31988. /**
  31989. * Texture data comes from a cube data file
  31990. */
  31991. Cube = 7,
  31992. /**
  31993. * Texture data comes from a raw cube data
  31994. */
  31995. CubeRaw = 8,
  31996. /**
  31997. * Texture data come from a prefiltered cube data file
  31998. */
  31999. CubePrefiltered = 9,
  32000. /**
  32001. * Texture content is raw 3D data
  32002. */
  32003. Raw3D = 10,
  32004. /**
  32005. * Texture content is raw 2D array data
  32006. */
  32007. Raw2DArray = 11,
  32008. /**
  32009. * Texture content is a depth texture
  32010. */
  32011. Depth = 12,
  32012. /**
  32013. * Texture data comes from a raw cube data encoded with RGBD
  32014. */
  32015. CubeRawRGBD = 13
  32016. }
  32017. /**
  32018. * Class used to store data associated with WebGL texture data for the engine
  32019. * This class should not be used directly
  32020. */
  32021. export class InternalTexture {
  32022. /** @hidden */
  32023. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32024. /**
  32025. * Defines if the texture is ready
  32026. */
  32027. isReady: boolean;
  32028. /**
  32029. * Defines if the texture is a cube texture
  32030. */
  32031. isCube: boolean;
  32032. /**
  32033. * Defines if the texture contains 3D data
  32034. */
  32035. is3D: boolean;
  32036. /**
  32037. * Defines if the texture contains 2D array data
  32038. */
  32039. is2DArray: boolean;
  32040. /**
  32041. * Defines if the texture contains multiview data
  32042. */
  32043. isMultiview: boolean;
  32044. /**
  32045. * Gets the URL used to load this texture
  32046. */
  32047. url: string;
  32048. /**
  32049. * Gets the sampling mode of the texture
  32050. */
  32051. samplingMode: number;
  32052. /**
  32053. * Gets a boolean indicating if the texture needs mipmaps generation
  32054. */
  32055. generateMipMaps: boolean;
  32056. /**
  32057. * Gets the number of samples used by the texture (WebGL2+ only)
  32058. */
  32059. samples: number;
  32060. /**
  32061. * Gets the type of the texture (int, float...)
  32062. */
  32063. type: number;
  32064. /**
  32065. * Gets the format of the texture (RGB, RGBA...)
  32066. */
  32067. format: number;
  32068. /**
  32069. * Observable called when the texture is loaded
  32070. */
  32071. onLoadedObservable: Observable<InternalTexture>;
  32072. /**
  32073. * Gets the width of the texture
  32074. */
  32075. width: number;
  32076. /**
  32077. * Gets the height of the texture
  32078. */
  32079. height: number;
  32080. /**
  32081. * Gets the depth of the texture
  32082. */
  32083. depth: number;
  32084. /**
  32085. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32086. */
  32087. baseWidth: number;
  32088. /**
  32089. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32090. */
  32091. baseHeight: number;
  32092. /**
  32093. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32094. */
  32095. baseDepth: number;
  32096. /**
  32097. * Gets a boolean indicating if the texture is inverted on Y axis
  32098. */
  32099. invertY: boolean;
  32100. /** @hidden */
  32101. _invertVScale: boolean;
  32102. /** @hidden */
  32103. _associatedChannel: number;
  32104. /** @hidden */
  32105. _source: InternalTextureSource;
  32106. /** @hidden */
  32107. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32108. /** @hidden */
  32109. _bufferView: Nullable<ArrayBufferView>;
  32110. /** @hidden */
  32111. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32112. /** @hidden */
  32113. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32114. /** @hidden */
  32115. _size: number;
  32116. /** @hidden */
  32117. _extension: string;
  32118. /** @hidden */
  32119. _files: Nullable<string[]>;
  32120. /** @hidden */
  32121. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32122. /** @hidden */
  32123. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32124. /** @hidden */
  32125. _framebuffer: Nullable<WebGLFramebuffer>;
  32126. /** @hidden */
  32127. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32128. /** @hidden */
  32129. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32130. /** @hidden */
  32131. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32132. /** @hidden */
  32133. _attachments: Nullable<number[]>;
  32134. /** @hidden */
  32135. _cachedCoordinatesMode: Nullable<number>;
  32136. /** @hidden */
  32137. _cachedWrapU: Nullable<number>;
  32138. /** @hidden */
  32139. _cachedWrapV: Nullable<number>;
  32140. /** @hidden */
  32141. _cachedWrapR: Nullable<number>;
  32142. /** @hidden */
  32143. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32144. /** @hidden */
  32145. _isDisabled: boolean;
  32146. /** @hidden */
  32147. _compression: Nullable<string>;
  32148. /** @hidden */
  32149. _generateStencilBuffer: boolean;
  32150. /** @hidden */
  32151. _generateDepthBuffer: boolean;
  32152. /** @hidden */
  32153. _comparisonFunction: number;
  32154. /** @hidden */
  32155. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32156. /** @hidden */
  32157. _lodGenerationScale: number;
  32158. /** @hidden */
  32159. _lodGenerationOffset: number;
  32160. /** @hidden */
  32161. _colorTextureArray: Nullable<WebGLTexture>;
  32162. /** @hidden */
  32163. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32164. /** @hidden */
  32165. _lodTextureHigh: Nullable<BaseTexture>;
  32166. /** @hidden */
  32167. _lodTextureMid: Nullable<BaseTexture>;
  32168. /** @hidden */
  32169. _lodTextureLow: Nullable<BaseTexture>;
  32170. /** @hidden */
  32171. _isRGBD: boolean;
  32172. /** @hidden */
  32173. _linearSpecularLOD: boolean;
  32174. /** @hidden */
  32175. _irradianceTexture: Nullable<BaseTexture>;
  32176. /** @hidden */
  32177. _webGLTexture: Nullable<WebGLTexture>;
  32178. /** @hidden */
  32179. _references: number;
  32180. private _engine;
  32181. /**
  32182. * Gets the Engine the texture belongs to.
  32183. * @returns The babylon engine
  32184. */
  32185. getEngine(): ThinEngine;
  32186. /**
  32187. * Gets the data source type of the texture
  32188. */
  32189. get source(): InternalTextureSource;
  32190. /**
  32191. * Creates a new InternalTexture
  32192. * @param engine defines the engine to use
  32193. * @param source defines the type of data that will be used
  32194. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32195. */
  32196. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32197. /**
  32198. * Increments the number of references (ie. the number of Texture that point to it)
  32199. */
  32200. incrementReferences(): void;
  32201. /**
  32202. * Change the size of the texture (not the size of the content)
  32203. * @param width defines the new width
  32204. * @param height defines the new height
  32205. * @param depth defines the new depth (1 by default)
  32206. */
  32207. updateSize(width: int, height: int, depth?: int): void;
  32208. /** @hidden */
  32209. _rebuild(): void;
  32210. /** @hidden */
  32211. _swapAndDie(target: InternalTexture): void;
  32212. /**
  32213. * Dispose the current allocated resources
  32214. */
  32215. dispose(): void;
  32216. }
  32217. }
  32218. declare module BABYLON {
  32219. /**
  32220. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32222. */
  32223. export class Analyser {
  32224. /**
  32225. * Gets or sets the smoothing
  32226. * @ignorenaming
  32227. */
  32228. SMOOTHING: number;
  32229. /**
  32230. * Gets or sets the FFT table size
  32231. * @ignorenaming
  32232. */
  32233. FFT_SIZE: number;
  32234. /**
  32235. * Gets or sets the bar graph amplitude
  32236. * @ignorenaming
  32237. */
  32238. BARGRAPHAMPLITUDE: number;
  32239. /**
  32240. * Gets or sets the position of the debug canvas
  32241. * @ignorenaming
  32242. */
  32243. DEBUGCANVASPOS: {
  32244. x: number;
  32245. y: number;
  32246. };
  32247. /**
  32248. * Gets or sets the debug canvas size
  32249. * @ignorenaming
  32250. */
  32251. DEBUGCANVASSIZE: {
  32252. width: number;
  32253. height: number;
  32254. };
  32255. private _byteFreqs;
  32256. private _byteTime;
  32257. private _floatFreqs;
  32258. private _webAudioAnalyser;
  32259. private _debugCanvas;
  32260. private _debugCanvasContext;
  32261. private _scene;
  32262. private _registerFunc;
  32263. private _audioEngine;
  32264. /**
  32265. * Creates a new analyser
  32266. * @param scene defines hosting scene
  32267. */
  32268. constructor(scene: Scene);
  32269. /**
  32270. * Get the number of data values you will have to play with for the visualization
  32271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32272. * @returns a number
  32273. */
  32274. getFrequencyBinCount(): number;
  32275. /**
  32276. * Gets the current frequency data as a byte array
  32277. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32278. * @returns a Uint8Array
  32279. */
  32280. getByteFrequencyData(): Uint8Array;
  32281. /**
  32282. * Gets the current waveform as a byte array
  32283. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32284. * @returns a Uint8Array
  32285. */
  32286. getByteTimeDomainData(): Uint8Array;
  32287. /**
  32288. * Gets the current frequency data as a float array
  32289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32290. * @returns a Float32Array
  32291. */
  32292. getFloatFrequencyData(): Float32Array;
  32293. /**
  32294. * Renders the debug canvas
  32295. */
  32296. drawDebugCanvas(): void;
  32297. /**
  32298. * Stops rendering the debug canvas and removes it
  32299. */
  32300. stopDebugCanvas(): void;
  32301. /**
  32302. * Connects two audio nodes
  32303. * @param inputAudioNode defines first node to connect
  32304. * @param outputAudioNode defines second node to connect
  32305. */
  32306. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32307. /**
  32308. * Releases all associated resources
  32309. */
  32310. dispose(): void;
  32311. }
  32312. }
  32313. declare module BABYLON {
  32314. /**
  32315. * This represents an audio engine and it is responsible
  32316. * to play, synchronize and analyse sounds throughout the application.
  32317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32318. */
  32319. export interface IAudioEngine extends IDisposable {
  32320. /**
  32321. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32322. */
  32323. readonly canUseWebAudio: boolean;
  32324. /**
  32325. * Gets the current AudioContext if available.
  32326. */
  32327. readonly audioContext: Nullable<AudioContext>;
  32328. /**
  32329. * The master gain node defines the global audio volume of your audio engine.
  32330. */
  32331. readonly masterGain: GainNode;
  32332. /**
  32333. * Gets whether or not mp3 are supported by your browser.
  32334. */
  32335. readonly isMP3supported: boolean;
  32336. /**
  32337. * Gets whether or not ogg are supported by your browser.
  32338. */
  32339. readonly isOGGsupported: boolean;
  32340. /**
  32341. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32342. * @ignoreNaming
  32343. */
  32344. WarnedWebAudioUnsupported: boolean;
  32345. /**
  32346. * Defines if the audio engine relies on a custom unlocked button.
  32347. * In this case, the embedded button will not be displayed.
  32348. */
  32349. useCustomUnlockedButton: boolean;
  32350. /**
  32351. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32352. */
  32353. readonly unlocked: boolean;
  32354. /**
  32355. * Event raised when audio has been unlocked on the browser.
  32356. */
  32357. onAudioUnlockedObservable: Observable<AudioEngine>;
  32358. /**
  32359. * Event raised when audio has been locked on the browser.
  32360. */
  32361. onAudioLockedObservable: Observable<AudioEngine>;
  32362. /**
  32363. * Flags the audio engine in Locked state.
  32364. * This happens due to new browser policies preventing audio to autoplay.
  32365. */
  32366. lock(): void;
  32367. /**
  32368. * Unlocks the audio engine once a user action has been done on the dom.
  32369. * This is helpful to resume play once browser policies have been satisfied.
  32370. */
  32371. unlock(): void;
  32372. }
  32373. /**
  32374. * This represents the default audio engine used in babylon.
  32375. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32377. */
  32378. export class AudioEngine implements IAudioEngine {
  32379. private _audioContext;
  32380. private _audioContextInitialized;
  32381. private _muteButton;
  32382. private _hostElement;
  32383. /**
  32384. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32385. */
  32386. canUseWebAudio: boolean;
  32387. /**
  32388. * The master gain node defines the global audio volume of your audio engine.
  32389. */
  32390. masterGain: GainNode;
  32391. /**
  32392. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32393. * @ignoreNaming
  32394. */
  32395. WarnedWebAudioUnsupported: boolean;
  32396. /**
  32397. * Gets whether or not mp3 are supported by your browser.
  32398. */
  32399. isMP3supported: boolean;
  32400. /**
  32401. * Gets whether or not ogg are supported by your browser.
  32402. */
  32403. isOGGsupported: boolean;
  32404. /**
  32405. * Gets whether audio has been unlocked on the device.
  32406. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32407. * a user interaction has happened.
  32408. */
  32409. unlocked: boolean;
  32410. /**
  32411. * Defines if the audio engine relies on a custom unlocked button.
  32412. * In this case, the embedded button will not be displayed.
  32413. */
  32414. useCustomUnlockedButton: boolean;
  32415. /**
  32416. * Event raised when audio has been unlocked on the browser.
  32417. */
  32418. onAudioUnlockedObservable: Observable<AudioEngine>;
  32419. /**
  32420. * Event raised when audio has been locked on the browser.
  32421. */
  32422. onAudioLockedObservable: Observable<AudioEngine>;
  32423. /**
  32424. * Gets the current AudioContext if available.
  32425. */
  32426. get audioContext(): Nullable<AudioContext>;
  32427. private _connectedAnalyser;
  32428. /**
  32429. * Instantiates a new audio engine.
  32430. *
  32431. * There should be only one per page as some browsers restrict the number
  32432. * of audio contexts you can create.
  32433. * @param hostElement defines the host element where to display the mute icon if necessary
  32434. */
  32435. constructor(hostElement?: Nullable<HTMLElement>);
  32436. /**
  32437. * Flags the audio engine in Locked state.
  32438. * This happens due to new browser policies preventing audio to autoplay.
  32439. */
  32440. lock(): void;
  32441. /**
  32442. * Unlocks the audio engine once a user action has been done on the dom.
  32443. * This is helpful to resume play once browser policies have been satisfied.
  32444. */
  32445. unlock(): void;
  32446. private _resumeAudioContext;
  32447. private _initializeAudioContext;
  32448. private _tryToRun;
  32449. private _triggerRunningState;
  32450. private _triggerSuspendedState;
  32451. private _displayMuteButton;
  32452. private _moveButtonToTopLeft;
  32453. private _onResize;
  32454. private _hideMuteButton;
  32455. /**
  32456. * Destroy and release the resources associated with the audio ccontext.
  32457. */
  32458. dispose(): void;
  32459. /**
  32460. * Gets the global volume sets on the master gain.
  32461. * @returns the global volume if set or -1 otherwise
  32462. */
  32463. getGlobalVolume(): number;
  32464. /**
  32465. * Sets the global volume of your experience (sets on the master gain).
  32466. * @param newVolume Defines the new global volume of the application
  32467. */
  32468. setGlobalVolume(newVolume: number): void;
  32469. /**
  32470. * Connect the audio engine to an audio analyser allowing some amazing
  32471. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32473. * @param analyser The analyser to connect to the engine
  32474. */
  32475. connectToAnalyser(analyser: Analyser): void;
  32476. }
  32477. }
  32478. declare module BABYLON {
  32479. /**
  32480. * Interface used to present a loading screen while loading a scene
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. export interface ILoadingScreen {
  32484. /**
  32485. * Function called to display the loading screen
  32486. */
  32487. displayLoadingUI: () => void;
  32488. /**
  32489. * Function called to hide the loading screen
  32490. */
  32491. hideLoadingUI: () => void;
  32492. /**
  32493. * Gets or sets the color to use for the background
  32494. */
  32495. loadingUIBackgroundColor: string;
  32496. /**
  32497. * Gets or sets the text to display while loading
  32498. */
  32499. loadingUIText: string;
  32500. }
  32501. /**
  32502. * Class used for the default loading screen
  32503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32504. */
  32505. export class DefaultLoadingScreen implements ILoadingScreen {
  32506. private _renderingCanvas;
  32507. private _loadingText;
  32508. private _loadingDivBackgroundColor;
  32509. private _loadingDiv;
  32510. private _loadingTextDiv;
  32511. /** Gets or sets the logo url to use for the default loading screen */
  32512. static DefaultLogoUrl: string;
  32513. /** Gets or sets the spinner url to use for the default loading screen */
  32514. static DefaultSpinnerUrl: string;
  32515. /**
  32516. * Creates a new default loading screen
  32517. * @param _renderingCanvas defines the canvas used to render the scene
  32518. * @param _loadingText defines the default text to display
  32519. * @param _loadingDivBackgroundColor defines the default background color
  32520. */
  32521. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32522. /**
  32523. * Function called to display the loading screen
  32524. */
  32525. displayLoadingUI(): void;
  32526. /**
  32527. * Function called to hide the loading screen
  32528. */
  32529. hideLoadingUI(): void;
  32530. /**
  32531. * Gets or sets the text to display while loading
  32532. */
  32533. set loadingUIText(text: string);
  32534. get loadingUIText(): string;
  32535. /**
  32536. * Gets or sets the color to use for the background
  32537. */
  32538. get loadingUIBackgroundColor(): string;
  32539. set loadingUIBackgroundColor(color: string);
  32540. private _resizeLoadingUI;
  32541. }
  32542. }
  32543. declare module BABYLON {
  32544. /**
  32545. * Interface for any object that can request an animation frame
  32546. */
  32547. export interface ICustomAnimationFrameRequester {
  32548. /**
  32549. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32550. */
  32551. renderFunction?: Function;
  32552. /**
  32553. * Called to request the next frame to render to
  32554. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32555. */
  32556. requestAnimationFrame: Function;
  32557. /**
  32558. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32559. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32560. */
  32561. requestID?: number;
  32562. }
  32563. }
  32564. declare module BABYLON {
  32565. /**
  32566. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32567. */
  32568. export class PerformanceMonitor {
  32569. private _enabled;
  32570. private _rollingFrameTime;
  32571. private _lastFrameTimeMs;
  32572. /**
  32573. * constructor
  32574. * @param frameSampleSize The number of samples required to saturate the sliding window
  32575. */
  32576. constructor(frameSampleSize?: number);
  32577. /**
  32578. * Samples current frame
  32579. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32580. */
  32581. sampleFrame(timeMs?: number): void;
  32582. /**
  32583. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32584. */
  32585. get averageFrameTime(): number;
  32586. /**
  32587. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32588. */
  32589. get averageFrameTimeVariance(): number;
  32590. /**
  32591. * Returns the frame time of the most recent frame
  32592. */
  32593. get instantaneousFrameTime(): number;
  32594. /**
  32595. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32596. */
  32597. get averageFPS(): number;
  32598. /**
  32599. * Returns the average framerate in frames per second using the most recent frame time
  32600. */
  32601. get instantaneousFPS(): number;
  32602. /**
  32603. * Returns true if enough samples have been taken to completely fill the sliding window
  32604. */
  32605. get isSaturated(): boolean;
  32606. /**
  32607. * Enables contributions to the sliding window sample set
  32608. */
  32609. enable(): void;
  32610. /**
  32611. * Disables contributions to the sliding window sample set
  32612. * Samples will not be interpolated over the disabled period
  32613. */
  32614. disable(): void;
  32615. /**
  32616. * Returns true if sampling is enabled
  32617. */
  32618. get isEnabled(): boolean;
  32619. /**
  32620. * Resets performance monitor
  32621. */
  32622. reset(): void;
  32623. }
  32624. /**
  32625. * RollingAverage
  32626. *
  32627. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32628. */
  32629. export class RollingAverage {
  32630. /**
  32631. * Current average
  32632. */
  32633. average: number;
  32634. /**
  32635. * Current variance
  32636. */
  32637. variance: number;
  32638. protected _samples: Array<number>;
  32639. protected _sampleCount: number;
  32640. protected _pos: number;
  32641. protected _m2: number;
  32642. /**
  32643. * constructor
  32644. * @param length The number of samples required to saturate the sliding window
  32645. */
  32646. constructor(length: number);
  32647. /**
  32648. * Adds a sample to the sample set
  32649. * @param v The sample value
  32650. */
  32651. add(v: number): void;
  32652. /**
  32653. * Returns previously added values or null if outside of history or outside the sliding window domain
  32654. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32655. * @return Value previously recorded with add() or null if outside of range
  32656. */
  32657. history(i: number): number;
  32658. /**
  32659. * Returns true if enough samples have been taken to completely fill the sliding window
  32660. * @return true if sample-set saturated
  32661. */
  32662. isSaturated(): boolean;
  32663. /**
  32664. * Resets the rolling average (equivalent to 0 samples taken so far)
  32665. */
  32666. reset(): void;
  32667. /**
  32668. * Wraps a value around the sample range boundaries
  32669. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32670. * @return Wrapped position in sample range
  32671. */
  32672. protected _wrapPosition(i: number): number;
  32673. }
  32674. }
  32675. declare module BABYLON {
  32676. /**
  32677. * This class is used to track a performance counter which is number based.
  32678. * The user has access to many properties which give statistics of different nature.
  32679. *
  32680. * The implementer can track two kinds of Performance Counter: time and count.
  32681. * 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.
  32682. * 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.
  32683. */
  32684. export class PerfCounter {
  32685. /**
  32686. * Gets or sets a global boolean to turn on and off all the counters
  32687. */
  32688. static Enabled: boolean;
  32689. /**
  32690. * Returns the smallest value ever
  32691. */
  32692. get min(): number;
  32693. /**
  32694. * Returns the biggest value ever
  32695. */
  32696. get max(): number;
  32697. /**
  32698. * Returns the average value since the performance counter is running
  32699. */
  32700. get average(): number;
  32701. /**
  32702. * Returns the average value of the last second the counter was monitored
  32703. */
  32704. get lastSecAverage(): number;
  32705. /**
  32706. * Returns the current value
  32707. */
  32708. get current(): number;
  32709. /**
  32710. * Gets the accumulated total
  32711. */
  32712. get total(): number;
  32713. /**
  32714. * Gets the total value count
  32715. */
  32716. get count(): number;
  32717. /**
  32718. * Creates a new counter
  32719. */
  32720. constructor();
  32721. /**
  32722. * Call this method to start monitoring a new frame.
  32723. * 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.
  32724. */
  32725. fetchNewFrame(): void;
  32726. /**
  32727. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32728. * @param newCount the count value to add to the monitored count
  32729. * @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.
  32730. */
  32731. addCount(newCount: number, fetchResult: boolean): void;
  32732. /**
  32733. * Start monitoring this performance counter
  32734. */
  32735. beginMonitoring(): void;
  32736. /**
  32737. * Compute the time lapsed since the previous beginMonitoring() call.
  32738. * @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
  32739. */
  32740. endMonitoring(newFrame?: boolean): void;
  32741. private _fetchResult;
  32742. private _startMonitoringTime;
  32743. private _min;
  32744. private _max;
  32745. private _average;
  32746. private _current;
  32747. private _totalValueCount;
  32748. private _totalAccumulated;
  32749. private _lastSecAverage;
  32750. private _lastSecAccumulated;
  32751. private _lastSecTime;
  32752. private _lastSecValueCount;
  32753. }
  32754. }
  32755. declare module BABYLON {
  32756. interface ThinEngine {
  32757. /**
  32758. * Sets alpha constants used by some alpha blending modes
  32759. * @param r defines the red component
  32760. * @param g defines the green component
  32761. * @param b defines the blue component
  32762. * @param a defines the alpha component
  32763. */
  32764. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32765. /**
  32766. * Sets the current alpha mode
  32767. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32768. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32770. */
  32771. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32772. /**
  32773. * Gets the current alpha mode
  32774. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32775. * @returns the current alpha mode
  32776. */
  32777. getAlphaMode(): number;
  32778. /**
  32779. * Sets the current alpha equation
  32780. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32781. */
  32782. setAlphaEquation(equation: number): void;
  32783. /**
  32784. * Gets the current alpha equation.
  32785. * @returns the current alpha equation
  32786. */
  32787. getAlphaEquation(): number;
  32788. }
  32789. }
  32790. declare module BABYLON {
  32791. /**
  32792. * Defines the interface used by display changed events
  32793. */
  32794. export interface IDisplayChangedEventArgs {
  32795. /** Gets the vrDisplay object (if any) */
  32796. vrDisplay: Nullable<any>;
  32797. /** Gets a boolean indicating if webVR is supported */
  32798. vrSupported: boolean;
  32799. }
  32800. /**
  32801. * Defines the interface used by objects containing a viewport (like a camera)
  32802. */
  32803. interface IViewportOwnerLike {
  32804. /**
  32805. * Gets or sets the viewport
  32806. */
  32807. viewport: IViewportLike;
  32808. }
  32809. /**
  32810. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32811. */
  32812. export class Engine extends ThinEngine {
  32813. /** Defines that alpha blending is disabled */
  32814. static readonly ALPHA_DISABLE: number;
  32815. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32816. static readonly ALPHA_ADD: number;
  32817. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32818. static readonly ALPHA_COMBINE: number;
  32819. /** Defines that alpha blending to DEST - SRC * DEST */
  32820. static readonly ALPHA_SUBTRACT: number;
  32821. /** Defines that alpha blending to SRC * DEST */
  32822. static readonly ALPHA_MULTIPLY: number;
  32823. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32824. static readonly ALPHA_MAXIMIZED: number;
  32825. /** Defines that alpha blending to SRC + DEST */
  32826. static readonly ALPHA_ONEONE: number;
  32827. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32828. static readonly ALPHA_PREMULTIPLIED: number;
  32829. /**
  32830. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32831. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32832. */
  32833. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32834. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32835. static readonly ALPHA_INTERPOLATE: number;
  32836. /**
  32837. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32838. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32839. */
  32840. static readonly ALPHA_SCREENMODE: number;
  32841. /** Defines that the ressource is not delayed*/
  32842. static readonly DELAYLOADSTATE_NONE: number;
  32843. /** Defines that the ressource was successfully delay loaded */
  32844. static readonly DELAYLOADSTATE_LOADED: number;
  32845. /** Defines that the ressource is currently delay loading */
  32846. static readonly DELAYLOADSTATE_LOADING: number;
  32847. /** Defines that the ressource is delayed and has not started loading */
  32848. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32850. static readonly NEVER: number;
  32851. /** 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 */
  32852. static readonly ALWAYS: number;
  32853. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32854. static readonly LESS: number;
  32855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32856. static readonly EQUAL: number;
  32857. /** 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 */
  32858. static readonly LEQUAL: number;
  32859. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32860. static readonly GREATER: number;
  32861. /** 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 */
  32862. static readonly GEQUAL: number;
  32863. /** 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 */
  32864. static readonly NOTEQUAL: number;
  32865. /** Passed to stencilOperation to specify that stencil value must be kept */
  32866. static readonly KEEP: number;
  32867. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32868. static readonly REPLACE: number;
  32869. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32870. static readonly INCR: number;
  32871. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32872. static readonly DECR: number;
  32873. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32874. static readonly INVERT: number;
  32875. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32876. static readonly INCR_WRAP: number;
  32877. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32878. static readonly DECR_WRAP: number;
  32879. /** Texture is not repeating outside of 0..1 UVs */
  32880. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32881. /** Texture is repeating outside of 0..1 UVs */
  32882. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32883. /** Texture is repeating and mirrored */
  32884. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32885. /** ALPHA */
  32886. static readonly TEXTUREFORMAT_ALPHA: number;
  32887. /** LUMINANCE */
  32888. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32889. /** LUMINANCE_ALPHA */
  32890. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32891. /** RGB */
  32892. static readonly TEXTUREFORMAT_RGB: number;
  32893. /** RGBA */
  32894. static readonly TEXTUREFORMAT_RGBA: number;
  32895. /** RED */
  32896. static readonly TEXTUREFORMAT_RED: number;
  32897. /** RED (2nd reference) */
  32898. static readonly TEXTUREFORMAT_R: number;
  32899. /** RG */
  32900. static readonly TEXTUREFORMAT_RG: number;
  32901. /** RED_INTEGER */
  32902. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32903. /** RED_INTEGER (2nd reference) */
  32904. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32905. /** RG_INTEGER */
  32906. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32907. /** RGB_INTEGER */
  32908. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32909. /** RGBA_INTEGER */
  32910. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32911. /** UNSIGNED_BYTE */
  32912. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32913. /** UNSIGNED_BYTE (2nd reference) */
  32914. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32915. /** FLOAT */
  32916. static readonly TEXTURETYPE_FLOAT: number;
  32917. /** HALF_FLOAT */
  32918. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32919. /** BYTE */
  32920. static readonly TEXTURETYPE_BYTE: number;
  32921. /** SHORT */
  32922. static readonly TEXTURETYPE_SHORT: number;
  32923. /** UNSIGNED_SHORT */
  32924. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32925. /** INT */
  32926. static readonly TEXTURETYPE_INT: number;
  32927. /** UNSIGNED_INT */
  32928. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32929. /** UNSIGNED_SHORT_4_4_4_4 */
  32930. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32931. /** UNSIGNED_SHORT_5_5_5_1 */
  32932. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32933. /** UNSIGNED_SHORT_5_6_5 */
  32934. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32935. /** UNSIGNED_INT_2_10_10_10_REV */
  32936. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32937. /** UNSIGNED_INT_24_8 */
  32938. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32939. /** UNSIGNED_INT_10F_11F_11F_REV */
  32940. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32941. /** UNSIGNED_INT_5_9_9_9_REV */
  32942. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32943. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32944. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32945. /** nearest is mag = nearest and min = nearest and mip = linear */
  32946. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32947. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32948. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32949. /** Trilinear is mag = linear and min = linear and mip = linear */
  32950. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32951. /** nearest is mag = nearest and min = nearest and mip = linear */
  32952. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32954. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32955. /** Trilinear is mag = linear and min = linear and mip = linear */
  32956. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32957. /** mag = nearest and min = nearest and mip = nearest */
  32958. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32959. /** mag = nearest and min = linear and mip = nearest */
  32960. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32961. /** mag = nearest and min = linear and mip = linear */
  32962. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32963. /** mag = nearest and min = linear and mip = none */
  32964. static readonly TEXTURE_NEAREST_LINEAR: number;
  32965. /** mag = nearest and min = nearest and mip = none */
  32966. static readonly TEXTURE_NEAREST_NEAREST: number;
  32967. /** mag = linear and min = nearest and mip = nearest */
  32968. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32969. /** mag = linear and min = nearest and mip = linear */
  32970. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32971. /** mag = linear and min = linear and mip = none */
  32972. static readonly TEXTURE_LINEAR_LINEAR: number;
  32973. /** mag = linear and min = nearest and mip = none */
  32974. static readonly TEXTURE_LINEAR_NEAREST: number;
  32975. /** Explicit coordinates mode */
  32976. static readonly TEXTURE_EXPLICIT_MODE: number;
  32977. /** Spherical coordinates mode */
  32978. static readonly TEXTURE_SPHERICAL_MODE: number;
  32979. /** Planar coordinates mode */
  32980. static readonly TEXTURE_PLANAR_MODE: number;
  32981. /** Cubic coordinates mode */
  32982. static readonly TEXTURE_CUBIC_MODE: number;
  32983. /** Projection coordinates mode */
  32984. static readonly TEXTURE_PROJECTION_MODE: number;
  32985. /** Skybox coordinates mode */
  32986. static readonly TEXTURE_SKYBOX_MODE: number;
  32987. /** Inverse Cubic coordinates mode */
  32988. static readonly TEXTURE_INVCUBIC_MODE: number;
  32989. /** Equirectangular coordinates mode */
  32990. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32991. /** Equirectangular Fixed coordinates mode */
  32992. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32993. /** Equirectangular Fixed Mirrored coordinates mode */
  32994. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32995. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32996. static readonly SCALEMODE_FLOOR: number;
  32997. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32998. static readonly SCALEMODE_NEAREST: number;
  32999. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33000. static readonly SCALEMODE_CEILING: number;
  33001. /**
  33002. * Returns the current npm package of the sdk
  33003. */
  33004. static get NpmPackage(): string;
  33005. /**
  33006. * Returns the current version of the framework
  33007. */
  33008. static get Version(): string;
  33009. /** Gets the list of created engines */
  33010. static get Instances(): Engine[];
  33011. /**
  33012. * Gets the latest created engine
  33013. */
  33014. static get LastCreatedEngine(): Nullable<Engine>;
  33015. /**
  33016. * Gets the latest created scene
  33017. */
  33018. static get LastCreatedScene(): Nullable<Scene>;
  33019. /**
  33020. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33021. * @param flag defines which part of the materials must be marked as dirty
  33022. * @param predicate defines a predicate used to filter which materials should be affected
  33023. */
  33024. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33025. /**
  33026. * Method called to create the default loading screen.
  33027. * This can be overriden in your own app.
  33028. * @param canvas The rendering canvas element
  33029. * @returns The loading screen
  33030. */
  33031. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33032. /**
  33033. * Method called to create the default rescale post process on each engine.
  33034. */
  33035. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33036. /**
  33037. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33038. **/
  33039. enableOfflineSupport: boolean;
  33040. /**
  33041. * 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)
  33042. **/
  33043. disableManifestCheck: boolean;
  33044. /**
  33045. * Gets the list of created scenes
  33046. */
  33047. scenes: Scene[];
  33048. /**
  33049. * Event raised when a new scene is created
  33050. */
  33051. onNewSceneAddedObservable: Observable<Scene>;
  33052. /**
  33053. * Gets the list of created postprocesses
  33054. */
  33055. postProcesses: PostProcess[];
  33056. /**
  33057. * Gets a boolean indicating if the pointer is currently locked
  33058. */
  33059. isPointerLock: boolean;
  33060. /**
  33061. * Observable event triggered each time the rendering canvas is resized
  33062. */
  33063. onResizeObservable: Observable<Engine>;
  33064. /**
  33065. * Observable event triggered each time the canvas loses focus
  33066. */
  33067. onCanvasBlurObservable: Observable<Engine>;
  33068. /**
  33069. * Observable event triggered each time the canvas gains focus
  33070. */
  33071. onCanvasFocusObservable: Observable<Engine>;
  33072. /**
  33073. * Observable event triggered each time the canvas receives pointerout event
  33074. */
  33075. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33076. /**
  33077. * Observable raised when the engine begins a new frame
  33078. */
  33079. onBeginFrameObservable: Observable<Engine>;
  33080. /**
  33081. * If set, will be used to request the next animation frame for the render loop
  33082. */
  33083. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33084. /**
  33085. * Observable raised when the engine ends the current frame
  33086. */
  33087. onEndFrameObservable: Observable<Engine>;
  33088. /**
  33089. * Observable raised when the engine is about to compile a shader
  33090. */
  33091. onBeforeShaderCompilationObservable: Observable<Engine>;
  33092. /**
  33093. * Observable raised when the engine has jsut compiled a shader
  33094. */
  33095. onAfterShaderCompilationObservable: Observable<Engine>;
  33096. /**
  33097. * Gets the audio engine
  33098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33099. * @ignorenaming
  33100. */
  33101. static audioEngine: IAudioEngine;
  33102. /**
  33103. * Default AudioEngine factory responsible of creating the Audio Engine.
  33104. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33105. */
  33106. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33107. /**
  33108. * Default offline support factory responsible of creating a tool used to store data locally.
  33109. * By default, this will create a Database object if the workload has been embedded.
  33110. */
  33111. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33112. private _loadingScreen;
  33113. private _pointerLockRequested;
  33114. private _dummyFramebuffer;
  33115. private _rescalePostProcess;
  33116. private _deterministicLockstep;
  33117. private _lockstepMaxSteps;
  33118. private _timeStep;
  33119. protected get _supportsHardwareTextureRescaling(): boolean;
  33120. private _fps;
  33121. private _deltaTime;
  33122. /** @hidden */
  33123. _drawCalls: PerfCounter;
  33124. /**
  33125. * Turn this value on if you want to pause FPS computation when in background
  33126. */
  33127. disablePerformanceMonitorInBackground: boolean;
  33128. private _performanceMonitor;
  33129. /**
  33130. * Gets the performance monitor attached to this engine
  33131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33132. */
  33133. get performanceMonitor(): PerformanceMonitor;
  33134. private _onFocus;
  33135. private _onBlur;
  33136. private _onCanvasPointerOut;
  33137. private _onCanvasBlur;
  33138. private _onCanvasFocus;
  33139. private _onFullscreenChange;
  33140. private _onPointerLockChange;
  33141. /**
  33142. * Gets the HTML element used to attach event listeners
  33143. * @returns a HTML element
  33144. */
  33145. getInputElement(): Nullable<HTMLElement>;
  33146. /**
  33147. * Creates a new engine
  33148. * @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
  33149. * @param antialias defines enable antialiasing (default: false)
  33150. * @param options defines further options to be sent to the getContext() function
  33151. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33152. */
  33153. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33154. /**
  33155. * Gets current aspect ratio
  33156. * @param viewportOwner defines the camera to use to get the aspect ratio
  33157. * @param useScreen defines if screen size must be used (or the current render target if any)
  33158. * @returns a number defining the aspect ratio
  33159. */
  33160. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33161. /**
  33162. * Gets current screen aspect ratio
  33163. * @returns a number defining the aspect ratio
  33164. */
  33165. getScreenAspectRatio(): number;
  33166. /**
  33167. * Gets the client rect of the HTML canvas attached with the current webGL context
  33168. * @returns a client rectanglee
  33169. */
  33170. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33171. /**
  33172. * Gets the client rect of the HTML element used for events
  33173. * @returns a client rectanglee
  33174. */
  33175. getInputElementClientRect(): Nullable<ClientRect>;
  33176. /**
  33177. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33178. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33179. * @returns true if engine is in deterministic lock step mode
  33180. */
  33181. isDeterministicLockStep(): boolean;
  33182. /**
  33183. * Gets the max steps when engine is running in deterministic lock step
  33184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33185. * @returns the max steps
  33186. */
  33187. getLockstepMaxSteps(): number;
  33188. /**
  33189. * Returns the time in ms between steps when using deterministic lock step.
  33190. * @returns time step in (ms)
  33191. */
  33192. getTimeStep(): number;
  33193. /**
  33194. * Force the mipmap generation for the given render target texture
  33195. * @param texture defines the render target texture to use
  33196. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33197. */
  33198. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33199. /** States */
  33200. /**
  33201. * Set various states to the webGL context
  33202. * @param culling defines backface culling state
  33203. * @param zOffset defines the value to apply to zOffset (0 by default)
  33204. * @param force defines if states must be applied even if cache is up to date
  33205. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33206. */
  33207. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33208. /**
  33209. * Set the z offset to apply to current rendering
  33210. * @param value defines the offset to apply
  33211. */
  33212. setZOffset(value: number): void;
  33213. /**
  33214. * Gets the current value of the zOffset
  33215. * @returns the current zOffset state
  33216. */
  33217. getZOffset(): number;
  33218. /**
  33219. * Enable or disable depth buffering
  33220. * @param enable defines the state to set
  33221. */
  33222. setDepthBuffer(enable: boolean): void;
  33223. /**
  33224. * Gets a boolean indicating if depth writing is enabled
  33225. * @returns the current depth writing state
  33226. */
  33227. getDepthWrite(): boolean;
  33228. /**
  33229. * Enable or disable depth writing
  33230. * @param enable defines the state to set
  33231. */
  33232. setDepthWrite(enable: boolean): void;
  33233. /**
  33234. * Gets a boolean indicating if stencil buffer is enabled
  33235. * @returns the current stencil buffer state
  33236. */
  33237. getStencilBuffer(): boolean;
  33238. /**
  33239. * Enable or disable the stencil buffer
  33240. * @param enable defines if the stencil buffer must be enabled or disabled
  33241. */
  33242. setStencilBuffer(enable: boolean): void;
  33243. /**
  33244. * Gets the current stencil mask
  33245. * @returns a number defining the new stencil mask to use
  33246. */
  33247. getStencilMask(): number;
  33248. /**
  33249. * Sets the current stencil mask
  33250. * @param mask defines the new stencil mask to use
  33251. */
  33252. setStencilMask(mask: number): void;
  33253. /**
  33254. * Gets the current stencil function
  33255. * @returns a number defining the stencil function to use
  33256. */
  33257. getStencilFunction(): number;
  33258. /**
  33259. * Gets the current stencil reference value
  33260. * @returns a number defining the stencil reference value to use
  33261. */
  33262. getStencilFunctionReference(): number;
  33263. /**
  33264. * Gets the current stencil mask
  33265. * @returns a number defining the stencil mask to use
  33266. */
  33267. getStencilFunctionMask(): number;
  33268. /**
  33269. * Sets the current stencil function
  33270. * @param stencilFunc defines the new stencil function to use
  33271. */
  33272. setStencilFunction(stencilFunc: number): void;
  33273. /**
  33274. * Sets the current stencil reference
  33275. * @param reference defines the new stencil reference to use
  33276. */
  33277. setStencilFunctionReference(reference: number): void;
  33278. /**
  33279. * Sets the current stencil mask
  33280. * @param mask defines the new stencil mask to use
  33281. */
  33282. setStencilFunctionMask(mask: number): void;
  33283. /**
  33284. * Gets the current stencil operation when stencil fails
  33285. * @returns a number defining stencil operation to use when stencil fails
  33286. */
  33287. getStencilOperationFail(): number;
  33288. /**
  33289. * Gets the current stencil operation when depth fails
  33290. * @returns a number defining stencil operation to use when depth fails
  33291. */
  33292. getStencilOperationDepthFail(): number;
  33293. /**
  33294. * Gets the current stencil operation when stencil passes
  33295. * @returns a number defining stencil operation to use when stencil passes
  33296. */
  33297. getStencilOperationPass(): number;
  33298. /**
  33299. * Sets the stencil operation to use when stencil fails
  33300. * @param operation defines the stencil operation to use when stencil fails
  33301. */
  33302. setStencilOperationFail(operation: number): void;
  33303. /**
  33304. * Sets the stencil operation to use when depth fails
  33305. * @param operation defines the stencil operation to use when depth fails
  33306. */
  33307. setStencilOperationDepthFail(operation: number): void;
  33308. /**
  33309. * Sets the stencil operation to use when stencil passes
  33310. * @param operation defines the stencil operation to use when stencil passes
  33311. */
  33312. setStencilOperationPass(operation: number): void;
  33313. /**
  33314. * Sets a boolean indicating if the dithering state is enabled or disabled
  33315. * @param value defines the dithering state
  33316. */
  33317. setDitheringState(value: boolean): void;
  33318. /**
  33319. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33320. * @param value defines the rasterizer state
  33321. */
  33322. setRasterizerState(value: boolean): void;
  33323. /**
  33324. * Gets the current depth function
  33325. * @returns a number defining the depth function
  33326. */
  33327. getDepthFunction(): Nullable<number>;
  33328. /**
  33329. * Sets the current depth function
  33330. * @param depthFunc defines the function to use
  33331. */
  33332. setDepthFunction(depthFunc: number): void;
  33333. /**
  33334. * Sets the current depth function to GREATER
  33335. */
  33336. setDepthFunctionToGreater(): void;
  33337. /**
  33338. * Sets the current depth function to GEQUAL
  33339. */
  33340. setDepthFunctionToGreaterOrEqual(): void;
  33341. /**
  33342. * Sets the current depth function to LESS
  33343. */
  33344. setDepthFunctionToLess(): void;
  33345. /**
  33346. * Sets the current depth function to LEQUAL
  33347. */
  33348. setDepthFunctionToLessOrEqual(): void;
  33349. private _cachedStencilBuffer;
  33350. private _cachedStencilFunction;
  33351. private _cachedStencilMask;
  33352. private _cachedStencilOperationPass;
  33353. private _cachedStencilOperationFail;
  33354. private _cachedStencilOperationDepthFail;
  33355. private _cachedStencilReference;
  33356. /**
  33357. * Caches the the state of the stencil buffer
  33358. */
  33359. cacheStencilState(): void;
  33360. /**
  33361. * Restores the state of the stencil buffer
  33362. */
  33363. restoreStencilState(): void;
  33364. /**
  33365. * Directly set the WebGL Viewport
  33366. * @param x defines the x coordinate of the viewport (in screen space)
  33367. * @param y defines the y coordinate of the viewport (in screen space)
  33368. * @param width defines the width of the viewport (in screen space)
  33369. * @param height defines the height of the viewport (in screen space)
  33370. * @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
  33371. */
  33372. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33373. /**
  33374. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33375. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33376. * @param y defines the y-coordinate of the corner of the clear rectangle
  33377. * @param width defines the width of the clear rectangle
  33378. * @param height defines the height of the clear rectangle
  33379. * @param clearColor defines the clear color
  33380. */
  33381. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33382. /**
  33383. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33384. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33385. * @param y defines the y-coordinate of the corner of the clear rectangle
  33386. * @param width defines the width of the clear rectangle
  33387. * @param height defines the height of the clear rectangle
  33388. */
  33389. enableScissor(x: number, y: number, width: number, height: number): void;
  33390. /**
  33391. * Disable previously set scissor test rectangle
  33392. */
  33393. disableScissor(): void;
  33394. protected _reportDrawCall(): void;
  33395. /**
  33396. * Initializes a webVR display and starts listening to display change events
  33397. * The onVRDisplayChangedObservable will be notified upon these changes
  33398. * @returns The onVRDisplayChangedObservable
  33399. */
  33400. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33401. /** @hidden */
  33402. _prepareVRComponent(): void;
  33403. /** @hidden */
  33404. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33405. /** @hidden */
  33406. _submitVRFrame(): void;
  33407. /**
  33408. * Call this function to leave webVR mode
  33409. * Will do nothing if webVR is not supported or if there is no webVR device
  33410. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33411. */
  33412. disableVR(): void;
  33413. /**
  33414. * Gets a boolean indicating that the system is in VR mode and is presenting
  33415. * @returns true if VR mode is engaged
  33416. */
  33417. isVRPresenting(): boolean;
  33418. /** @hidden */
  33419. _requestVRFrame(): void;
  33420. /** @hidden */
  33421. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33422. /**
  33423. * Gets the source code of the vertex shader associated with a specific webGL program
  33424. * @param program defines the program to use
  33425. * @returns a string containing the source code of the vertex shader associated with the program
  33426. */
  33427. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33428. /**
  33429. * Gets the source code of the fragment shader associated with a specific webGL program
  33430. * @param program defines the program to use
  33431. * @returns a string containing the source code of the fragment shader associated with the program
  33432. */
  33433. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33434. /**
  33435. * Sets a depth stencil texture from a render target to the according uniform.
  33436. * @param channel The texture channel
  33437. * @param uniform The uniform to set
  33438. * @param texture The render target texture containing the depth stencil texture to apply
  33439. */
  33440. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33441. /**
  33442. * Sets a texture to the webGL context from a postprocess
  33443. * @param channel defines the channel to use
  33444. * @param postProcess defines the source postprocess
  33445. */
  33446. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33447. /**
  33448. * Binds the output of the passed in post process to the texture channel specified
  33449. * @param channel The channel the texture should be bound to
  33450. * @param postProcess The post process which's output should be bound
  33451. */
  33452. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33453. /** @hidden */
  33454. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33455. protected _rebuildBuffers(): void;
  33456. /** @hidden */
  33457. _renderFrame(): void;
  33458. _renderLoop(): void;
  33459. /** @hidden */
  33460. _renderViews(): boolean;
  33461. /**
  33462. * Toggle full screen mode
  33463. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33464. */
  33465. switchFullscreen(requestPointerLock: boolean): void;
  33466. /**
  33467. * Enters full screen mode
  33468. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33469. */
  33470. enterFullscreen(requestPointerLock: boolean): void;
  33471. /**
  33472. * Exits full screen mode
  33473. */
  33474. exitFullscreen(): void;
  33475. /**
  33476. * Enters Pointerlock mode
  33477. */
  33478. enterPointerlock(): void;
  33479. /**
  33480. * Exits Pointerlock mode
  33481. */
  33482. exitPointerlock(): void;
  33483. /**
  33484. * Begin a new frame
  33485. */
  33486. beginFrame(): void;
  33487. /**
  33488. * Enf the current frame
  33489. */
  33490. endFrame(): void;
  33491. resize(): void;
  33492. /**
  33493. * Set the compressed texture format to use, based on the formats you have, and the formats
  33494. * supported by the hardware / browser.
  33495. *
  33496. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33497. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33498. * to API arguments needed to compressed textures. This puts the burden on the container
  33499. * generator to house the arcane code for determining these for current & future formats.
  33500. *
  33501. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33502. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33503. *
  33504. * Note: The result of this call is not taken into account when a texture is base64.
  33505. *
  33506. * @param formatsAvailable defines the list of those format families you have created
  33507. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33508. *
  33509. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33510. * @returns The extension selected.
  33511. */
  33512. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33513. /**
  33514. * Set the compressed texture extensions or file names to skip.
  33515. *
  33516. * @param skippedFiles defines the list of those texture files you want to skip
  33517. * Example: [".dds", ".env", "myfile.png"]
  33518. */
  33519. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33520. /**
  33521. * Force a specific size of the canvas
  33522. * @param width defines the new canvas' width
  33523. * @param height defines the new canvas' height
  33524. */
  33525. setSize(width: number, height: number): void;
  33526. /**
  33527. * Updates a dynamic vertex buffer.
  33528. * @param vertexBuffer the vertex buffer to update
  33529. * @param data the data used to update the vertex buffer
  33530. * @param byteOffset the byte offset of the data
  33531. * @param byteLength the byte length of the data
  33532. */
  33533. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33534. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33535. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33536. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33537. _releaseTexture(texture: InternalTexture): void;
  33538. /**
  33539. * @hidden
  33540. * Rescales a texture
  33541. * @param source input texutre
  33542. * @param destination destination texture
  33543. * @param scene scene to use to render the resize
  33544. * @param internalFormat format to use when resizing
  33545. * @param onComplete callback to be called when resize has completed
  33546. */
  33547. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33548. /**
  33549. * Gets the current framerate
  33550. * @returns a number representing the framerate
  33551. */
  33552. getFps(): number;
  33553. /**
  33554. * Gets the time spent between current and previous frame
  33555. * @returns a number representing the delta time in ms
  33556. */
  33557. getDeltaTime(): number;
  33558. private _measureFps;
  33559. /** @hidden */
  33560. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33561. /**
  33562. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33563. * @param renderTarget The render target to set the frame buffer for
  33564. */
  33565. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33566. /**
  33567. * Update a dynamic index buffer
  33568. * @param indexBuffer defines the target index buffer
  33569. * @param indices defines the data to update
  33570. * @param offset defines the offset in the target index buffer where update should start
  33571. */
  33572. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33573. /**
  33574. * Updates the sample count of a render target texture
  33575. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33576. * @param texture defines the texture to update
  33577. * @param samples defines the sample count to set
  33578. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33579. */
  33580. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33581. /**
  33582. * Updates a depth texture Comparison Mode and Function.
  33583. * If the comparison Function is equal to 0, the mode will be set to none.
  33584. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33585. * @param texture The texture to set the comparison function for
  33586. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33587. */
  33588. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33589. /**
  33590. * Creates a webGL buffer to use with instanciation
  33591. * @param capacity defines the size of the buffer
  33592. * @returns the webGL buffer
  33593. */
  33594. createInstancesBuffer(capacity: number): DataBuffer;
  33595. /**
  33596. * Delete a webGL buffer used with instanciation
  33597. * @param buffer defines the webGL buffer to delete
  33598. */
  33599. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33600. /** @hidden */
  33601. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33602. dispose(): void;
  33603. private _disableTouchAction;
  33604. /**
  33605. * Display the loading screen
  33606. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33607. */
  33608. displayLoadingUI(): void;
  33609. /**
  33610. * Hide the loading screen
  33611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33612. */
  33613. hideLoadingUI(): void;
  33614. /**
  33615. * Gets the current loading screen object
  33616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33617. */
  33618. get loadingScreen(): ILoadingScreen;
  33619. /**
  33620. * Sets the current loading screen object
  33621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33622. */
  33623. set loadingScreen(loadingScreen: ILoadingScreen);
  33624. /**
  33625. * Sets the current loading screen text
  33626. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33627. */
  33628. set loadingUIText(text: string);
  33629. /**
  33630. * Sets the current loading screen background color
  33631. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33632. */
  33633. set loadingUIBackgroundColor(color: string);
  33634. /** Pointerlock and fullscreen */
  33635. /**
  33636. * Ask the browser to promote the current element to pointerlock mode
  33637. * @param element defines the DOM element to promote
  33638. */
  33639. static _RequestPointerlock(element: HTMLElement): void;
  33640. /**
  33641. * Asks the browser to exit pointerlock mode
  33642. */
  33643. static _ExitPointerlock(): void;
  33644. /**
  33645. * Ask the browser to promote the current element to fullscreen rendering mode
  33646. * @param element defines the DOM element to promote
  33647. */
  33648. static _RequestFullscreen(element: HTMLElement): void;
  33649. /**
  33650. * Asks the browser to exit fullscreen mode
  33651. */
  33652. static _ExitFullscreen(): void;
  33653. }
  33654. }
  33655. declare module BABYLON {
  33656. /**
  33657. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33658. * during the life time of the application.
  33659. */
  33660. export class EngineStore {
  33661. /** Gets the list of created engines */
  33662. static Instances: Engine[];
  33663. /** @hidden */
  33664. static _LastCreatedScene: Nullable<Scene>;
  33665. /**
  33666. * Gets the latest created engine
  33667. */
  33668. static get LastCreatedEngine(): Nullable<Engine>;
  33669. /**
  33670. * Gets the latest created scene
  33671. */
  33672. static get LastCreatedScene(): Nullable<Scene>;
  33673. /**
  33674. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33675. * @ignorenaming
  33676. */
  33677. static UseFallbackTexture: boolean;
  33678. /**
  33679. * Texture content used if a texture cannot loaded
  33680. * @ignorenaming
  33681. */
  33682. static FallbackTexture: string;
  33683. }
  33684. }
  33685. declare module BABYLON {
  33686. /**
  33687. * Helper class that provides a small promise polyfill
  33688. */
  33689. export class PromisePolyfill {
  33690. /**
  33691. * Static function used to check if the polyfill is required
  33692. * If this is the case then the function will inject the polyfill to window.Promise
  33693. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33694. */
  33695. static Apply(force?: boolean): void;
  33696. }
  33697. }
  33698. declare module BABYLON {
  33699. /**
  33700. * Interface for screenshot methods with describe argument called `size` as object with options
  33701. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33702. */
  33703. export interface IScreenshotSize {
  33704. /**
  33705. * number in pixels for canvas height
  33706. */
  33707. height?: number;
  33708. /**
  33709. * multiplier allowing render at a higher or lower resolution
  33710. * If value is defined then height and width will be ignored and taken from camera
  33711. */
  33712. precision?: number;
  33713. /**
  33714. * number in pixels for canvas width
  33715. */
  33716. width?: number;
  33717. }
  33718. }
  33719. declare module BABYLON {
  33720. interface IColor4Like {
  33721. r: float;
  33722. g: float;
  33723. b: float;
  33724. a: float;
  33725. }
  33726. /**
  33727. * Class containing a set of static utilities functions
  33728. */
  33729. export class Tools {
  33730. /**
  33731. * Gets or sets the base URL to use to load assets
  33732. */
  33733. static get BaseUrl(): string;
  33734. static set BaseUrl(value: string);
  33735. /**
  33736. * Enable/Disable Custom HTTP Request Headers globally.
  33737. * default = false
  33738. * @see CustomRequestHeaders
  33739. */
  33740. static UseCustomRequestHeaders: boolean;
  33741. /**
  33742. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33743. * i.e. when loading files, where the server/service expects an Authorization header
  33744. */
  33745. static CustomRequestHeaders: {
  33746. [key: string]: string;
  33747. };
  33748. /**
  33749. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33750. */
  33751. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33752. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33753. /**
  33754. * Default behaviour for cors in the application.
  33755. * It can be a string if the expected behavior is identical in the entire app.
  33756. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33757. */
  33758. static CorsBehavior: string | ((url: string | string[]) => string);
  33759. /**
  33760. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33761. * @ignorenaming
  33762. */
  33763. static get UseFallbackTexture(): boolean;
  33764. static set UseFallbackTexture(value: boolean);
  33765. /**
  33766. * Use this object to register external classes like custom textures or material
  33767. * to allow the laoders to instantiate them
  33768. */
  33769. static get RegisteredExternalClasses(): {
  33770. [key: string]: Object;
  33771. };
  33772. static set RegisteredExternalClasses(classes: {
  33773. [key: string]: Object;
  33774. });
  33775. /**
  33776. * Texture content used if a texture cannot loaded
  33777. * @ignorenaming
  33778. */
  33779. static get fallbackTexture(): string;
  33780. static set fallbackTexture(value: string);
  33781. /**
  33782. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33783. * @param u defines the coordinate on X axis
  33784. * @param v defines the coordinate on Y axis
  33785. * @param width defines the width of the source data
  33786. * @param height defines the height of the source data
  33787. * @param pixels defines the source byte array
  33788. * @param color defines the output color
  33789. */
  33790. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33791. /**
  33792. * Interpolates between a and b via alpha
  33793. * @param a The lower value (returned when alpha = 0)
  33794. * @param b The upper value (returned when alpha = 1)
  33795. * @param alpha The interpolation-factor
  33796. * @return The mixed value
  33797. */
  33798. static Mix(a: number, b: number, alpha: number): number;
  33799. /**
  33800. * Tries to instantiate a new object from a given class name
  33801. * @param className defines the class name to instantiate
  33802. * @returns the new object or null if the system was not able to do the instantiation
  33803. */
  33804. static Instantiate(className: string): any;
  33805. /**
  33806. * Provides a slice function that will work even on IE
  33807. * @param data defines the array to slice
  33808. * @param start defines the start of the data (optional)
  33809. * @param end defines the end of the data (optional)
  33810. * @returns the new sliced array
  33811. */
  33812. static Slice<T>(data: T, start?: number, end?: number): T;
  33813. /**
  33814. * Polyfill for setImmediate
  33815. * @param action defines the action to execute after the current execution block
  33816. */
  33817. static SetImmediate(action: () => void): void;
  33818. /**
  33819. * Function indicating if a number is an exponent of 2
  33820. * @param value defines the value to test
  33821. * @returns true if the value is an exponent of 2
  33822. */
  33823. static IsExponentOfTwo(value: number): boolean;
  33824. private static _tmpFloatArray;
  33825. /**
  33826. * Returns the nearest 32-bit single precision float representation of a Number
  33827. * @param value A Number. If the parameter is of a different type, it will get converted
  33828. * to a number or to NaN if it cannot be converted
  33829. * @returns number
  33830. */
  33831. static FloatRound(value: number): number;
  33832. /**
  33833. * Extracts the filename from a path
  33834. * @param path defines the path to use
  33835. * @returns the filename
  33836. */
  33837. static GetFilename(path: string): string;
  33838. /**
  33839. * Extracts the "folder" part of a path (everything before the filename).
  33840. * @param uri The URI to extract the info from
  33841. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33842. * @returns The "folder" part of the path
  33843. */
  33844. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33845. /**
  33846. * Extracts text content from a DOM element hierarchy
  33847. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33848. */
  33849. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33850. /**
  33851. * Convert an angle in radians to degrees
  33852. * @param angle defines the angle to convert
  33853. * @returns the angle in degrees
  33854. */
  33855. static ToDegrees(angle: number): number;
  33856. /**
  33857. * Convert an angle in degrees to radians
  33858. * @param angle defines the angle to convert
  33859. * @returns the angle in radians
  33860. */
  33861. static ToRadians(angle: number): number;
  33862. /**
  33863. * Returns an array if obj is not an array
  33864. * @param obj defines the object to evaluate as an array
  33865. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33866. * @returns either obj directly if obj is an array or a new array containing obj
  33867. */
  33868. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33869. /**
  33870. * Gets the pointer prefix to use
  33871. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33872. */
  33873. static GetPointerPrefix(): string;
  33874. /**
  33875. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33876. * @param url define the url we are trying
  33877. * @param element define the dom element where to configure the cors policy
  33878. */
  33879. static SetCorsBehavior(url: string | string[], element: {
  33880. crossOrigin: string | null;
  33881. }): void;
  33882. /**
  33883. * Removes unwanted characters from an url
  33884. * @param url defines the url to clean
  33885. * @returns the cleaned url
  33886. */
  33887. static CleanUrl(url: string): string;
  33888. /**
  33889. * Gets or sets a function used to pre-process url before using them to load assets
  33890. */
  33891. static get PreprocessUrl(): (url: string) => string;
  33892. static set PreprocessUrl(processor: (url: string) => string);
  33893. /**
  33894. * Loads an image as an HTMLImageElement.
  33895. * @param input url string, ArrayBuffer, or Blob to load
  33896. * @param onLoad callback called when the image successfully loads
  33897. * @param onError callback called when the image fails to load
  33898. * @param offlineProvider offline provider for caching
  33899. * @param mimeType optional mime type
  33900. * @returns the HTMLImageElement of the loaded image
  33901. */
  33902. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33903. /**
  33904. * Loads a file from a url
  33905. * @param url url string, ArrayBuffer, or Blob to load
  33906. * @param onSuccess callback called when the file successfully loads
  33907. * @param onProgress callback called while file is loading (if the server supports this mode)
  33908. * @param offlineProvider defines the offline provider for caching
  33909. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33910. * @param onError callback called when the file fails to load
  33911. * @returns a file request object
  33912. */
  33913. 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;
  33914. /**
  33915. * Loads a file from a url
  33916. * @param url the file url to load
  33917. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33918. */
  33919. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33920. /**
  33921. * Load a script (identified by an url). When the url returns, the
  33922. * content of this file is added into a new script element, attached to the DOM (body element)
  33923. * @param scriptUrl defines the url of the script to laod
  33924. * @param onSuccess defines the callback called when the script is loaded
  33925. * @param onError defines the callback to call if an error occurs
  33926. * @param scriptId defines the id of the script element
  33927. */
  33928. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33929. /**
  33930. * Load an asynchronous script (identified by an url). When the url returns, the
  33931. * content of this file is added into a new script element, attached to the DOM (body element)
  33932. * @param scriptUrl defines the url of the script to laod
  33933. * @param scriptId defines the id of the script element
  33934. * @returns a promise request object
  33935. */
  33936. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  33937. /**
  33938. * Loads a file from a blob
  33939. * @param fileToLoad defines the blob to use
  33940. * @param callback defines the callback to call when data is loaded
  33941. * @param progressCallback defines the callback to call during loading process
  33942. * @returns a file request object
  33943. */
  33944. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33945. /**
  33946. * Reads a file from a File object
  33947. * @param file defines the file to load
  33948. * @param onSuccess defines the callback to call when data is loaded
  33949. * @param onProgress defines the callback to call during loading process
  33950. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33951. * @param onError defines the callback to call when an error occurs
  33952. * @returns a file request object
  33953. */
  33954. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33955. /**
  33956. * Creates a data url from a given string content
  33957. * @param content defines the content to convert
  33958. * @returns the new data url link
  33959. */
  33960. static FileAsURL(content: string): string;
  33961. /**
  33962. * Format the given number to a specific decimal format
  33963. * @param value defines the number to format
  33964. * @param decimals defines the number of decimals to use
  33965. * @returns the formatted string
  33966. */
  33967. static Format(value: number, decimals?: number): string;
  33968. /**
  33969. * Tries to copy an object by duplicating every property
  33970. * @param source defines the source object
  33971. * @param destination defines the target object
  33972. * @param doNotCopyList defines a list of properties to avoid
  33973. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33974. */
  33975. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33976. /**
  33977. * Gets a boolean indicating if the given object has no own property
  33978. * @param obj defines the object to test
  33979. * @returns true if object has no own property
  33980. */
  33981. static IsEmpty(obj: any): boolean;
  33982. /**
  33983. * Function used to register events at window level
  33984. * @param windowElement defines the Window object to use
  33985. * @param events defines the events to register
  33986. */
  33987. static RegisterTopRootEvents(windowElement: Window, events: {
  33988. name: string;
  33989. handler: Nullable<(e: FocusEvent) => any>;
  33990. }[]): void;
  33991. /**
  33992. * Function used to unregister events from window level
  33993. * @param windowElement defines the Window object to use
  33994. * @param events defines the events to unregister
  33995. */
  33996. static UnregisterTopRootEvents(windowElement: Window, events: {
  33997. name: string;
  33998. handler: Nullable<(e: FocusEvent) => any>;
  33999. }[]): void;
  34000. /**
  34001. * @ignore
  34002. */
  34003. static _ScreenshotCanvas: HTMLCanvasElement;
  34004. /**
  34005. * Dumps the current bound framebuffer
  34006. * @param width defines the rendering width
  34007. * @param height defines the rendering height
  34008. * @param engine defines the hosting engine
  34009. * @param successCallback defines the callback triggered once the data are available
  34010. * @param mimeType defines the mime type of the result
  34011. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34012. */
  34013. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34014. /**
  34015. * Converts the canvas data to blob.
  34016. * This acts as a polyfill for browsers not supporting the to blob function.
  34017. * @param canvas Defines the canvas to extract the data from
  34018. * @param successCallback Defines the callback triggered once the data are available
  34019. * @param mimeType Defines the mime type of the result
  34020. */
  34021. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34022. /**
  34023. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34024. * @param successCallback defines the callback triggered once the data are available
  34025. * @param mimeType defines the mime type of the result
  34026. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34027. */
  34028. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34029. /**
  34030. * Downloads a blob in the browser
  34031. * @param blob defines the blob to download
  34032. * @param fileName defines the name of the downloaded file
  34033. */
  34034. static Download(blob: Blob, fileName: string): void;
  34035. /**
  34036. * Captures a screenshot of the current rendering
  34037. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34038. * @param engine defines the rendering engine
  34039. * @param camera defines the source camera
  34040. * @param size This parameter can be set to a single number or to an object with the
  34041. * following (optional) properties: precision, width, height. If a single number is passed,
  34042. * it will be used for both width and height. If an object is passed, the screenshot size
  34043. * will be derived from the parameters. The precision property is a multiplier allowing
  34044. * rendering at a higher or lower resolution
  34045. * @param successCallback defines the callback receives a single parameter which contains the
  34046. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34047. * src parameter of an <img> to display it
  34048. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34049. * Check your browser for supported MIME types
  34050. */
  34051. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34052. /**
  34053. * Captures a screenshot of the current rendering
  34054. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34055. * @param engine defines the rendering engine
  34056. * @param camera defines the source camera
  34057. * @param size This parameter can be set to a single number or to an object with the
  34058. * following (optional) properties: precision, width, height. If a single number is passed,
  34059. * it will be used for both width and height. If an object is passed, the screenshot size
  34060. * will be derived from the parameters. The precision property is a multiplier allowing
  34061. * rendering at a higher or lower resolution
  34062. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34063. * Check your browser for supported MIME types
  34064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34065. * to the src parameter of an <img> to display it
  34066. */
  34067. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34068. /**
  34069. * Generates an image screenshot from the specified camera.
  34070. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34071. * @param engine The engine to use for rendering
  34072. * @param camera The camera to use for rendering
  34073. * @param size This parameter can be set to a single number or to an object with the
  34074. * following (optional) properties: precision, width, height. If a single number is passed,
  34075. * it will be used for both width and height. If an object is passed, the screenshot size
  34076. * will be derived from the parameters. The precision property is a multiplier allowing
  34077. * rendering at a higher or lower resolution
  34078. * @param successCallback The callback receives a single parameter which contains the
  34079. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34080. * src parameter of an <img> to display it
  34081. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34082. * Check your browser for supported MIME types
  34083. * @param samples Texture samples (default: 1)
  34084. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34085. * @param fileName A name for for the downloaded file.
  34086. */
  34087. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34088. /**
  34089. * Generates an image screenshot from the specified camera.
  34090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34091. * @param engine The engine to use for rendering
  34092. * @param camera The camera to use for rendering
  34093. * @param size This parameter can be set to a single number or to an object with the
  34094. * following (optional) properties: precision, width, height. If a single number is passed,
  34095. * it will be used for both width and height. If an object is passed, the screenshot size
  34096. * will be derived from the parameters. The precision property is a multiplier allowing
  34097. * rendering at a higher or lower resolution
  34098. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34099. * Check your browser for supported MIME types
  34100. * @param samples Texture samples (default: 1)
  34101. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34102. * @param fileName A name for for the downloaded file.
  34103. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34104. * to the src parameter of an <img> to display it
  34105. */
  34106. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34107. /**
  34108. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34109. * Be aware Math.random() could cause collisions, but:
  34110. * "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"
  34111. * @returns a pseudo random id
  34112. */
  34113. static RandomId(): string;
  34114. /**
  34115. * Test if the given uri is a base64 string
  34116. * @param uri The uri to test
  34117. * @return True if the uri is a base64 string or false otherwise
  34118. */
  34119. static IsBase64(uri: string): boolean;
  34120. /**
  34121. * Decode the given base64 uri.
  34122. * @param uri The uri to decode
  34123. * @return The decoded base64 data.
  34124. */
  34125. static DecodeBase64(uri: string): ArrayBuffer;
  34126. /**
  34127. * Gets the absolute url.
  34128. * @param url the input url
  34129. * @return the absolute url
  34130. */
  34131. static GetAbsoluteUrl(url: string): string;
  34132. /**
  34133. * No log
  34134. */
  34135. static readonly NoneLogLevel: number;
  34136. /**
  34137. * Only message logs
  34138. */
  34139. static readonly MessageLogLevel: number;
  34140. /**
  34141. * Only warning logs
  34142. */
  34143. static readonly WarningLogLevel: number;
  34144. /**
  34145. * Only error logs
  34146. */
  34147. static readonly ErrorLogLevel: number;
  34148. /**
  34149. * All logs
  34150. */
  34151. static readonly AllLogLevel: number;
  34152. /**
  34153. * Gets a value indicating the number of loading errors
  34154. * @ignorenaming
  34155. */
  34156. static get errorsCount(): number;
  34157. /**
  34158. * Callback called when a new log is added
  34159. */
  34160. static OnNewCacheEntry: (entry: string) => void;
  34161. /**
  34162. * Log a message to the console
  34163. * @param message defines the message to log
  34164. */
  34165. static Log(message: string): void;
  34166. /**
  34167. * Write a warning message to the console
  34168. * @param message defines the message to log
  34169. */
  34170. static Warn(message: string): void;
  34171. /**
  34172. * Write an error message to the console
  34173. * @param message defines the message to log
  34174. */
  34175. static Error(message: string): void;
  34176. /**
  34177. * Gets current log cache (list of logs)
  34178. */
  34179. static get LogCache(): string;
  34180. /**
  34181. * Clears the log cache
  34182. */
  34183. static ClearLogCache(): void;
  34184. /**
  34185. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34186. */
  34187. static set LogLevels(level: number);
  34188. /**
  34189. * Checks if the window object exists
  34190. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34191. */
  34192. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34193. /**
  34194. * No performance log
  34195. */
  34196. static readonly PerformanceNoneLogLevel: number;
  34197. /**
  34198. * Use user marks to log performance
  34199. */
  34200. static readonly PerformanceUserMarkLogLevel: number;
  34201. /**
  34202. * Log performance to the console
  34203. */
  34204. static readonly PerformanceConsoleLogLevel: number;
  34205. private static _performance;
  34206. /**
  34207. * Sets the current performance log level
  34208. */
  34209. static set PerformanceLogLevel(level: number);
  34210. private static _StartPerformanceCounterDisabled;
  34211. private static _EndPerformanceCounterDisabled;
  34212. private static _StartUserMark;
  34213. private static _EndUserMark;
  34214. private static _StartPerformanceConsole;
  34215. private static _EndPerformanceConsole;
  34216. /**
  34217. * Starts a performance counter
  34218. */
  34219. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34220. /**
  34221. * Ends a specific performance coutner
  34222. */
  34223. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34224. /**
  34225. * Gets either window.performance.now() if supported or Date.now() else
  34226. */
  34227. static get Now(): number;
  34228. /**
  34229. * This method will return the name of the class used to create the instance of the given object.
  34230. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34231. * @param object the object to get the class name from
  34232. * @param isType defines if the object is actually a type
  34233. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34234. */
  34235. static GetClassName(object: any, isType?: boolean): string;
  34236. /**
  34237. * Gets the first element of an array satisfying a given predicate
  34238. * @param array defines the array to browse
  34239. * @param predicate defines the predicate to use
  34240. * @returns null if not found or the element
  34241. */
  34242. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34243. /**
  34244. * This method will return the name of the full name of the class, including its owning module (if any).
  34245. * 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).
  34246. * @param object the object to get the class name from
  34247. * @param isType defines if the object is actually a type
  34248. * @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.
  34249. * @ignorenaming
  34250. */
  34251. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34252. /**
  34253. * Returns a promise that resolves after the given amount of time.
  34254. * @param delay Number of milliseconds to delay
  34255. * @returns Promise that resolves after the given amount of time
  34256. */
  34257. static DelayAsync(delay: number): Promise<void>;
  34258. }
  34259. /**
  34260. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34261. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34262. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34263. * @param name The name of the class, case should be preserved
  34264. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34265. */
  34266. export function className(name: string, module?: string): (target: Object) => void;
  34267. /**
  34268. * An implementation of a loop for asynchronous functions.
  34269. */
  34270. export class AsyncLoop {
  34271. /**
  34272. * Defines the number of iterations for the loop
  34273. */
  34274. iterations: number;
  34275. /**
  34276. * Defines the current index of the loop.
  34277. */
  34278. index: number;
  34279. private _done;
  34280. private _fn;
  34281. private _successCallback;
  34282. /**
  34283. * Constructor.
  34284. * @param iterations the number of iterations.
  34285. * @param func the function to run each iteration
  34286. * @param successCallback the callback that will be called upon succesful execution
  34287. * @param offset starting offset.
  34288. */
  34289. constructor(
  34290. /**
  34291. * Defines the number of iterations for the loop
  34292. */
  34293. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34294. /**
  34295. * Execute the next iteration. Must be called after the last iteration was finished.
  34296. */
  34297. executeNext(): void;
  34298. /**
  34299. * Break the loop and run the success callback.
  34300. */
  34301. breakLoop(): void;
  34302. /**
  34303. * Create and run an async loop.
  34304. * @param iterations the number of iterations.
  34305. * @param fn the function to run each iteration
  34306. * @param successCallback the callback that will be called upon succesful execution
  34307. * @param offset starting offset.
  34308. * @returns the created async loop object
  34309. */
  34310. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34311. /**
  34312. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34313. * @param iterations total number of iterations
  34314. * @param syncedIterations number of synchronous iterations in each async iteration.
  34315. * @param fn the function to call each iteration.
  34316. * @param callback a success call back that will be called when iterating stops.
  34317. * @param breakFunction a break condition (optional)
  34318. * @param timeout timeout settings for the setTimeout function. default - 0.
  34319. * @returns the created async loop object
  34320. */
  34321. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34322. }
  34323. }
  34324. declare module BABYLON {
  34325. /**
  34326. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34327. * The underlying implementation relies on an associative array to ensure the best performances.
  34328. * The value can be anything including 'null' but except 'undefined'
  34329. */
  34330. export class StringDictionary<T> {
  34331. /**
  34332. * This will clear this dictionary and copy the content from the 'source' one.
  34333. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34334. * @param source the dictionary to take the content from and copy to this dictionary
  34335. */
  34336. copyFrom(source: StringDictionary<T>): void;
  34337. /**
  34338. * Get a value based from its key
  34339. * @param key the given key to get the matching value from
  34340. * @return the value if found, otherwise undefined is returned
  34341. */
  34342. get(key: string): T | undefined;
  34343. /**
  34344. * Get a value from its key or add it if it doesn't exist.
  34345. * This method will ensure you that a given key/data will be present in the dictionary.
  34346. * @param key the given key to get the matching value from
  34347. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34348. * The factory will only be invoked if there's no data for the given key.
  34349. * @return the value corresponding to the key.
  34350. */
  34351. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34352. /**
  34353. * Get a value from its key if present in the dictionary otherwise add it
  34354. * @param key the key to get the value from
  34355. * @param val if there's no such key/value pair in the dictionary add it with this value
  34356. * @return the value corresponding to the key
  34357. */
  34358. getOrAdd(key: string, val: T): T;
  34359. /**
  34360. * Check if there's a given key in the dictionary
  34361. * @param key the key to check for
  34362. * @return true if the key is present, false otherwise
  34363. */
  34364. contains(key: string): boolean;
  34365. /**
  34366. * Add a new key and its corresponding value
  34367. * @param key the key to add
  34368. * @param value the value corresponding to the key
  34369. * @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
  34370. */
  34371. add(key: string, value: T): boolean;
  34372. /**
  34373. * Update a specific value associated to a key
  34374. * @param key defines the key to use
  34375. * @param value defines the value to store
  34376. * @returns true if the value was updated (or false if the key was not found)
  34377. */
  34378. set(key: string, value: T): boolean;
  34379. /**
  34380. * Get the element of the given key and remove it from the dictionary
  34381. * @param key defines the key to search
  34382. * @returns the value associated with the key or null if not found
  34383. */
  34384. getAndRemove(key: string): Nullable<T>;
  34385. /**
  34386. * Remove a key/value from the dictionary.
  34387. * @param key the key to remove
  34388. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34389. */
  34390. remove(key: string): boolean;
  34391. /**
  34392. * Clear the whole content of the dictionary
  34393. */
  34394. clear(): void;
  34395. /**
  34396. * Gets the current count
  34397. */
  34398. get count(): number;
  34399. /**
  34400. * Execute a callback on each key/val of the dictionary.
  34401. * Note that you can remove any element in this dictionary in the callback implementation
  34402. * @param callback the callback to execute on a given key/value pair
  34403. */
  34404. forEach(callback: (key: string, val: T) => void): void;
  34405. /**
  34406. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34407. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34408. * Note that you can remove any element in this dictionary in the callback implementation
  34409. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34410. * @returns the first item
  34411. */
  34412. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34413. private _count;
  34414. private _data;
  34415. }
  34416. }
  34417. declare module BABYLON {
  34418. /** @hidden */
  34419. export interface ICollisionCoordinator {
  34420. createCollider(): Collider;
  34421. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34422. init(scene: Scene): void;
  34423. }
  34424. /** @hidden */
  34425. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34426. private _scene;
  34427. private _scaledPosition;
  34428. private _scaledVelocity;
  34429. private _finalPosition;
  34430. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34431. createCollider(): Collider;
  34432. init(scene: Scene): void;
  34433. private _collideWithWorld;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. /**
  34438. * Class used to manage all inputs for the scene.
  34439. */
  34440. export class InputManager {
  34441. /** The distance in pixel that you have to move to prevent some events */
  34442. static DragMovementThreshold: number;
  34443. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34444. static LongPressDelay: number;
  34445. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34446. static DoubleClickDelay: number;
  34447. /** If you need to check double click without raising a single click at first click, enable this flag */
  34448. static ExclusiveDoubleClickMode: boolean;
  34449. private _wheelEventName;
  34450. private _onPointerMove;
  34451. private _onPointerDown;
  34452. private _onPointerUp;
  34453. private _initClickEvent;
  34454. private _initActionManager;
  34455. private _delayedSimpleClick;
  34456. private _delayedSimpleClickTimeout;
  34457. private _previousDelayedSimpleClickTimeout;
  34458. private _meshPickProceed;
  34459. private _previousButtonPressed;
  34460. private _currentPickResult;
  34461. private _previousPickResult;
  34462. private _totalPointersPressed;
  34463. private _doubleClickOccured;
  34464. private _pointerOverMesh;
  34465. private _pickedDownMesh;
  34466. private _pickedUpMesh;
  34467. private _pointerX;
  34468. private _pointerY;
  34469. private _unTranslatedPointerX;
  34470. private _unTranslatedPointerY;
  34471. private _startingPointerPosition;
  34472. private _previousStartingPointerPosition;
  34473. private _startingPointerTime;
  34474. private _previousStartingPointerTime;
  34475. private _pointerCaptures;
  34476. private _onKeyDown;
  34477. private _onKeyUp;
  34478. private _onCanvasFocusObserver;
  34479. private _onCanvasBlurObserver;
  34480. private _scene;
  34481. /**
  34482. * Creates a new InputManager
  34483. * @param scene defines the hosting scene
  34484. */
  34485. constructor(scene: Scene);
  34486. /**
  34487. * Gets the mesh that is currently under the pointer
  34488. */
  34489. get meshUnderPointer(): Nullable<AbstractMesh>;
  34490. /**
  34491. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34492. */
  34493. get unTranslatedPointer(): Vector2;
  34494. /**
  34495. * Gets or sets the current on-screen X position of the pointer
  34496. */
  34497. get pointerX(): number;
  34498. set pointerX(value: number);
  34499. /**
  34500. * Gets or sets the current on-screen Y position of the pointer
  34501. */
  34502. get pointerY(): number;
  34503. set pointerY(value: number);
  34504. private _updatePointerPosition;
  34505. private _processPointerMove;
  34506. private _setRayOnPointerInfo;
  34507. private _checkPrePointerObservable;
  34508. /**
  34509. * Use this method to simulate a pointer move on a mesh
  34510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34513. */
  34514. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34515. /**
  34516. * Use this method to simulate a pointer down on a mesh
  34517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34520. */
  34521. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34522. private _processPointerDown;
  34523. /** @hidden */
  34524. _isPointerSwiping(): boolean;
  34525. /**
  34526. * Use this method to simulate a pointer up on a mesh
  34527. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34528. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34529. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34530. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34531. */
  34532. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34533. private _processPointerUp;
  34534. /**
  34535. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34536. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34537. * @returns true if the pointer was captured
  34538. */
  34539. isPointerCaptured(pointerId?: number): boolean;
  34540. /**
  34541. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34542. * @param attachUp defines if you want to attach events to pointerup
  34543. * @param attachDown defines if you want to attach events to pointerdown
  34544. * @param attachMove defines if you want to attach events to pointermove
  34545. */
  34546. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34547. /**
  34548. * Detaches all event handlers
  34549. */
  34550. detachControl(): void;
  34551. /**
  34552. * Force the value of meshUnderPointer
  34553. * @param mesh defines the mesh to use
  34554. */
  34555. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34556. /**
  34557. * Gets the mesh under the pointer
  34558. * @returns a Mesh or null if no mesh is under the pointer
  34559. */
  34560. getPointerOverMesh(): Nullable<AbstractMesh>;
  34561. }
  34562. }
  34563. declare module BABYLON {
  34564. /**
  34565. * Helper class used to generate session unique ID
  34566. */
  34567. export class UniqueIdGenerator {
  34568. private static _UniqueIdCounter;
  34569. /**
  34570. * Gets an unique (relatively to the current scene) Id
  34571. */
  34572. static get UniqueId(): number;
  34573. }
  34574. }
  34575. declare module BABYLON {
  34576. /**
  34577. * This class defines the direct association between an animation and a target
  34578. */
  34579. export class TargetedAnimation {
  34580. /**
  34581. * Animation to perform
  34582. */
  34583. animation: Animation;
  34584. /**
  34585. * Target to animate
  34586. */
  34587. target: any;
  34588. /**
  34589. * Serialize the object
  34590. * @returns the JSON object representing the current entity
  34591. */
  34592. serialize(): any;
  34593. }
  34594. /**
  34595. * Use this class to create coordinated animations on multiple targets
  34596. */
  34597. export class AnimationGroup implements IDisposable {
  34598. /** The name of the animation group */
  34599. name: string;
  34600. private _scene;
  34601. private _targetedAnimations;
  34602. private _animatables;
  34603. private _from;
  34604. private _to;
  34605. private _isStarted;
  34606. private _isPaused;
  34607. private _speedRatio;
  34608. private _loopAnimation;
  34609. /**
  34610. * Gets or sets the unique id of the node
  34611. */
  34612. uniqueId: number;
  34613. /**
  34614. * This observable will notify when one animation have ended
  34615. */
  34616. onAnimationEndObservable: Observable<TargetedAnimation>;
  34617. /**
  34618. * Observer raised when one animation loops
  34619. */
  34620. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34621. /**
  34622. * Observer raised when all animations have looped
  34623. */
  34624. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34625. /**
  34626. * This observable will notify when all animations have ended.
  34627. */
  34628. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34629. /**
  34630. * This observable will notify when all animations have paused.
  34631. */
  34632. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34633. /**
  34634. * This observable will notify when all animations are playing.
  34635. */
  34636. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34637. /**
  34638. * Gets the first frame
  34639. */
  34640. get from(): number;
  34641. /**
  34642. * Gets the last frame
  34643. */
  34644. get to(): number;
  34645. /**
  34646. * Define if the animations are started
  34647. */
  34648. get isStarted(): boolean;
  34649. /**
  34650. * Gets a value indicating that the current group is playing
  34651. */
  34652. get isPlaying(): boolean;
  34653. /**
  34654. * Gets or sets the speed ratio to use for all animations
  34655. */
  34656. get speedRatio(): number;
  34657. /**
  34658. * Gets or sets the speed ratio to use for all animations
  34659. */
  34660. set speedRatio(value: number);
  34661. /**
  34662. * Gets or sets if all animations should loop or not
  34663. */
  34664. get loopAnimation(): boolean;
  34665. set loopAnimation(value: boolean);
  34666. /**
  34667. * Gets the targeted animations for this animation group
  34668. */
  34669. get targetedAnimations(): Array<TargetedAnimation>;
  34670. /**
  34671. * returning the list of animatables controlled by this animation group.
  34672. */
  34673. get animatables(): Array<Animatable>;
  34674. /**
  34675. * Instantiates a new Animation Group.
  34676. * This helps managing several animations at once.
  34677. * @see http://doc.babylonjs.com/how_to/group
  34678. * @param name Defines the name of the group
  34679. * @param scene Defines the scene the group belongs to
  34680. */
  34681. constructor(
  34682. /** The name of the animation group */
  34683. name: string, scene?: Nullable<Scene>);
  34684. /**
  34685. * Add an animation (with its target) in the group
  34686. * @param animation defines the animation we want to add
  34687. * @param target defines the target of the animation
  34688. * @returns the TargetedAnimation object
  34689. */
  34690. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34691. /**
  34692. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34693. * It can add constant keys at begin or end
  34694. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34695. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34696. * @returns the animation group
  34697. */
  34698. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34699. private _animationLoopCount;
  34700. private _animationLoopFlags;
  34701. private _processLoop;
  34702. /**
  34703. * Start all animations on given targets
  34704. * @param loop defines if animations must loop
  34705. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34706. * @param from defines the from key (optional)
  34707. * @param to defines the to key (optional)
  34708. * @returns the current animation group
  34709. */
  34710. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34711. /**
  34712. * Pause all animations
  34713. * @returns the animation group
  34714. */
  34715. pause(): AnimationGroup;
  34716. /**
  34717. * Play all animations to initial state
  34718. * This function will start() the animations if they were not started or will restart() them if they were paused
  34719. * @param loop defines if animations must loop
  34720. * @returns the animation group
  34721. */
  34722. play(loop?: boolean): AnimationGroup;
  34723. /**
  34724. * Reset all animations to initial state
  34725. * @returns the animation group
  34726. */
  34727. reset(): AnimationGroup;
  34728. /**
  34729. * Restart animations from key 0
  34730. * @returns the animation group
  34731. */
  34732. restart(): AnimationGroup;
  34733. /**
  34734. * Stop all animations
  34735. * @returns the animation group
  34736. */
  34737. stop(): AnimationGroup;
  34738. /**
  34739. * Set animation weight for all animatables
  34740. * @param weight defines the weight to use
  34741. * @return the animationGroup
  34742. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34743. */
  34744. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34745. /**
  34746. * Synchronize and normalize all animatables with a source animatable
  34747. * @param root defines the root animatable to synchronize with
  34748. * @return the animationGroup
  34749. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34750. */
  34751. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34752. /**
  34753. * Goes to a specific frame in this animation group
  34754. * @param frame the frame number to go to
  34755. * @return the animationGroup
  34756. */
  34757. goToFrame(frame: number): AnimationGroup;
  34758. /**
  34759. * Dispose all associated resources
  34760. */
  34761. dispose(): void;
  34762. private _checkAnimationGroupEnded;
  34763. /**
  34764. * Clone the current animation group and returns a copy
  34765. * @param newName defines the name of the new group
  34766. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34767. * @returns the new aniamtion group
  34768. */
  34769. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34770. /**
  34771. * Serializes the animationGroup to an object
  34772. * @returns Serialized object
  34773. */
  34774. serialize(): any;
  34775. /**
  34776. * Returns a new AnimationGroup object parsed from the source provided.
  34777. * @param parsedAnimationGroup defines the source
  34778. * @param scene defines the scene that will receive the animationGroup
  34779. * @returns a new AnimationGroup
  34780. */
  34781. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34782. /**
  34783. * Returns the string "AnimationGroup"
  34784. * @returns "AnimationGroup"
  34785. */
  34786. getClassName(): string;
  34787. /**
  34788. * Creates a detailled string about the object
  34789. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34790. * @returns a string representing the object
  34791. */
  34792. toString(fullDetails?: boolean): string;
  34793. }
  34794. }
  34795. declare module BABYLON {
  34796. /**
  34797. * Define an interface for all classes that will hold resources
  34798. */
  34799. export interface IDisposable {
  34800. /**
  34801. * Releases all held resources
  34802. */
  34803. dispose(): void;
  34804. }
  34805. /** Interface defining initialization parameters for Scene class */
  34806. export interface SceneOptions {
  34807. /**
  34808. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34809. * It will improve performance when the number of geometries becomes important.
  34810. */
  34811. useGeometryUniqueIdsMap?: boolean;
  34812. /**
  34813. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34814. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34815. */
  34816. useMaterialMeshMap?: boolean;
  34817. /**
  34818. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34819. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34820. */
  34821. useClonedMeshMap?: boolean;
  34822. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34823. virtual?: boolean;
  34824. }
  34825. /**
  34826. * Represents a scene to be rendered by the engine.
  34827. * @see http://doc.babylonjs.com/features/scene
  34828. */
  34829. export class Scene extends AbstractScene implements IAnimatable {
  34830. /** The fog is deactivated */
  34831. static readonly FOGMODE_NONE: number;
  34832. /** The fog density is following an exponential function */
  34833. static readonly FOGMODE_EXP: number;
  34834. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34835. static readonly FOGMODE_EXP2: number;
  34836. /** The fog density is following a linear function. */
  34837. static readonly FOGMODE_LINEAR: number;
  34838. /**
  34839. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34841. */
  34842. static MinDeltaTime: number;
  34843. /**
  34844. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34846. */
  34847. static MaxDeltaTime: number;
  34848. /**
  34849. * Factory used to create the default material.
  34850. * @param name The name of the material to create
  34851. * @param scene The scene to create the material for
  34852. * @returns The default material
  34853. */
  34854. static DefaultMaterialFactory(scene: Scene): Material;
  34855. /**
  34856. * Factory used to create the a collision coordinator.
  34857. * @returns The collision coordinator
  34858. */
  34859. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34860. /** @hidden */
  34861. _inputManager: InputManager;
  34862. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34863. cameraToUseForPointers: Nullable<Camera>;
  34864. /** @hidden */
  34865. readonly _isScene: boolean;
  34866. /**
  34867. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34868. */
  34869. autoClear: boolean;
  34870. /**
  34871. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34872. */
  34873. autoClearDepthAndStencil: boolean;
  34874. /**
  34875. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34876. */
  34877. clearColor: Color4;
  34878. /**
  34879. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34880. */
  34881. ambientColor: Color3;
  34882. /**
  34883. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34884. * It should only be one of the following (if not the default embedded one):
  34885. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34886. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34887. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34888. * The material properties need to be setup according to the type of texture in use.
  34889. */
  34890. environmentBRDFTexture: BaseTexture;
  34891. /** @hidden */
  34892. protected _environmentTexture: Nullable<BaseTexture>;
  34893. /**
  34894. * Texture used in all pbr material as the reflection texture.
  34895. * As in the majority of the scene they are the same (exception for multi room and so on),
  34896. * this is easier to reference from here than from all the materials.
  34897. */
  34898. get environmentTexture(): Nullable<BaseTexture>;
  34899. /**
  34900. * Texture used in all pbr material as the reflection texture.
  34901. * As in the majority of the scene they are the same (exception for multi room and so on),
  34902. * this is easier to set here than in all the materials.
  34903. */
  34904. set environmentTexture(value: Nullable<BaseTexture>);
  34905. /** @hidden */
  34906. protected _environmentIntensity: number;
  34907. /**
  34908. * Intensity of the environment in all pbr material.
  34909. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34910. * As in the majority of the scene they are the same (exception for multi room and so on),
  34911. * this is easier to reference from here than from all the materials.
  34912. */
  34913. get environmentIntensity(): number;
  34914. /**
  34915. * Intensity of the environment in all pbr material.
  34916. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34917. * As in the majority of the scene they are the same (exception for multi room and so on),
  34918. * this is easier to set here than in all the materials.
  34919. */
  34920. set environmentIntensity(value: number);
  34921. /** @hidden */
  34922. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34923. /**
  34924. * Default image processing configuration used either in the rendering
  34925. * Forward main pass or through the imageProcessingPostProcess if present.
  34926. * As in the majority of the scene they are the same (exception for multi camera),
  34927. * this is easier to reference from here than from all the materials and post process.
  34928. *
  34929. * No setter as we it is a shared configuration, you can set the values instead.
  34930. */
  34931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34932. private _forceWireframe;
  34933. /**
  34934. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34935. */
  34936. set forceWireframe(value: boolean);
  34937. get forceWireframe(): boolean;
  34938. private _skipFrustumClipping;
  34939. /**
  34940. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  34941. */
  34942. set skipFrustumClipping(value: boolean);
  34943. get skipFrustumClipping(): boolean;
  34944. private _forcePointsCloud;
  34945. /**
  34946. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34947. */
  34948. set forcePointsCloud(value: boolean);
  34949. get forcePointsCloud(): boolean;
  34950. /**
  34951. * Gets or sets the active clipplane 1
  34952. */
  34953. clipPlane: Nullable<Plane>;
  34954. /**
  34955. * Gets or sets the active clipplane 2
  34956. */
  34957. clipPlane2: Nullable<Plane>;
  34958. /**
  34959. * Gets or sets the active clipplane 3
  34960. */
  34961. clipPlane3: Nullable<Plane>;
  34962. /**
  34963. * Gets or sets the active clipplane 4
  34964. */
  34965. clipPlane4: Nullable<Plane>;
  34966. /**
  34967. * Gets or sets the active clipplane 5
  34968. */
  34969. clipPlane5: Nullable<Plane>;
  34970. /**
  34971. * Gets or sets the active clipplane 6
  34972. */
  34973. clipPlane6: Nullable<Plane>;
  34974. /**
  34975. * Gets or sets a boolean indicating if animations are enabled
  34976. */
  34977. animationsEnabled: boolean;
  34978. private _animationPropertiesOverride;
  34979. /**
  34980. * Gets or sets the animation properties override
  34981. */
  34982. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34983. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34984. /**
  34985. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34986. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34987. */
  34988. useConstantAnimationDeltaTime: boolean;
  34989. /**
  34990. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34991. * Please note that it requires to run a ray cast through the scene on every frame
  34992. */
  34993. constantlyUpdateMeshUnderPointer: boolean;
  34994. /**
  34995. * Defines the HTML cursor to use when hovering over interactive elements
  34996. */
  34997. hoverCursor: string;
  34998. /**
  34999. * Defines the HTML default cursor to use (empty by default)
  35000. */
  35001. defaultCursor: string;
  35002. /**
  35003. * Defines wether cursors are handled by the scene.
  35004. */
  35005. doNotHandleCursors: boolean;
  35006. /**
  35007. * This is used to call preventDefault() on pointer down
  35008. * in order to block unwanted artifacts like system double clicks
  35009. */
  35010. preventDefaultOnPointerDown: boolean;
  35011. /**
  35012. * This is used to call preventDefault() on pointer up
  35013. * in order to block unwanted artifacts like system double clicks
  35014. */
  35015. preventDefaultOnPointerUp: boolean;
  35016. /**
  35017. * Gets or sets user defined metadata
  35018. */
  35019. metadata: any;
  35020. /**
  35021. * For internal use only. Please do not use.
  35022. */
  35023. reservedDataStore: any;
  35024. /**
  35025. * Gets the name of the plugin used to load this scene (null by default)
  35026. */
  35027. loadingPluginName: string;
  35028. /**
  35029. * Use this array to add regular expressions used to disable offline support for specific urls
  35030. */
  35031. disableOfflineSupportExceptionRules: RegExp[];
  35032. /**
  35033. * An event triggered when the scene is disposed.
  35034. */
  35035. onDisposeObservable: Observable<Scene>;
  35036. private _onDisposeObserver;
  35037. /** Sets a function to be executed when this scene is disposed. */
  35038. set onDispose(callback: () => void);
  35039. /**
  35040. * An event triggered before rendering the scene (right after animations and physics)
  35041. */
  35042. onBeforeRenderObservable: Observable<Scene>;
  35043. private _onBeforeRenderObserver;
  35044. /** Sets a function to be executed before rendering this scene */
  35045. set beforeRender(callback: Nullable<() => void>);
  35046. /**
  35047. * An event triggered after rendering the scene
  35048. */
  35049. onAfterRenderObservable: Observable<Scene>;
  35050. /**
  35051. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35052. */
  35053. onAfterRenderCameraObservable: Observable<Camera>;
  35054. private _onAfterRenderObserver;
  35055. /** Sets a function to be executed after rendering this scene */
  35056. set afterRender(callback: Nullable<() => void>);
  35057. /**
  35058. * An event triggered before animating the scene
  35059. */
  35060. onBeforeAnimationsObservable: Observable<Scene>;
  35061. /**
  35062. * An event triggered after animations processing
  35063. */
  35064. onAfterAnimationsObservable: Observable<Scene>;
  35065. /**
  35066. * An event triggered before draw calls are ready to be sent
  35067. */
  35068. onBeforeDrawPhaseObservable: Observable<Scene>;
  35069. /**
  35070. * An event triggered after draw calls have been sent
  35071. */
  35072. onAfterDrawPhaseObservable: Observable<Scene>;
  35073. /**
  35074. * An event triggered when the scene is ready
  35075. */
  35076. onReadyObservable: Observable<Scene>;
  35077. /**
  35078. * An event triggered before rendering a camera
  35079. */
  35080. onBeforeCameraRenderObservable: Observable<Camera>;
  35081. private _onBeforeCameraRenderObserver;
  35082. /** Sets a function to be executed before rendering a camera*/
  35083. set beforeCameraRender(callback: () => void);
  35084. /**
  35085. * An event triggered after rendering a camera
  35086. */
  35087. onAfterCameraRenderObservable: Observable<Camera>;
  35088. private _onAfterCameraRenderObserver;
  35089. /** Sets a function to be executed after rendering a camera*/
  35090. set afterCameraRender(callback: () => void);
  35091. /**
  35092. * An event triggered when active meshes evaluation is about to start
  35093. */
  35094. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35095. /**
  35096. * An event triggered when active meshes evaluation is done
  35097. */
  35098. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35099. /**
  35100. * An event triggered when particles rendering is about to start
  35101. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35102. */
  35103. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35104. /**
  35105. * An event triggered when particles rendering is done
  35106. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35107. */
  35108. onAfterParticlesRenderingObservable: Observable<Scene>;
  35109. /**
  35110. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35111. */
  35112. onDataLoadedObservable: Observable<Scene>;
  35113. /**
  35114. * An event triggered when a camera is created
  35115. */
  35116. onNewCameraAddedObservable: Observable<Camera>;
  35117. /**
  35118. * An event triggered when a camera is removed
  35119. */
  35120. onCameraRemovedObservable: Observable<Camera>;
  35121. /**
  35122. * An event triggered when a light is created
  35123. */
  35124. onNewLightAddedObservable: Observable<Light>;
  35125. /**
  35126. * An event triggered when a light is removed
  35127. */
  35128. onLightRemovedObservable: Observable<Light>;
  35129. /**
  35130. * An event triggered when a geometry is created
  35131. */
  35132. onNewGeometryAddedObservable: Observable<Geometry>;
  35133. /**
  35134. * An event triggered when a geometry is removed
  35135. */
  35136. onGeometryRemovedObservable: Observable<Geometry>;
  35137. /**
  35138. * An event triggered when a transform node is created
  35139. */
  35140. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35141. /**
  35142. * An event triggered when a transform node is removed
  35143. */
  35144. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35145. /**
  35146. * An event triggered when a mesh is created
  35147. */
  35148. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35149. /**
  35150. * An event triggered when a mesh is removed
  35151. */
  35152. onMeshRemovedObservable: Observable<AbstractMesh>;
  35153. /**
  35154. * An event triggered when a skeleton is created
  35155. */
  35156. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35157. /**
  35158. * An event triggered when a skeleton is removed
  35159. */
  35160. onSkeletonRemovedObservable: Observable<Skeleton>;
  35161. /**
  35162. * An event triggered when a material is created
  35163. */
  35164. onNewMaterialAddedObservable: Observable<Material>;
  35165. /**
  35166. * An event triggered when a material is removed
  35167. */
  35168. onMaterialRemovedObservable: Observable<Material>;
  35169. /**
  35170. * An event triggered when a texture is created
  35171. */
  35172. onNewTextureAddedObservable: Observable<BaseTexture>;
  35173. /**
  35174. * An event triggered when a texture is removed
  35175. */
  35176. onTextureRemovedObservable: Observable<BaseTexture>;
  35177. /**
  35178. * An event triggered when render targets are about to be rendered
  35179. * Can happen multiple times per frame.
  35180. */
  35181. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35182. /**
  35183. * An event triggered when render targets were rendered.
  35184. * Can happen multiple times per frame.
  35185. */
  35186. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35187. /**
  35188. * An event triggered before calculating deterministic simulation step
  35189. */
  35190. onBeforeStepObservable: Observable<Scene>;
  35191. /**
  35192. * An event triggered after calculating deterministic simulation step
  35193. */
  35194. onAfterStepObservable: Observable<Scene>;
  35195. /**
  35196. * An event triggered when the activeCamera property is updated
  35197. */
  35198. onActiveCameraChanged: Observable<Scene>;
  35199. /**
  35200. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35201. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35202. * 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)
  35203. */
  35204. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35205. /**
  35206. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35207. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35208. * 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)
  35209. */
  35210. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35211. /**
  35212. * This Observable will when a mesh has been imported into the scene.
  35213. */
  35214. onMeshImportedObservable: Observable<AbstractMesh>;
  35215. /**
  35216. * This Observable will when an animation file has been imported into the scene.
  35217. */
  35218. onAnimationFileImportedObservable: Observable<Scene>;
  35219. /**
  35220. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35221. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35222. */
  35223. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35224. /** @hidden */
  35225. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35226. /**
  35227. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35228. */
  35229. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35230. /**
  35231. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35232. */
  35233. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35234. /**
  35235. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35236. */
  35237. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35238. /** Callback called when a pointer move is detected */
  35239. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35240. /** Callback called when a pointer down is detected */
  35241. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35242. /** Callback called when a pointer up is detected */
  35243. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35244. /** Callback called when a pointer pick is detected */
  35245. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35246. /**
  35247. * 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).
  35248. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35249. */
  35250. onPrePointerObservable: Observable<PointerInfoPre>;
  35251. /**
  35252. * Observable event triggered each time an input event is received from the rendering canvas
  35253. */
  35254. onPointerObservable: Observable<PointerInfo>;
  35255. /**
  35256. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35257. */
  35258. get unTranslatedPointer(): Vector2;
  35259. /**
  35260. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35261. */
  35262. static get DragMovementThreshold(): number;
  35263. static set DragMovementThreshold(value: number);
  35264. /**
  35265. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35266. */
  35267. static get LongPressDelay(): number;
  35268. static set LongPressDelay(value: number);
  35269. /**
  35270. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35271. */
  35272. static get DoubleClickDelay(): number;
  35273. static set DoubleClickDelay(value: number);
  35274. /** If you need to check double click without raising a single click at first click, enable this flag */
  35275. static get ExclusiveDoubleClickMode(): boolean;
  35276. static set ExclusiveDoubleClickMode(value: boolean);
  35277. /** @hidden */
  35278. _mirroredCameraPosition: Nullable<Vector3>;
  35279. /**
  35280. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35281. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35282. */
  35283. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35284. /**
  35285. * Observable event triggered each time an keyboard event is received from the hosting window
  35286. */
  35287. onKeyboardObservable: Observable<KeyboardInfo>;
  35288. private _useRightHandedSystem;
  35289. /**
  35290. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35291. */
  35292. set useRightHandedSystem(value: boolean);
  35293. get useRightHandedSystem(): boolean;
  35294. private _timeAccumulator;
  35295. private _currentStepId;
  35296. private _currentInternalStep;
  35297. /**
  35298. * Sets the step Id used by deterministic lock step
  35299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35300. * @param newStepId defines the step Id
  35301. */
  35302. setStepId(newStepId: number): void;
  35303. /**
  35304. * Gets the step Id used by deterministic lock step
  35305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35306. * @returns the step Id
  35307. */
  35308. getStepId(): number;
  35309. /**
  35310. * Gets the internal step used by deterministic lock step
  35311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35312. * @returns the internal step
  35313. */
  35314. getInternalStep(): number;
  35315. private _fogEnabled;
  35316. /**
  35317. * Gets or sets a boolean indicating if fog is enabled on this scene
  35318. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35319. * (Default is true)
  35320. */
  35321. set fogEnabled(value: boolean);
  35322. get fogEnabled(): boolean;
  35323. private _fogMode;
  35324. /**
  35325. * Gets or sets the fog mode to use
  35326. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35327. * | mode | value |
  35328. * | --- | --- |
  35329. * | FOGMODE_NONE | 0 |
  35330. * | FOGMODE_EXP | 1 |
  35331. * | FOGMODE_EXP2 | 2 |
  35332. * | FOGMODE_LINEAR | 3 |
  35333. */
  35334. set fogMode(value: number);
  35335. get fogMode(): number;
  35336. /**
  35337. * Gets or sets the fog color to use
  35338. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35339. * (Default is Color3(0.2, 0.2, 0.3))
  35340. */
  35341. fogColor: Color3;
  35342. /**
  35343. * Gets or sets the fog density to use
  35344. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35345. * (Default is 0.1)
  35346. */
  35347. fogDensity: number;
  35348. /**
  35349. * Gets or sets the fog start distance to use
  35350. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35351. * (Default is 0)
  35352. */
  35353. fogStart: number;
  35354. /**
  35355. * Gets or sets the fog end distance to use
  35356. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35357. * (Default is 1000)
  35358. */
  35359. fogEnd: number;
  35360. private _shadowsEnabled;
  35361. /**
  35362. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35363. */
  35364. set shadowsEnabled(value: boolean);
  35365. get shadowsEnabled(): boolean;
  35366. private _lightsEnabled;
  35367. /**
  35368. * Gets or sets a boolean indicating if lights are enabled on this scene
  35369. */
  35370. set lightsEnabled(value: boolean);
  35371. get lightsEnabled(): boolean;
  35372. /** All of the active cameras added to this scene. */
  35373. activeCameras: Camera[];
  35374. /** @hidden */
  35375. _activeCamera: Nullable<Camera>;
  35376. /** Gets or sets the current active camera */
  35377. get activeCamera(): Nullable<Camera>;
  35378. set activeCamera(value: Nullable<Camera>);
  35379. private _defaultMaterial;
  35380. /** The default material used on meshes when no material is affected */
  35381. get defaultMaterial(): Material;
  35382. /** The default material used on meshes when no material is affected */
  35383. set defaultMaterial(value: Material);
  35384. private _texturesEnabled;
  35385. /**
  35386. * Gets or sets a boolean indicating if textures are enabled on this scene
  35387. */
  35388. set texturesEnabled(value: boolean);
  35389. get texturesEnabled(): boolean;
  35390. /**
  35391. * Gets or sets a boolean indicating if particles are enabled on this scene
  35392. */
  35393. particlesEnabled: boolean;
  35394. /**
  35395. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35396. */
  35397. spritesEnabled: boolean;
  35398. private _skeletonsEnabled;
  35399. /**
  35400. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35401. */
  35402. set skeletonsEnabled(value: boolean);
  35403. get skeletonsEnabled(): boolean;
  35404. /**
  35405. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35406. */
  35407. lensFlaresEnabled: boolean;
  35408. /**
  35409. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35411. */
  35412. collisionsEnabled: boolean;
  35413. private _collisionCoordinator;
  35414. /** @hidden */
  35415. get collisionCoordinator(): ICollisionCoordinator;
  35416. /**
  35417. * Defines the gravity applied to this scene (used only for collisions)
  35418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35419. */
  35420. gravity: Vector3;
  35421. /**
  35422. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35423. */
  35424. postProcessesEnabled: boolean;
  35425. /**
  35426. * The list of postprocesses added to the scene
  35427. */
  35428. postProcesses: PostProcess[];
  35429. /**
  35430. * Gets the current postprocess manager
  35431. */
  35432. postProcessManager: PostProcessManager;
  35433. /**
  35434. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35435. */
  35436. renderTargetsEnabled: boolean;
  35437. /**
  35438. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35439. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35440. */
  35441. dumpNextRenderTargets: boolean;
  35442. /**
  35443. * The list of user defined render targets added to the scene
  35444. */
  35445. customRenderTargets: RenderTargetTexture[];
  35446. /**
  35447. * Defines if texture loading must be delayed
  35448. * If true, textures will only be loaded when they need to be rendered
  35449. */
  35450. useDelayedTextureLoading: boolean;
  35451. /**
  35452. * Gets the list of meshes imported to the scene through SceneLoader
  35453. */
  35454. importedMeshesFiles: String[];
  35455. /**
  35456. * Gets or sets a boolean indicating if probes are enabled on this scene
  35457. */
  35458. probesEnabled: boolean;
  35459. /**
  35460. * Gets or sets the current offline provider to use to store scene data
  35461. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35462. */
  35463. offlineProvider: IOfflineProvider;
  35464. /**
  35465. * Gets or sets the action manager associated with the scene
  35466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35467. */
  35468. actionManager: AbstractActionManager;
  35469. private _meshesForIntersections;
  35470. /**
  35471. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35472. */
  35473. proceduralTexturesEnabled: boolean;
  35474. private _engine;
  35475. private _totalVertices;
  35476. /** @hidden */
  35477. _activeIndices: PerfCounter;
  35478. /** @hidden */
  35479. _activeParticles: PerfCounter;
  35480. /** @hidden */
  35481. _activeBones: PerfCounter;
  35482. private _animationRatio;
  35483. /** @hidden */
  35484. _animationTimeLast: number;
  35485. /** @hidden */
  35486. _animationTime: number;
  35487. /**
  35488. * Gets or sets a general scale for animation speed
  35489. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35490. */
  35491. animationTimeScale: number;
  35492. /** @hidden */
  35493. _cachedMaterial: Nullable<Material>;
  35494. /** @hidden */
  35495. _cachedEffect: Nullable<Effect>;
  35496. /** @hidden */
  35497. _cachedVisibility: Nullable<number>;
  35498. private _renderId;
  35499. private _frameId;
  35500. private _executeWhenReadyTimeoutId;
  35501. private _intermediateRendering;
  35502. private _viewUpdateFlag;
  35503. private _projectionUpdateFlag;
  35504. /** @hidden */
  35505. _toBeDisposed: Nullable<IDisposable>[];
  35506. private _activeRequests;
  35507. /** @hidden */
  35508. _pendingData: any[];
  35509. private _isDisposed;
  35510. /**
  35511. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35512. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35513. */
  35514. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35515. private _activeMeshes;
  35516. private _processedMaterials;
  35517. private _renderTargets;
  35518. /** @hidden */
  35519. _activeParticleSystems: SmartArray<IParticleSystem>;
  35520. private _activeSkeletons;
  35521. private _softwareSkinnedMeshes;
  35522. private _renderingManager;
  35523. /** @hidden */
  35524. _activeAnimatables: Animatable[];
  35525. private _transformMatrix;
  35526. private _sceneUbo;
  35527. /** @hidden */
  35528. _viewMatrix: Matrix;
  35529. private _projectionMatrix;
  35530. /** @hidden */
  35531. _forcedViewPosition: Nullable<Vector3>;
  35532. /** @hidden */
  35533. _frustumPlanes: Plane[];
  35534. /**
  35535. * Gets the list of frustum planes (built from the active camera)
  35536. */
  35537. get frustumPlanes(): Plane[];
  35538. /**
  35539. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35540. * This is useful if there are more lights that the maximum simulteanous authorized
  35541. */
  35542. requireLightSorting: boolean;
  35543. /** @hidden */
  35544. readonly useMaterialMeshMap: boolean;
  35545. /** @hidden */
  35546. readonly useClonedMeshMap: boolean;
  35547. private _externalData;
  35548. private _uid;
  35549. /**
  35550. * @hidden
  35551. * Backing store of defined scene components.
  35552. */
  35553. _components: ISceneComponent[];
  35554. /**
  35555. * @hidden
  35556. * Backing store of defined scene components.
  35557. */
  35558. _serializableComponents: ISceneSerializableComponent[];
  35559. /**
  35560. * List of components to register on the next registration step.
  35561. */
  35562. private _transientComponents;
  35563. /**
  35564. * Registers the transient components if needed.
  35565. */
  35566. private _registerTransientComponents;
  35567. /**
  35568. * @hidden
  35569. * Add a component to the scene.
  35570. * Note that the ccomponent could be registered on th next frame if this is called after
  35571. * the register component stage.
  35572. * @param component Defines the component to add to the scene
  35573. */
  35574. _addComponent(component: ISceneComponent): void;
  35575. /**
  35576. * @hidden
  35577. * Gets a component from the scene.
  35578. * @param name defines the name of the component to retrieve
  35579. * @returns the component or null if not present
  35580. */
  35581. _getComponent(name: string): Nullable<ISceneComponent>;
  35582. /**
  35583. * @hidden
  35584. * Defines the actions happening before camera updates.
  35585. */
  35586. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35587. /**
  35588. * @hidden
  35589. * Defines the actions happening before clear the canvas.
  35590. */
  35591. _beforeClearStage: Stage<SimpleStageAction>;
  35592. /**
  35593. * @hidden
  35594. * Defines the actions when collecting render targets for the frame.
  35595. */
  35596. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35597. /**
  35598. * @hidden
  35599. * Defines the actions happening for one camera in the frame.
  35600. */
  35601. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35602. /**
  35603. * @hidden
  35604. * Defines the actions happening during the per mesh ready checks.
  35605. */
  35606. _isReadyForMeshStage: Stage<MeshStageAction>;
  35607. /**
  35608. * @hidden
  35609. * Defines the actions happening before evaluate active mesh checks.
  35610. */
  35611. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35612. /**
  35613. * @hidden
  35614. * Defines the actions happening during the evaluate sub mesh checks.
  35615. */
  35616. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35617. /**
  35618. * @hidden
  35619. * Defines the actions happening during the active mesh stage.
  35620. */
  35621. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35622. /**
  35623. * @hidden
  35624. * Defines the actions happening during the per camera render target step.
  35625. */
  35626. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35627. /**
  35628. * @hidden
  35629. * Defines the actions happening just before the active camera is drawing.
  35630. */
  35631. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35632. /**
  35633. * @hidden
  35634. * Defines the actions happening just before a render target is drawing.
  35635. */
  35636. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35637. /**
  35638. * @hidden
  35639. * Defines the actions happening just before a rendering group is drawing.
  35640. */
  35641. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35642. /**
  35643. * @hidden
  35644. * Defines the actions happening just before a mesh is drawing.
  35645. */
  35646. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35647. /**
  35648. * @hidden
  35649. * Defines the actions happening just after a mesh has been drawn.
  35650. */
  35651. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35652. /**
  35653. * @hidden
  35654. * Defines the actions happening just after a rendering group has been drawn.
  35655. */
  35656. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35657. /**
  35658. * @hidden
  35659. * Defines the actions happening just after the active camera has been drawn.
  35660. */
  35661. _afterCameraDrawStage: Stage<CameraStageAction>;
  35662. /**
  35663. * @hidden
  35664. * Defines the actions happening just after a render target has been drawn.
  35665. */
  35666. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35667. /**
  35668. * @hidden
  35669. * Defines the actions happening just after rendering all cameras and computing intersections.
  35670. */
  35671. _afterRenderStage: Stage<SimpleStageAction>;
  35672. /**
  35673. * @hidden
  35674. * Defines the actions happening when a pointer move event happens.
  35675. */
  35676. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35677. /**
  35678. * @hidden
  35679. * Defines the actions happening when a pointer down event happens.
  35680. */
  35681. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35682. /**
  35683. * @hidden
  35684. * Defines the actions happening when a pointer up event happens.
  35685. */
  35686. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35687. /**
  35688. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35689. */
  35690. private geometriesByUniqueId;
  35691. /**
  35692. * Creates a new Scene
  35693. * @param engine defines the engine to use to render this scene
  35694. * @param options defines the scene options
  35695. */
  35696. constructor(engine: Engine, options?: SceneOptions);
  35697. /**
  35698. * Gets a string idenfifying the name of the class
  35699. * @returns "Scene" string
  35700. */
  35701. getClassName(): string;
  35702. private _defaultMeshCandidates;
  35703. /**
  35704. * @hidden
  35705. */
  35706. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35707. private _defaultSubMeshCandidates;
  35708. /**
  35709. * @hidden
  35710. */
  35711. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35712. /**
  35713. * Sets the default candidate providers for the scene.
  35714. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35715. * and getCollidingSubMeshCandidates to their default function
  35716. */
  35717. setDefaultCandidateProviders(): void;
  35718. /**
  35719. * Gets the mesh that is currently under the pointer
  35720. */
  35721. get meshUnderPointer(): Nullable<AbstractMesh>;
  35722. /**
  35723. * Gets or sets the current on-screen X position of the pointer
  35724. */
  35725. get pointerX(): number;
  35726. set pointerX(value: number);
  35727. /**
  35728. * Gets or sets the current on-screen Y position of the pointer
  35729. */
  35730. get pointerY(): number;
  35731. set pointerY(value: number);
  35732. /**
  35733. * Gets the cached material (ie. the latest rendered one)
  35734. * @returns the cached material
  35735. */
  35736. getCachedMaterial(): Nullable<Material>;
  35737. /**
  35738. * Gets the cached effect (ie. the latest rendered one)
  35739. * @returns the cached effect
  35740. */
  35741. getCachedEffect(): Nullable<Effect>;
  35742. /**
  35743. * Gets the cached visibility state (ie. the latest rendered one)
  35744. * @returns the cached visibility state
  35745. */
  35746. getCachedVisibility(): Nullable<number>;
  35747. /**
  35748. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35749. * @param material defines the current material
  35750. * @param effect defines the current effect
  35751. * @param visibility defines the current visibility state
  35752. * @returns true if one parameter is not cached
  35753. */
  35754. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35755. /**
  35756. * Gets the engine associated with the scene
  35757. * @returns an Engine
  35758. */
  35759. getEngine(): Engine;
  35760. /**
  35761. * Gets the total number of vertices rendered per frame
  35762. * @returns the total number of vertices rendered per frame
  35763. */
  35764. getTotalVertices(): number;
  35765. /**
  35766. * Gets the performance counter for total vertices
  35767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35768. */
  35769. get totalVerticesPerfCounter(): PerfCounter;
  35770. /**
  35771. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35772. * @returns the total number of active indices rendered per frame
  35773. */
  35774. getActiveIndices(): number;
  35775. /**
  35776. * Gets the performance counter for active indices
  35777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35778. */
  35779. get totalActiveIndicesPerfCounter(): PerfCounter;
  35780. /**
  35781. * Gets the total number of active particles rendered per frame
  35782. * @returns the total number of active particles rendered per frame
  35783. */
  35784. getActiveParticles(): number;
  35785. /**
  35786. * Gets the performance counter for active particles
  35787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35788. */
  35789. get activeParticlesPerfCounter(): PerfCounter;
  35790. /**
  35791. * Gets the total number of active bones rendered per frame
  35792. * @returns the total number of active bones rendered per frame
  35793. */
  35794. getActiveBones(): number;
  35795. /**
  35796. * Gets the performance counter for active bones
  35797. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35798. */
  35799. get activeBonesPerfCounter(): PerfCounter;
  35800. /**
  35801. * Gets the array of active meshes
  35802. * @returns an array of AbstractMesh
  35803. */
  35804. getActiveMeshes(): SmartArray<AbstractMesh>;
  35805. /**
  35806. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35807. * @returns a number
  35808. */
  35809. getAnimationRatio(): number;
  35810. /**
  35811. * Gets an unique Id for the current render phase
  35812. * @returns a number
  35813. */
  35814. getRenderId(): number;
  35815. /**
  35816. * Gets an unique Id for the current frame
  35817. * @returns a number
  35818. */
  35819. getFrameId(): number;
  35820. /** Call this function if you want to manually increment the render Id*/
  35821. incrementRenderId(): void;
  35822. private _createUbo;
  35823. /**
  35824. * Use this method to simulate a pointer move on a mesh
  35825. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35826. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35827. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35828. * @returns the current scene
  35829. */
  35830. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35831. /**
  35832. * Use this method to simulate a pointer down on a mesh
  35833. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35834. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35835. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35836. * @returns the current scene
  35837. */
  35838. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35839. /**
  35840. * Use this method to simulate a pointer up on a mesh
  35841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35844. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35845. * @returns the current scene
  35846. */
  35847. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35848. /**
  35849. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35850. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35851. * @returns true if the pointer was captured
  35852. */
  35853. isPointerCaptured(pointerId?: number): boolean;
  35854. /**
  35855. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35856. * @param attachUp defines if you want to attach events to pointerup
  35857. * @param attachDown defines if you want to attach events to pointerdown
  35858. * @param attachMove defines if you want to attach events to pointermove
  35859. */
  35860. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35861. /** Detaches all event handlers*/
  35862. detachControl(): void;
  35863. /**
  35864. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35865. * Delay loaded resources are not taking in account
  35866. * @return true if all required resources are ready
  35867. */
  35868. isReady(): boolean;
  35869. /** Resets all cached information relative to material (including effect and visibility) */
  35870. resetCachedMaterial(): void;
  35871. /**
  35872. * Registers a function to be called before every frame render
  35873. * @param func defines the function to register
  35874. */
  35875. registerBeforeRender(func: () => void): void;
  35876. /**
  35877. * Unregisters a function called before every frame render
  35878. * @param func defines the function to unregister
  35879. */
  35880. unregisterBeforeRender(func: () => void): void;
  35881. /**
  35882. * Registers a function to be called after every frame render
  35883. * @param func defines the function to register
  35884. */
  35885. registerAfterRender(func: () => void): void;
  35886. /**
  35887. * Unregisters a function called after every frame render
  35888. * @param func defines the function to unregister
  35889. */
  35890. unregisterAfterRender(func: () => void): void;
  35891. private _executeOnceBeforeRender;
  35892. /**
  35893. * The provided function will run before render once and will be disposed afterwards.
  35894. * A timeout delay can be provided so that the function will be executed in N ms.
  35895. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35896. * @param func The function to be executed.
  35897. * @param timeout optional delay in ms
  35898. */
  35899. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35900. /** @hidden */
  35901. _addPendingData(data: any): void;
  35902. /** @hidden */
  35903. _removePendingData(data: any): void;
  35904. /**
  35905. * Returns the number of items waiting to be loaded
  35906. * @returns the number of items waiting to be loaded
  35907. */
  35908. getWaitingItemsCount(): number;
  35909. /**
  35910. * Returns a boolean indicating if the scene is still loading data
  35911. */
  35912. get isLoading(): boolean;
  35913. /**
  35914. * Registers a function to be executed when the scene is ready
  35915. * @param {Function} func - the function to be executed
  35916. */
  35917. executeWhenReady(func: () => void): void;
  35918. /**
  35919. * Returns a promise that resolves when the scene is ready
  35920. * @returns A promise that resolves when the scene is ready
  35921. */
  35922. whenReadyAsync(): Promise<void>;
  35923. /** @hidden */
  35924. _checkIsReady(): void;
  35925. /**
  35926. * Gets all animatable attached to the scene
  35927. */
  35928. get animatables(): Animatable[];
  35929. /**
  35930. * Resets the last animation time frame.
  35931. * Useful to override when animations start running when loading a scene for the first time.
  35932. */
  35933. resetLastAnimationTimeFrame(): void;
  35934. /**
  35935. * Gets the current view matrix
  35936. * @returns a Matrix
  35937. */
  35938. getViewMatrix(): Matrix;
  35939. /**
  35940. * Gets the current projection matrix
  35941. * @returns a Matrix
  35942. */
  35943. getProjectionMatrix(): Matrix;
  35944. /**
  35945. * Gets the current transform matrix
  35946. * @returns a Matrix made of View * Projection
  35947. */
  35948. getTransformMatrix(): Matrix;
  35949. /**
  35950. * Sets the current transform matrix
  35951. * @param viewL defines the View matrix to use
  35952. * @param projectionL defines the Projection matrix to use
  35953. * @param viewR defines the right View matrix to use (if provided)
  35954. * @param projectionR defines the right Projection matrix to use (if provided)
  35955. */
  35956. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35957. /**
  35958. * Gets the uniform buffer used to store scene data
  35959. * @returns a UniformBuffer
  35960. */
  35961. getSceneUniformBuffer(): UniformBuffer;
  35962. /**
  35963. * Gets an unique (relatively to the current scene) Id
  35964. * @returns an unique number for the scene
  35965. */
  35966. getUniqueId(): number;
  35967. /**
  35968. * Add a mesh to the list of scene's meshes
  35969. * @param newMesh defines the mesh to add
  35970. * @param recursive if all child meshes should also be added to the scene
  35971. */
  35972. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35973. /**
  35974. * Remove a mesh for the list of scene's meshes
  35975. * @param toRemove defines the mesh to remove
  35976. * @param recursive if all child meshes should also be removed from the scene
  35977. * @returns the index where the mesh was in the mesh list
  35978. */
  35979. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35980. /**
  35981. * Add a transform node to the list of scene's transform nodes
  35982. * @param newTransformNode defines the transform node to add
  35983. */
  35984. addTransformNode(newTransformNode: TransformNode): void;
  35985. /**
  35986. * Remove a transform node for the list of scene's transform nodes
  35987. * @param toRemove defines the transform node to remove
  35988. * @returns the index where the transform node was in the transform node list
  35989. */
  35990. removeTransformNode(toRemove: TransformNode): number;
  35991. /**
  35992. * Remove a skeleton for the list of scene's skeletons
  35993. * @param toRemove defines the skeleton to remove
  35994. * @returns the index where the skeleton was in the skeleton list
  35995. */
  35996. removeSkeleton(toRemove: Skeleton): number;
  35997. /**
  35998. * Remove a morph target for the list of scene's morph targets
  35999. * @param toRemove defines the morph target to remove
  36000. * @returns the index where the morph target was in the morph target list
  36001. */
  36002. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36003. /**
  36004. * Remove a light for the list of scene's lights
  36005. * @param toRemove defines the light to remove
  36006. * @returns the index where the light was in the light list
  36007. */
  36008. removeLight(toRemove: Light): number;
  36009. /**
  36010. * Remove a camera for the list of scene's cameras
  36011. * @param toRemove defines the camera to remove
  36012. * @returns the index where the camera was in the camera list
  36013. */
  36014. removeCamera(toRemove: Camera): number;
  36015. /**
  36016. * Remove a particle system for the list of scene's particle systems
  36017. * @param toRemove defines the particle system to remove
  36018. * @returns the index where the particle system was in the particle system list
  36019. */
  36020. removeParticleSystem(toRemove: IParticleSystem): number;
  36021. /**
  36022. * Remove a animation for the list of scene's animations
  36023. * @param toRemove defines the animation to remove
  36024. * @returns the index where the animation was in the animation list
  36025. */
  36026. removeAnimation(toRemove: Animation): number;
  36027. /**
  36028. * Will stop the animation of the given target
  36029. * @param target - the target
  36030. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36031. * @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)
  36032. */
  36033. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36034. /**
  36035. * Removes the given animation group from this scene.
  36036. * @param toRemove The animation group to remove
  36037. * @returns The index of the removed animation group
  36038. */
  36039. removeAnimationGroup(toRemove: AnimationGroup): number;
  36040. /**
  36041. * Removes the given multi-material from this scene.
  36042. * @param toRemove The multi-material to remove
  36043. * @returns The index of the removed multi-material
  36044. */
  36045. removeMultiMaterial(toRemove: MultiMaterial): number;
  36046. /**
  36047. * Removes the given material from this scene.
  36048. * @param toRemove The material to remove
  36049. * @returns The index of the removed material
  36050. */
  36051. removeMaterial(toRemove: Material): number;
  36052. /**
  36053. * Removes the given action manager from this scene.
  36054. * @param toRemove The action manager to remove
  36055. * @returns The index of the removed action manager
  36056. */
  36057. removeActionManager(toRemove: AbstractActionManager): number;
  36058. /**
  36059. * Removes the given texture from this scene.
  36060. * @param toRemove The texture to remove
  36061. * @returns The index of the removed texture
  36062. */
  36063. removeTexture(toRemove: BaseTexture): number;
  36064. /**
  36065. * Adds the given light to this scene
  36066. * @param newLight The light to add
  36067. */
  36068. addLight(newLight: Light): void;
  36069. /**
  36070. * Sorts the list list based on light priorities
  36071. */
  36072. sortLightsByPriority(): void;
  36073. /**
  36074. * Adds the given camera to this scene
  36075. * @param newCamera The camera to add
  36076. */
  36077. addCamera(newCamera: Camera): void;
  36078. /**
  36079. * Adds the given skeleton to this scene
  36080. * @param newSkeleton The skeleton to add
  36081. */
  36082. addSkeleton(newSkeleton: Skeleton): void;
  36083. /**
  36084. * Adds the given particle system to this scene
  36085. * @param newParticleSystem The particle system to add
  36086. */
  36087. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36088. /**
  36089. * Adds the given animation to this scene
  36090. * @param newAnimation The animation to add
  36091. */
  36092. addAnimation(newAnimation: Animation): void;
  36093. /**
  36094. * Adds the given animation group to this scene.
  36095. * @param newAnimationGroup The animation group to add
  36096. */
  36097. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36098. /**
  36099. * Adds the given multi-material to this scene
  36100. * @param newMultiMaterial The multi-material to add
  36101. */
  36102. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36103. /**
  36104. * Adds the given material to this scene
  36105. * @param newMaterial The material to add
  36106. */
  36107. addMaterial(newMaterial: Material): void;
  36108. /**
  36109. * Adds the given morph target to this scene
  36110. * @param newMorphTargetManager The morph target to add
  36111. */
  36112. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36113. /**
  36114. * Adds the given geometry to this scene
  36115. * @param newGeometry The geometry to add
  36116. */
  36117. addGeometry(newGeometry: Geometry): void;
  36118. /**
  36119. * Adds the given action manager to this scene
  36120. * @param newActionManager The action manager to add
  36121. */
  36122. addActionManager(newActionManager: AbstractActionManager): void;
  36123. /**
  36124. * Adds the given texture to this scene.
  36125. * @param newTexture The texture to add
  36126. */
  36127. addTexture(newTexture: BaseTexture): void;
  36128. /**
  36129. * Switch active camera
  36130. * @param newCamera defines the new active camera
  36131. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36132. */
  36133. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36134. /**
  36135. * sets the active camera of the scene using its ID
  36136. * @param id defines the camera's ID
  36137. * @return the new active camera or null if none found.
  36138. */
  36139. setActiveCameraByID(id: string): Nullable<Camera>;
  36140. /**
  36141. * sets the active camera of the scene using its name
  36142. * @param name defines the camera's name
  36143. * @returns the new active camera or null if none found.
  36144. */
  36145. setActiveCameraByName(name: string): Nullable<Camera>;
  36146. /**
  36147. * get an animation group using its name
  36148. * @param name defines the material's name
  36149. * @return the animation group or null if none found.
  36150. */
  36151. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36152. /**
  36153. * Get a material using its unique id
  36154. * @param uniqueId defines the material's unique id
  36155. * @return the material or null if none found.
  36156. */
  36157. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36158. /**
  36159. * get a material using its id
  36160. * @param id defines the material's ID
  36161. * @return the material or null if none found.
  36162. */
  36163. getMaterialByID(id: string): Nullable<Material>;
  36164. /**
  36165. * Gets a the last added material using a given id
  36166. * @param id defines the material's ID
  36167. * @return the last material with the given id or null if none found.
  36168. */
  36169. getLastMaterialByID(id: string): Nullable<Material>;
  36170. /**
  36171. * Gets a material using its name
  36172. * @param name defines the material's name
  36173. * @return the material or null if none found.
  36174. */
  36175. getMaterialByName(name: string): Nullable<Material>;
  36176. /**
  36177. * Get a texture using its unique id
  36178. * @param uniqueId defines the texture's unique id
  36179. * @return the texture or null if none found.
  36180. */
  36181. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36182. /**
  36183. * Gets a camera using its id
  36184. * @param id defines the id to look for
  36185. * @returns the camera or null if not found
  36186. */
  36187. getCameraByID(id: string): Nullable<Camera>;
  36188. /**
  36189. * Gets a camera using its unique id
  36190. * @param uniqueId defines the unique id to look for
  36191. * @returns the camera or null if not found
  36192. */
  36193. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36194. /**
  36195. * Gets a camera using its name
  36196. * @param name defines the camera's name
  36197. * @return the camera or null if none found.
  36198. */
  36199. getCameraByName(name: string): Nullable<Camera>;
  36200. /**
  36201. * Gets a bone using its id
  36202. * @param id defines the bone's id
  36203. * @return the bone or null if not found
  36204. */
  36205. getBoneByID(id: string): Nullable<Bone>;
  36206. /**
  36207. * Gets a bone using its id
  36208. * @param name defines the bone's name
  36209. * @return the bone or null if not found
  36210. */
  36211. getBoneByName(name: string): Nullable<Bone>;
  36212. /**
  36213. * Gets a light node using its name
  36214. * @param name defines the the light's name
  36215. * @return the light or null if none found.
  36216. */
  36217. getLightByName(name: string): Nullable<Light>;
  36218. /**
  36219. * Gets a light node using its id
  36220. * @param id defines the light's id
  36221. * @return the light or null if none found.
  36222. */
  36223. getLightByID(id: string): Nullable<Light>;
  36224. /**
  36225. * Gets a light node using its scene-generated unique ID
  36226. * @param uniqueId defines the light's unique id
  36227. * @return the light or null if none found.
  36228. */
  36229. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36230. /**
  36231. * Gets a particle system by id
  36232. * @param id defines the particle system id
  36233. * @return the corresponding system or null if none found
  36234. */
  36235. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36236. /**
  36237. * Gets a geometry using its ID
  36238. * @param id defines the geometry's id
  36239. * @return the geometry or null if none found.
  36240. */
  36241. getGeometryByID(id: string): Nullable<Geometry>;
  36242. private _getGeometryByUniqueID;
  36243. /**
  36244. * Add a new geometry to this scene
  36245. * @param geometry defines the geometry to be added to the scene.
  36246. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36247. * @return a boolean defining if the geometry was added or not
  36248. */
  36249. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36250. /**
  36251. * Removes an existing geometry
  36252. * @param geometry defines the geometry to be removed from the scene
  36253. * @return a boolean defining if the geometry was removed or not
  36254. */
  36255. removeGeometry(geometry: Geometry): boolean;
  36256. /**
  36257. * Gets the list of geometries attached to the scene
  36258. * @returns an array of Geometry
  36259. */
  36260. getGeometries(): Geometry[];
  36261. /**
  36262. * Gets the first added mesh found of a given ID
  36263. * @param id defines the id to search for
  36264. * @return the mesh found or null if not found at all
  36265. */
  36266. getMeshByID(id: string): Nullable<AbstractMesh>;
  36267. /**
  36268. * Gets a list of meshes using their id
  36269. * @param id defines the id to search for
  36270. * @returns a list of meshes
  36271. */
  36272. getMeshesByID(id: string): Array<AbstractMesh>;
  36273. /**
  36274. * Gets the first added transform node found of a given ID
  36275. * @param id defines the id to search for
  36276. * @return the found transform node or null if not found at all.
  36277. */
  36278. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36279. /**
  36280. * Gets a transform node with its auto-generated unique id
  36281. * @param uniqueId efines the unique id to search for
  36282. * @return the found transform node or null if not found at all.
  36283. */
  36284. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36285. /**
  36286. * Gets a list of transform nodes using their id
  36287. * @param id defines the id to search for
  36288. * @returns a list of transform nodes
  36289. */
  36290. getTransformNodesByID(id: string): Array<TransformNode>;
  36291. /**
  36292. * Gets a mesh with its auto-generated unique id
  36293. * @param uniqueId defines the unique id to search for
  36294. * @return the found mesh or null if not found at all.
  36295. */
  36296. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36297. /**
  36298. * Gets a the last added mesh using a given id
  36299. * @param id defines the id to search for
  36300. * @return the found mesh or null if not found at all.
  36301. */
  36302. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36303. /**
  36304. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36305. * @param id defines the id to search for
  36306. * @return the found node or null if not found at all
  36307. */
  36308. getLastEntryByID(id: string): Nullable<Node>;
  36309. /**
  36310. * Gets a node (Mesh, Camera, Light) using a given id
  36311. * @param id defines the id to search for
  36312. * @return the found node or null if not found at all
  36313. */
  36314. getNodeByID(id: string): Nullable<Node>;
  36315. /**
  36316. * Gets a node (Mesh, Camera, Light) using a given name
  36317. * @param name defines the name to search for
  36318. * @return the found node or null if not found at all.
  36319. */
  36320. getNodeByName(name: string): Nullable<Node>;
  36321. /**
  36322. * Gets a mesh using a given name
  36323. * @param name defines the name to search for
  36324. * @return the found mesh or null if not found at all.
  36325. */
  36326. getMeshByName(name: string): Nullable<AbstractMesh>;
  36327. /**
  36328. * Gets a transform node using a given name
  36329. * @param name defines the name to search for
  36330. * @return the found transform node or null if not found at all.
  36331. */
  36332. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36333. /**
  36334. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36335. * @param id defines the id to search for
  36336. * @return the found skeleton or null if not found at all.
  36337. */
  36338. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36339. /**
  36340. * Gets a skeleton using a given auto generated unique id
  36341. * @param uniqueId defines the unique id to search for
  36342. * @return the found skeleton or null if not found at all.
  36343. */
  36344. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36345. /**
  36346. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36347. * @param id defines the id to search for
  36348. * @return the found skeleton or null if not found at all.
  36349. */
  36350. getSkeletonById(id: string): Nullable<Skeleton>;
  36351. /**
  36352. * Gets a skeleton using a given name
  36353. * @param name defines the name to search for
  36354. * @return the found skeleton or null if not found at all.
  36355. */
  36356. getSkeletonByName(name: string): Nullable<Skeleton>;
  36357. /**
  36358. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36359. * @param id defines the id to search for
  36360. * @return the found morph target manager or null if not found at all.
  36361. */
  36362. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36363. /**
  36364. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36365. * @param id defines the id to search for
  36366. * @return the found morph target or null if not found at all.
  36367. */
  36368. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36369. /**
  36370. * Gets a boolean indicating if the given mesh is active
  36371. * @param mesh defines the mesh to look for
  36372. * @returns true if the mesh is in the active list
  36373. */
  36374. isActiveMesh(mesh: AbstractMesh): boolean;
  36375. /**
  36376. * Return a unique id as a string which can serve as an identifier for the scene
  36377. */
  36378. get uid(): string;
  36379. /**
  36380. * Add an externaly attached data from its key.
  36381. * This method call will fail and return false, if such key already exists.
  36382. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36383. * @param key the unique key that identifies the data
  36384. * @param data the data object to associate to the key for this Engine instance
  36385. * @return true if no such key were already present and the data was added successfully, false otherwise
  36386. */
  36387. addExternalData<T>(key: string, data: T): boolean;
  36388. /**
  36389. * Get an externaly attached data from its key
  36390. * @param key the unique key that identifies the data
  36391. * @return the associated data, if present (can be null), or undefined if not present
  36392. */
  36393. getExternalData<T>(key: string): Nullable<T>;
  36394. /**
  36395. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36396. * @param key the unique key that identifies the data
  36397. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36398. * @return the associated data, can be null if the factory returned null.
  36399. */
  36400. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36401. /**
  36402. * Remove an externaly attached data from the Engine instance
  36403. * @param key the unique key that identifies the data
  36404. * @return true if the data was successfully removed, false if it doesn't exist
  36405. */
  36406. removeExternalData(key: string): boolean;
  36407. private _evaluateSubMesh;
  36408. /**
  36409. * Clear the processed materials smart array preventing retention point in material dispose.
  36410. */
  36411. freeProcessedMaterials(): void;
  36412. private _preventFreeActiveMeshesAndRenderingGroups;
  36413. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36414. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36415. * when disposing several meshes in a row or a hierarchy of meshes.
  36416. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36417. */
  36418. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36419. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36420. /**
  36421. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36422. */
  36423. freeActiveMeshes(): void;
  36424. /**
  36425. * Clear the info related to rendering groups preventing retention points during dispose.
  36426. */
  36427. freeRenderingGroups(): void;
  36428. /** @hidden */
  36429. _isInIntermediateRendering(): boolean;
  36430. /**
  36431. * Lambda returning the list of potentially active meshes.
  36432. */
  36433. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36434. /**
  36435. * Lambda returning the list of potentially active sub meshes.
  36436. */
  36437. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36438. /**
  36439. * Lambda returning the list of potentially intersecting sub meshes.
  36440. */
  36441. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36442. /**
  36443. * Lambda returning the list of potentially colliding sub meshes.
  36444. */
  36445. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36446. private _activeMeshesFrozen;
  36447. private _skipEvaluateActiveMeshesCompletely;
  36448. /**
  36449. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36450. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36451. * @returns the current scene
  36452. */
  36453. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36454. /**
  36455. * Use this function to restart evaluating active meshes on every frame
  36456. * @returns the current scene
  36457. */
  36458. unfreezeActiveMeshes(): Scene;
  36459. private _evaluateActiveMeshes;
  36460. private _activeMesh;
  36461. /**
  36462. * Update the transform matrix to update from the current active camera
  36463. * @param force defines a boolean used to force the update even if cache is up to date
  36464. */
  36465. updateTransformMatrix(force?: boolean): void;
  36466. private _bindFrameBuffer;
  36467. /** @hidden */
  36468. _allowPostProcessClearColor: boolean;
  36469. /** @hidden */
  36470. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36471. private _processSubCameras;
  36472. private _checkIntersections;
  36473. /** @hidden */
  36474. _advancePhysicsEngineStep(step: number): void;
  36475. /**
  36476. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36477. */
  36478. getDeterministicFrameTime: () => number;
  36479. /** @hidden */
  36480. _animate(): void;
  36481. /** Execute all animations (for a frame) */
  36482. animate(): void;
  36483. /**
  36484. * Render the scene
  36485. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36486. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36487. */
  36488. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36489. /**
  36490. * Freeze all materials
  36491. * A frozen material will not be updatable but should be faster to render
  36492. */
  36493. freezeMaterials(): void;
  36494. /**
  36495. * Unfreeze all materials
  36496. * A frozen material will not be updatable but should be faster to render
  36497. */
  36498. unfreezeMaterials(): void;
  36499. /**
  36500. * Releases all held ressources
  36501. */
  36502. dispose(): void;
  36503. /**
  36504. * Gets if the scene is already disposed
  36505. */
  36506. get isDisposed(): boolean;
  36507. /**
  36508. * Call this function to reduce memory footprint of the scene.
  36509. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36510. */
  36511. clearCachedVertexData(): void;
  36512. /**
  36513. * This function will remove the local cached buffer data from texture.
  36514. * It will save memory but will prevent the texture from being rebuilt
  36515. */
  36516. cleanCachedTextureBuffer(): void;
  36517. /**
  36518. * Get the world extend vectors with an optional filter
  36519. *
  36520. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36521. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36522. */
  36523. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36524. min: Vector3;
  36525. max: Vector3;
  36526. };
  36527. /**
  36528. * Creates a ray that can be used to pick in the scene
  36529. * @param x defines the x coordinate of the origin (on-screen)
  36530. * @param y defines the y coordinate of the origin (on-screen)
  36531. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36532. * @param camera defines the camera to use for the picking
  36533. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36534. * @returns a Ray
  36535. */
  36536. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36537. /**
  36538. * Creates a ray that can be used to pick in the scene
  36539. * @param x defines the x coordinate of the origin (on-screen)
  36540. * @param y defines the y coordinate of the origin (on-screen)
  36541. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36542. * @param result defines the ray where to store the picking ray
  36543. * @param camera defines the camera to use for the picking
  36544. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36545. * @returns the current scene
  36546. */
  36547. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36548. /**
  36549. * Creates a ray that can be used to pick in the scene
  36550. * @param x defines the x coordinate of the origin (on-screen)
  36551. * @param y defines the y coordinate of the origin (on-screen)
  36552. * @param camera defines the camera to use for the picking
  36553. * @returns a Ray
  36554. */
  36555. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36556. /**
  36557. * Creates a ray that can be used to pick in the scene
  36558. * @param x defines the x coordinate of the origin (on-screen)
  36559. * @param y defines the y coordinate of the origin (on-screen)
  36560. * @param result defines the ray where to store the picking ray
  36561. * @param camera defines the camera to use for the picking
  36562. * @returns the current scene
  36563. */
  36564. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36565. /** Launch a ray to try to pick a mesh in the scene
  36566. * @param x position on screen
  36567. * @param y position on screen
  36568. * @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
  36569. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36570. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36572. * @returns a PickingInfo
  36573. */
  36574. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36575. /** Use the given ray to pick a mesh in the scene
  36576. * @param ray The ray to use to pick meshes
  36577. * @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
  36578. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36580. * @returns a PickingInfo
  36581. */
  36582. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36583. /**
  36584. * Launch a ray to try to pick a mesh in the scene
  36585. * @param x X position on screen
  36586. * @param y Y position on screen
  36587. * @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
  36588. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36590. * @returns an array of PickingInfo
  36591. */
  36592. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36593. /**
  36594. * Launch a ray to try to pick a mesh in the scene
  36595. * @param ray Ray to use
  36596. * @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
  36597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36598. * @returns an array of PickingInfo
  36599. */
  36600. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36601. /**
  36602. * Force the value of meshUnderPointer
  36603. * @param mesh defines the mesh to use
  36604. */
  36605. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36606. /**
  36607. * Gets the mesh under the pointer
  36608. * @returns a Mesh or null if no mesh is under the pointer
  36609. */
  36610. getPointerOverMesh(): Nullable<AbstractMesh>;
  36611. /** @hidden */
  36612. _rebuildGeometries(): void;
  36613. /** @hidden */
  36614. _rebuildTextures(): void;
  36615. private _getByTags;
  36616. /**
  36617. * Get a list of meshes by tags
  36618. * @param tagsQuery defines the tags query to use
  36619. * @param forEach defines a predicate used to filter results
  36620. * @returns an array of Mesh
  36621. */
  36622. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36623. /**
  36624. * Get a list of cameras by tags
  36625. * @param tagsQuery defines the tags query to use
  36626. * @param forEach defines a predicate used to filter results
  36627. * @returns an array of Camera
  36628. */
  36629. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36630. /**
  36631. * Get a list of lights by tags
  36632. * @param tagsQuery defines the tags query to use
  36633. * @param forEach defines a predicate used to filter results
  36634. * @returns an array of Light
  36635. */
  36636. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36637. /**
  36638. * Get a list of materials by tags
  36639. * @param tagsQuery defines the tags query to use
  36640. * @param forEach defines a predicate used to filter results
  36641. * @returns an array of Material
  36642. */
  36643. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36644. /**
  36645. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36646. * This allowed control for front to back rendering or reversly depending of the special needs.
  36647. *
  36648. * @param renderingGroupId The rendering group id corresponding to its index
  36649. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36650. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36651. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36652. */
  36653. 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;
  36654. /**
  36655. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36656. *
  36657. * @param renderingGroupId The rendering group id corresponding to its index
  36658. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36659. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36660. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36661. */
  36662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36663. /**
  36664. * Gets the current auto clear configuration for one rendering group of the rendering
  36665. * manager.
  36666. * @param index the rendering group index to get the information for
  36667. * @returns The auto clear setup for the requested rendering group
  36668. */
  36669. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36670. private _blockMaterialDirtyMechanism;
  36671. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36672. get blockMaterialDirtyMechanism(): boolean;
  36673. set blockMaterialDirtyMechanism(value: boolean);
  36674. /**
  36675. * Will flag all materials as dirty to trigger new shader compilation
  36676. * @param flag defines the flag used to specify which material part must be marked as dirty
  36677. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36678. */
  36679. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36680. /** @hidden */
  36681. _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;
  36682. /** @hidden */
  36683. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36684. /** @hidden */
  36685. _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;
  36686. /** @hidden */
  36687. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36688. /** @hidden */
  36689. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36690. /** @hidden */
  36691. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36692. }
  36693. }
  36694. declare module BABYLON {
  36695. /**
  36696. * Set of assets to keep when moving a scene into an asset container.
  36697. */
  36698. export class KeepAssets extends AbstractScene {
  36699. }
  36700. /**
  36701. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36702. */
  36703. export class InstantiatedEntries {
  36704. /**
  36705. * List of new root nodes (eg. nodes with no parent)
  36706. */
  36707. rootNodes: TransformNode[];
  36708. /**
  36709. * List of new skeletons
  36710. */
  36711. skeletons: Skeleton[];
  36712. /**
  36713. * List of new animation groups
  36714. */
  36715. animationGroups: AnimationGroup[];
  36716. }
  36717. /**
  36718. * Container with a set of assets that can be added or removed from a scene.
  36719. */
  36720. export class AssetContainer extends AbstractScene {
  36721. /**
  36722. * The scene the AssetContainer belongs to.
  36723. */
  36724. scene: Scene;
  36725. /**
  36726. * Instantiates an AssetContainer.
  36727. * @param scene The scene the AssetContainer belongs to.
  36728. */
  36729. constructor(scene: Scene);
  36730. /**
  36731. * Instantiate or clone all meshes and add the new ones to the scene.
  36732. * Skeletons and animation groups will all be cloned
  36733. * @param nameFunction defines an optional function used to get new names for clones
  36734. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36735. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36736. */
  36737. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36738. /**
  36739. * Adds all the assets from the container to the scene.
  36740. */
  36741. addAllToScene(): void;
  36742. /**
  36743. * Removes all the assets in the container from the scene
  36744. */
  36745. removeAllFromScene(): void;
  36746. /**
  36747. * Disposes all the assets in the container
  36748. */
  36749. dispose(): void;
  36750. private _moveAssets;
  36751. /**
  36752. * Removes all the assets contained in the scene and adds them to the container.
  36753. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36754. */
  36755. moveAllFromScene(keepAssets?: KeepAssets): void;
  36756. /**
  36757. * 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.
  36758. * @returns the root mesh
  36759. */
  36760. createRootMesh(): Mesh;
  36761. /**
  36762. * Merge animations from this asset container into a scene
  36763. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36764. * @param animatables set of animatables to retarget to a node from the scene
  36765. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36766. */
  36767. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36768. }
  36769. }
  36770. declare module BABYLON {
  36771. /**
  36772. * Defines how the parser contract is defined.
  36773. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36774. */
  36775. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36776. /**
  36777. * Defines how the individual parser contract is defined.
  36778. * These parser can parse an individual asset
  36779. */
  36780. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36781. /**
  36782. * Base class of the scene acting as a container for the different elements composing a scene.
  36783. * This class is dynamically extended by the different components of the scene increasing
  36784. * flexibility and reducing coupling
  36785. */
  36786. export abstract class AbstractScene {
  36787. /**
  36788. * Stores the list of available parsers in the application.
  36789. */
  36790. private static _BabylonFileParsers;
  36791. /**
  36792. * Stores the list of available individual parsers in the application.
  36793. */
  36794. private static _IndividualBabylonFileParsers;
  36795. /**
  36796. * Adds a parser in the list of available ones
  36797. * @param name Defines the name of the parser
  36798. * @param parser Defines the parser to add
  36799. */
  36800. static AddParser(name: string, parser: BabylonFileParser): void;
  36801. /**
  36802. * Gets a general parser from the list of avaialble ones
  36803. * @param name Defines the name of the parser
  36804. * @returns the requested parser or null
  36805. */
  36806. static GetParser(name: string): Nullable<BabylonFileParser>;
  36807. /**
  36808. * Adds n individual parser in the list of available ones
  36809. * @param name Defines the name of the parser
  36810. * @param parser Defines the parser to add
  36811. */
  36812. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36813. /**
  36814. * Gets an individual parser from the list of avaialble ones
  36815. * @param name Defines the name of the parser
  36816. * @returns the requested parser or null
  36817. */
  36818. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36819. /**
  36820. * Parser json data and populate both a scene and its associated container object
  36821. * @param jsonData Defines the data to parse
  36822. * @param scene Defines the scene to parse the data for
  36823. * @param container Defines the container attached to the parsing sequence
  36824. * @param rootUrl Defines the root url of the data
  36825. */
  36826. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36827. /**
  36828. * Gets the list of root nodes (ie. nodes with no parent)
  36829. */
  36830. rootNodes: Node[];
  36831. /** All of the cameras added to this scene
  36832. * @see http://doc.babylonjs.com/babylon101/cameras
  36833. */
  36834. cameras: Camera[];
  36835. /**
  36836. * All of the lights added to this scene
  36837. * @see http://doc.babylonjs.com/babylon101/lights
  36838. */
  36839. lights: Light[];
  36840. /**
  36841. * All of the (abstract) meshes added to this scene
  36842. */
  36843. meshes: AbstractMesh[];
  36844. /**
  36845. * The list of skeletons added to the scene
  36846. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36847. */
  36848. skeletons: Skeleton[];
  36849. /**
  36850. * All of the particle systems added to this scene
  36851. * @see http://doc.babylonjs.com/babylon101/particles
  36852. */
  36853. particleSystems: IParticleSystem[];
  36854. /**
  36855. * Gets a list of Animations associated with the scene
  36856. */
  36857. animations: Animation[];
  36858. /**
  36859. * All of the animation groups added to this scene
  36860. * @see http://doc.babylonjs.com/how_to/group
  36861. */
  36862. animationGroups: AnimationGroup[];
  36863. /**
  36864. * All of the multi-materials added to this scene
  36865. * @see http://doc.babylonjs.com/how_to/multi_materials
  36866. */
  36867. multiMaterials: MultiMaterial[];
  36868. /**
  36869. * All of the materials added to this scene
  36870. * In the context of a Scene, it is not supposed to be modified manually.
  36871. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36872. * Note also that the order of the Material within the array is not significant and might change.
  36873. * @see http://doc.babylonjs.com/babylon101/materials
  36874. */
  36875. materials: Material[];
  36876. /**
  36877. * The list of morph target managers added to the scene
  36878. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36879. */
  36880. morphTargetManagers: MorphTargetManager[];
  36881. /**
  36882. * The list of geometries used in the scene.
  36883. */
  36884. geometries: Geometry[];
  36885. /**
  36886. * All of the tranform nodes added to this scene
  36887. * In the context of a Scene, it is not supposed to be modified manually.
  36888. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36889. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36890. * @see http://doc.babylonjs.com/how_to/transformnode
  36891. */
  36892. transformNodes: TransformNode[];
  36893. /**
  36894. * ActionManagers available on the scene.
  36895. */
  36896. actionManagers: AbstractActionManager[];
  36897. /**
  36898. * Textures to keep.
  36899. */
  36900. textures: BaseTexture[];
  36901. /**
  36902. * Environment texture for the scene
  36903. */
  36904. environmentTexture: Nullable<BaseTexture>;
  36905. /**
  36906. * @returns all meshes, lights, cameras, transformNodes and bones
  36907. */
  36908. getNodes(): Array<Node>;
  36909. }
  36910. }
  36911. declare module BABYLON {
  36912. /**
  36913. * Interface used to define options for Sound class
  36914. */
  36915. export interface ISoundOptions {
  36916. /**
  36917. * Does the sound autoplay once loaded.
  36918. */
  36919. autoplay?: boolean;
  36920. /**
  36921. * Does the sound loop after it finishes playing once.
  36922. */
  36923. loop?: boolean;
  36924. /**
  36925. * Sound's volume
  36926. */
  36927. volume?: number;
  36928. /**
  36929. * Is it a spatial sound?
  36930. */
  36931. spatialSound?: boolean;
  36932. /**
  36933. * Maximum distance to hear that sound
  36934. */
  36935. maxDistance?: number;
  36936. /**
  36937. * Uses user defined attenuation function
  36938. */
  36939. useCustomAttenuation?: boolean;
  36940. /**
  36941. * Define the roll off factor of spatial sounds.
  36942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36943. */
  36944. rolloffFactor?: number;
  36945. /**
  36946. * Define the reference distance the sound should be heard perfectly.
  36947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36948. */
  36949. refDistance?: number;
  36950. /**
  36951. * Define the distance attenuation model the sound will follow.
  36952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36953. */
  36954. distanceModel?: string;
  36955. /**
  36956. * Defines the playback speed (1 by default)
  36957. */
  36958. playbackRate?: number;
  36959. /**
  36960. * Defines if the sound is from a streaming source
  36961. */
  36962. streaming?: boolean;
  36963. /**
  36964. * Defines an optional length (in seconds) inside the sound file
  36965. */
  36966. length?: number;
  36967. /**
  36968. * Defines an optional offset (in seconds) inside the sound file
  36969. */
  36970. offset?: number;
  36971. /**
  36972. * If true, URLs will not be required to state the audio file codec to use.
  36973. */
  36974. skipCodecCheck?: boolean;
  36975. }
  36976. /**
  36977. * Defines a sound that can be played in the application.
  36978. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36980. */
  36981. export class Sound {
  36982. /**
  36983. * The name of the sound in the scene.
  36984. */
  36985. name: string;
  36986. /**
  36987. * Does the sound autoplay once loaded.
  36988. */
  36989. autoplay: boolean;
  36990. /**
  36991. * Does the sound loop after it finishes playing once.
  36992. */
  36993. loop: boolean;
  36994. /**
  36995. * Does the sound use a custom attenuation curve to simulate the falloff
  36996. * happening when the source gets further away from the camera.
  36997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36998. */
  36999. useCustomAttenuation: boolean;
  37000. /**
  37001. * The sound track id this sound belongs to.
  37002. */
  37003. soundTrackId: number;
  37004. /**
  37005. * Is this sound currently played.
  37006. */
  37007. isPlaying: boolean;
  37008. /**
  37009. * Is this sound currently paused.
  37010. */
  37011. isPaused: boolean;
  37012. /**
  37013. * Does this sound enables spatial sound.
  37014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37015. */
  37016. spatialSound: boolean;
  37017. /**
  37018. * Define the reference distance the sound should be heard perfectly.
  37019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37020. */
  37021. refDistance: number;
  37022. /**
  37023. * Define the roll off factor of spatial sounds.
  37024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37025. */
  37026. rolloffFactor: number;
  37027. /**
  37028. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37030. */
  37031. maxDistance: number;
  37032. /**
  37033. * Define the distance attenuation model the sound will follow.
  37034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37035. */
  37036. distanceModel: string;
  37037. /**
  37038. * @hidden
  37039. * Back Compat
  37040. **/
  37041. onended: () => any;
  37042. /**
  37043. * Observable event when the current playing sound finishes.
  37044. */
  37045. onEndedObservable: Observable<Sound>;
  37046. private _panningModel;
  37047. private _playbackRate;
  37048. private _streaming;
  37049. private _startTime;
  37050. private _startOffset;
  37051. private _position;
  37052. /** @hidden */
  37053. _positionInEmitterSpace: boolean;
  37054. private _localDirection;
  37055. private _volume;
  37056. private _isReadyToPlay;
  37057. private _isDirectional;
  37058. private _readyToPlayCallback;
  37059. private _audioBuffer;
  37060. private _soundSource;
  37061. private _streamingSource;
  37062. private _soundPanner;
  37063. private _soundGain;
  37064. private _inputAudioNode;
  37065. private _outputAudioNode;
  37066. private _coneInnerAngle;
  37067. private _coneOuterAngle;
  37068. private _coneOuterGain;
  37069. private _scene;
  37070. private _connectedTransformNode;
  37071. private _customAttenuationFunction;
  37072. private _registerFunc;
  37073. private _isOutputConnected;
  37074. private _htmlAudioElement;
  37075. private _urlType;
  37076. private _length?;
  37077. private _offset?;
  37078. /** @hidden */
  37079. static _SceneComponentInitialization: (scene: Scene) => void;
  37080. /**
  37081. * Create a sound and attach it to a scene
  37082. * @param name Name of your sound
  37083. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37084. * @param scene defines the scene the sound belongs to
  37085. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37086. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37087. */
  37088. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37089. /**
  37090. * Release the sound and its associated resources
  37091. */
  37092. dispose(): void;
  37093. /**
  37094. * Gets if the sounds is ready to be played or not.
  37095. * @returns true if ready, otherwise false
  37096. */
  37097. isReady(): boolean;
  37098. private _soundLoaded;
  37099. /**
  37100. * Sets the data of the sound from an audiobuffer
  37101. * @param audioBuffer The audioBuffer containing the data
  37102. */
  37103. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37104. /**
  37105. * Updates the current sounds options such as maxdistance, loop...
  37106. * @param options A JSON object containing values named as the object properties
  37107. */
  37108. updateOptions(options: ISoundOptions): void;
  37109. private _createSpatialParameters;
  37110. private _updateSpatialParameters;
  37111. /**
  37112. * Switch the panning model to HRTF:
  37113. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37115. */
  37116. switchPanningModelToHRTF(): void;
  37117. /**
  37118. * Switch the panning model to Equal Power:
  37119. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37121. */
  37122. switchPanningModelToEqualPower(): void;
  37123. private _switchPanningModel;
  37124. /**
  37125. * Connect this sound to a sound track audio node like gain...
  37126. * @param soundTrackAudioNode the sound track audio node to connect to
  37127. */
  37128. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37129. /**
  37130. * Transform this sound into a directional source
  37131. * @param coneInnerAngle Size of the inner cone in degree
  37132. * @param coneOuterAngle Size of the outer cone in degree
  37133. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37134. */
  37135. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37136. /**
  37137. * Gets or sets the inner angle for the directional cone.
  37138. */
  37139. get directionalConeInnerAngle(): number;
  37140. /**
  37141. * Gets or sets the inner angle for the directional cone.
  37142. */
  37143. set directionalConeInnerAngle(value: number);
  37144. /**
  37145. * Gets or sets the outer angle for the directional cone.
  37146. */
  37147. get directionalConeOuterAngle(): number;
  37148. /**
  37149. * Gets or sets the outer angle for the directional cone.
  37150. */
  37151. set directionalConeOuterAngle(value: number);
  37152. /**
  37153. * Sets the position of the emitter if spatial sound is enabled
  37154. * @param newPosition Defines the new posisiton
  37155. */
  37156. setPosition(newPosition: Vector3): void;
  37157. /**
  37158. * Sets the local direction of the emitter if spatial sound is enabled
  37159. * @param newLocalDirection Defines the new local direction
  37160. */
  37161. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37162. private _updateDirection;
  37163. /** @hidden */
  37164. updateDistanceFromListener(): void;
  37165. /**
  37166. * Sets a new custom attenuation function for the sound.
  37167. * @param callback Defines the function used for the attenuation
  37168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37169. */
  37170. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37171. /**
  37172. * Play the sound
  37173. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37174. * @param offset (optional) Start the sound at a specific time in seconds
  37175. * @param length (optional) Sound duration (in seconds)
  37176. */
  37177. play(time?: number, offset?: number, length?: number): void;
  37178. private _onended;
  37179. /**
  37180. * Stop the sound
  37181. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37182. */
  37183. stop(time?: number): void;
  37184. /**
  37185. * Put the sound in pause
  37186. */
  37187. pause(): void;
  37188. /**
  37189. * Sets a dedicated volume for this sounds
  37190. * @param newVolume Define the new volume of the sound
  37191. * @param time Define time for gradual change to new volume
  37192. */
  37193. setVolume(newVolume: number, time?: number): void;
  37194. /**
  37195. * Set the sound play back rate
  37196. * @param newPlaybackRate Define the playback rate the sound should be played at
  37197. */
  37198. setPlaybackRate(newPlaybackRate: number): void;
  37199. /**
  37200. * Gets the volume of the sound.
  37201. * @returns the volume of the sound
  37202. */
  37203. getVolume(): number;
  37204. /**
  37205. * Attach the sound to a dedicated mesh
  37206. * @param transformNode The transform node to connect the sound with
  37207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37208. */
  37209. attachToMesh(transformNode: TransformNode): void;
  37210. /**
  37211. * Detach the sound from the previously attached mesh
  37212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37213. */
  37214. detachFromMesh(): void;
  37215. private _onRegisterAfterWorldMatrixUpdate;
  37216. /**
  37217. * Clone the current sound in the scene.
  37218. * @returns the new sound clone
  37219. */
  37220. clone(): Nullable<Sound>;
  37221. /**
  37222. * Gets the current underlying audio buffer containing the data
  37223. * @returns the audio buffer
  37224. */
  37225. getAudioBuffer(): Nullable<AudioBuffer>;
  37226. /**
  37227. * Serializes the Sound in a JSON representation
  37228. * @returns the JSON representation of the sound
  37229. */
  37230. serialize(): any;
  37231. /**
  37232. * Parse a JSON representation of a sound to innstantiate in a given scene
  37233. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37234. * @param scene Define the scene the new parsed sound should be created in
  37235. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37236. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37237. * @returns the newly parsed sound
  37238. */
  37239. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37240. }
  37241. }
  37242. declare module BABYLON {
  37243. /**
  37244. * This defines an action helpful to play a defined sound on a triggered action.
  37245. */
  37246. export class PlaySoundAction extends Action {
  37247. private _sound;
  37248. /**
  37249. * Instantiate the action
  37250. * @param triggerOptions defines the trigger options
  37251. * @param sound defines the sound to play
  37252. * @param condition defines the trigger related conditions
  37253. */
  37254. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37255. /** @hidden */
  37256. _prepare(): void;
  37257. /**
  37258. * Execute the action and play the sound.
  37259. */
  37260. execute(): void;
  37261. /**
  37262. * Serializes the actions and its related information.
  37263. * @param parent defines the object to serialize in
  37264. * @returns the serialized object
  37265. */
  37266. serialize(parent: any): any;
  37267. }
  37268. /**
  37269. * This defines an action helpful to stop a defined sound on a triggered action.
  37270. */
  37271. export class StopSoundAction extends Action {
  37272. private _sound;
  37273. /**
  37274. * Instantiate the action
  37275. * @param triggerOptions defines the trigger options
  37276. * @param sound defines the sound to stop
  37277. * @param condition defines the trigger related conditions
  37278. */
  37279. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37280. /** @hidden */
  37281. _prepare(): void;
  37282. /**
  37283. * Execute the action and stop the sound.
  37284. */
  37285. execute(): void;
  37286. /**
  37287. * Serializes the actions and its related information.
  37288. * @param parent defines the object to serialize in
  37289. * @returns the serialized object
  37290. */
  37291. serialize(parent: any): any;
  37292. }
  37293. }
  37294. declare module BABYLON {
  37295. /**
  37296. * This defines an action responsible to change the value of a property
  37297. * by interpolating between its current value and the newly set one once triggered.
  37298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37299. */
  37300. export class InterpolateValueAction extends Action {
  37301. /**
  37302. * Defines the path of the property where the value should be interpolated
  37303. */
  37304. propertyPath: string;
  37305. /**
  37306. * Defines the target value at the end of the interpolation.
  37307. */
  37308. value: any;
  37309. /**
  37310. * Defines the time it will take for the property to interpolate to the value.
  37311. */
  37312. duration: number;
  37313. /**
  37314. * Defines if the other scene animations should be stopped when the action has been triggered
  37315. */
  37316. stopOtherAnimations?: boolean;
  37317. /**
  37318. * Defines a callback raised once the interpolation animation has been done.
  37319. */
  37320. onInterpolationDone?: () => void;
  37321. /**
  37322. * Observable triggered once the interpolation animation has been done.
  37323. */
  37324. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37325. private _target;
  37326. private _effectiveTarget;
  37327. private _property;
  37328. /**
  37329. * Instantiate the action
  37330. * @param triggerOptions defines the trigger options
  37331. * @param target defines the object containing the value to interpolate
  37332. * @param propertyPath defines the path to the property in the target object
  37333. * @param value defines the target value at the end of the interpolation
  37334. * @param duration deines the time it will take for the property to interpolate to the value.
  37335. * @param condition defines the trigger related conditions
  37336. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37337. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37338. */
  37339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37340. /** @hidden */
  37341. _prepare(): void;
  37342. /**
  37343. * Execute the action starts the value interpolation.
  37344. */
  37345. execute(): void;
  37346. /**
  37347. * Serializes the actions and its related information.
  37348. * @param parent defines the object to serialize in
  37349. * @returns the serialized object
  37350. */
  37351. serialize(parent: any): any;
  37352. }
  37353. }
  37354. declare module BABYLON {
  37355. /**
  37356. * Options allowed during the creation of a sound track.
  37357. */
  37358. export interface ISoundTrackOptions {
  37359. /**
  37360. * The volume the sound track should take during creation
  37361. */
  37362. volume?: number;
  37363. /**
  37364. * Define if the sound track is the main sound track of the scene
  37365. */
  37366. mainTrack?: boolean;
  37367. }
  37368. /**
  37369. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37370. * It will be also used in a future release to apply effects on a specific track.
  37371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37372. */
  37373. export class SoundTrack {
  37374. /**
  37375. * The unique identifier of the sound track in the scene.
  37376. */
  37377. id: number;
  37378. /**
  37379. * The list of sounds included in the sound track.
  37380. */
  37381. soundCollection: Array<Sound>;
  37382. private _outputAudioNode;
  37383. private _scene;
  37384. private _connectedAnalyser;
  37385. private _options;
  37386. private _isInitialized;
  37387. /**
  37388. * Creates a new sound track.
  37389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37390. * @param scene Define the scene the sound track belongs to
  37391. * @param options
  37392. */
  37393. constructor(scene: Scene, options?: ISoundTrackOptions);
  37394. private _initializeSoundTrackAudioGraph;
  37395. /**
  37396. * Release the sound track and its associated resources
  37397. */
  37398. dispose(): void;
  37399. /**
  37400. * Adds a sound to this sound track
  37401. * @param sound define the cound to add
  37402. * @ignoreNaming
  37403. */
  37404. AddSound(sound: Sound): void;
  37405. /**
  37406. * Removes a sound to this sound track
  37407. * @param sound define the cound to remove
  37408. * @ignoreNaming
  37409. */
  37410. RemoveSound(sound: Sound): void;
  37411. /**
  37412. * Set a global volume for the full sound track.
  37413. * @param newVolume Define the new volume of the sound track
  37414. */
  37415. setVolume(newVolume: number): void;
  37416. /**
  37417. * Switch the panning model to HRTF:
  37418. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37420. */
  37421. switchPanningModelToHRTF(): void;
  37422. /**
  37423. * Switch the panning model to Equal Power:
  37424. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37426. */
  37427. switchPanningModelToEqualPower(): void;
  37428. /**
  37429. * Connect the sound track to an audio analyser allowing some amazing
  37430. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37432. * @param analyser The analyser to connect to the engine
  37433. */
  37434. connectToAnalyser(analyser: Analyser): void;
  37435. }
  37436. }
  37437. declare module BABYLON {
  37438. interface AbstractScene {
  37439. /**
  37440. * The list of sounds used in the scene.
  37441. */
  37442. sounds: Nullable<Array<Sound>>;
  37443. }
  37444. interface Scene {
  37445. /**
  37446. * @hidden
  37447. * Backing field
  37448. */
  37449. _mainSoundTrack: SoundTrack;
  37450. /**
  37451. * The main sound track played by the scene.
  37452. * It cotains your primary collection of sounds.
  37453. */
  37454. mainSoundTrack: SoundTrack;
  37455. /**
  37456. * The list of sound tracks added to the scene
  37457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37458. */
  37459. soundTracks: Nullable<Array<SoundTrack>>;
  37460. /**
  37461. * Gets a sound using a given name
  37462. * @param name defines the name to search for
  37463. * @return the found sound or null if not found at all.
  37464. */
  37465. getSoundByName(name: string): Nullable<Sound>;
  37466. /**
  37467. * Gets or sets if audio support is enabled
  37468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37469. */
  37470. audioEnabled: boolean;
  37471. /**
  37472. * Gets or sets if audio will be output to headphones
  37473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37474. */
  37475. headphone: boolean;
  37476. /**
  37477. * Gets or sets custom audio listener position provider
  37478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37479. */
  37480. audioListenerPositionProvider: Nullable<() => Vector3>;
  37481. /**
  37482. * Gets or sets a refresh rate when using 3D audio positioning
  37483. */
  37484. audioPositioningRefreshRate: number;
  37485. }
  37486. /**
  37487. * Defines the sound scene component responsible to manage any sounds
  37488. * in a given scene.
  37489. */
  37490. export class AudioSceneComponent implements ISceneSerializableComponent {
  37491. /**
  37492. * The component name helpfull to identify the component in the list of scene components.
  37493. */
  37494. readonly name: string;
  37495. /**
  37496. * The scene the component belongs to.
  37497. */
  37498. scene: Scene;
  37499. private _audioEnabled;
  37500. /**
  37501. * Gets whether audio is enabled or not.
  37502. * Please use related enable/disable method to switch state.
  37503. */
  37504. get audioEnabled(): boolean;
  37505. private _headphone;
  37506. /**
  37507. * Gets whether audio is outputing to headphone or not.
  37508. * Please use the according Switch methods to change output.
  37509. */
  37510. get headphone(): boolean;
  37511. /**
  37512. * Gets or sets a refresh rate when using 3D audio positioning
  37513. */
  37514. audioPositioningRefreshRate: number;
  37515. private _audioListenerPositionProvider;
  37516. /**
  37517. * Gets the current audio listener position provider
  37518. */
  37519. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37520. /**
  37521. * Sets a custom listener position for all sounds in the scene
  37522. * By default, this is the position of the first active camera
  37523. */
  37524. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37525. /**
  37526. * Creates a new instance of the component for the given scene
  37527. * @param scene Defines the scene to register the component in
  37528. */
  37529. constructor(scene: Scene);
  37530. /**
  37531. * Registers the component in a given scene
  37532. */
  37533. register(): void;
  37534. /**
  37535. * Rebuilds the elements related to this component in case of
  37536. * context lost for instance.
  37537. */
  37538. rebuild(): void;
  37539. /**
  37540. * Serializes the component data to the specified json object
  37541. * @param serializationObject The object to serialize to
  37542. */
  37543. serialize(serializationObject: any): void;
  37544. /**
  37545. * Adds all the elements from the container to the scene
  37546. * @param container the container holding the elements
  37547. */
  37548. addFromContainer(container: AbstractScene): void;
  37549. /**
  37550. * Removes all the elements in the container from the scene
  37551. * @param container contains the elements to remove
  37552. * @param dispose if the removed element should be disposed (default: false)
  37553. */
  37554. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37555. /**
  37556. * Disposes the component and the associated ressources.
  37557. */
  37558. dispose(): void;
  37559. /**
  37560. * Disables audio in the associated scene.
  37561. */
  37562. disableAudio(): void;
  37563. /**
  37564. * Enables audio in the associated scene.
  37565. */
  37566. enableAudio(): void;
  37567. /**
  37568. * Switch audio to headphone output.
  37569. */
  37570. switchAudioModeForHeadphones(): void;
  37571. /**
  37572. * Switch audio to normal speakers.
  37573. */
  37574. switchAudioModeForNormalSpeakers(): void;
  37575. private _cachedCameraDirection;
  37576. private _cachedCameraPosition;
  37577. private _lastCheck;
  37578. private _afterRender;
  37579. }
  37580. }
  37581. declare module BABYLON {
  37582. /**
  37583. * Wraps one or more Sound objects and selects one with random weight for playback.
  37584. */
  37585. export class WeightedSound {
  37586. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37587. loop: boolean;
  37588. private _coneInnerAngle;
  37589. private _coneOuterAngle;
  37590. private _volume;
  37591. /** A Sound is currently playing. */
  37592. isPlaying: boolean;
  37593. /** A Sound is currently paused. */
  37594. isPaused: boolean;
  37595. private _sounds;
  37596. private _weights;
  37597. private _currentIndex?;
  37598. /**
  37599. * Creates a new WeightedSound from the list of sounds given.
  37600. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37601. * @param sounds Array of Sounds that will be selected from.
  37602. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37603. */
  37604. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37605. /**
  37606. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37607. */
  37608. get directionalConeInnerAngle(): number;
  37609. /**
  37610. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37611. */
  37612. set directionalConeInnerAngle(value: number);
  37613. /**
  37614. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37615. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37616. */
  37617. get directionalConeOuterAngle(): number;
  37618. /**
  37619. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37620. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37621. */
  37622. set directionalConeOuterAngle(value: number);
  37623. /**
  37624. * Playback volume.
  37625. */
  37626. get volume(): number;
  37627. /**
  37628. * Playback volume.
  37629. */
  37630. set volume(value: number);
  37631. private _onended;
  37632. /**
  37633. * Suspend playback
  37634. */
  37635. pause(): void;
  37636. /**
  37637. * Stop playback
  37638. */
  37639. stop(): void;
  37640. /**
  37641. * Start playback.
  37642. * @param startOffset Position the clip head at a specific time in seconds.
  37643. */
  37644. play(startOffset?: number): void;
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. /**
  37649. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37650. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37651. */
  37652. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37653. /**
  37654. * Gets the name of the behavior.
  37655. */
  37656. get name(): string;
  37657. /**
  37658. * The easing function used by animations
  37659. */
  37660. static EasingFunction: BackEase;
  37661. /**
  37662. * The easing mode used by animations
  37663. */
  37664. static EasingMode: number;
  37665. /**
  37666. * The duration of the animation, in milliseconds
  37667. */
  37668. transitionDuration: number;
  37669. /**
  37670. * Length of the distance animated by the transition when lower radius is reached
  37671. */
  37672. lowerRadiusTransitionRange: number;
  37673. /**
  37674. * Length of the distance animated by the transition when upper radius is reached
  37675. */
  37676. upperRadiusTransitionRange: number;
  37677. private _autoTransitionRange;
  37678. /**
  37679. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37680. */
  37681. get autoTransitionRange(): boolean;
  37682. /**
  37683. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37684. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37685. */
  37686. set autoTransitionRange(value: boolean);
  37687. private _attachedCamera;
  37688. private _onAfterCheckInputsObserver;
  37689. private _onMeshTargetChangedObserver;
  37690. /**
  37691. * Initializes the behavior.
  37692. */
  37693. init(): void;
  37694. /**
  37695. * Attaches the behavior to its arc rotate camera.
  37696. * @param camera Defines the camera to attach the behavior to
  37697. */
  37698. attach(camera: ArcRotateCamera): void;
  37699. /**
  37700. * Detaches the behavior from its current arc rotate camera.
  37701. */
  37702. detach(): void;
  37703. private _radiusIsAnimating;
  37704. private _radiusBounceTransition;
  37705. private _animatables;
  37706. private _cachedWheelPrecision;
  37707. /**
  37708. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37709. * @param radiusLimit The limit to check against.
  37710. * @return Bool to indicate if at limit.
  37711. */
  37712. private _isRadiusAtLimit;
  37713. /**
  37714. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37715. * @param radiusDelta The delta by which to animate to. Can be negative.
  37716. */
  37717. private _applyBoundRadiusAnimation;
  37718. /**
  37719. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37720. */
  37721. protected _clearAnimationLocks(): void;
  37722. /**
  37723. * Stops and removes all animations that have been applied to the camera
  37724. */
  37725. stopAllAnimations(): void;
  37726. }
  37727. }
  37728. declare module BABYLON {
  37729. /**
  37730. * 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.
  37731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37732. */
  37733. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37734. /**
  37735. * Gets the name of the behavior.
  37736. */
  37737. get name(): string;
  37738. private _mode;
  37739. private _radiusScale;
  37740. private _positionScale;
  37741. private _defaultElevation;
  37742. private _elevationReturnTime;
  37743. private _elevationReturnWaitTime;
  37744. private _zoomStopsAnimation;
  37745. private _framingTime;
  37746. /**
  37747. * The easing function used by animations
  37748. */
  37749. static EasingFunction: ExponentialEase;
  37750. /**
  37751. * The easing mode used by animations
  37752. */
  37753. static EasingMode: number;
  37754. /**
  37755. * Sets the current mode used by the behavior
  37756. */
  37757. set mode(mode: number);
  37758. /**
  37759. * Gets current mode used by the behavior.
  37760. */
  37761. get mode(): number;
  37762. /**
  37763. * Sets the scale applied to the radius (1 by default)
  37764. */
  37765. set radiusScale(radius: number);
  37766. /**
  37767. * Gets the scale applied to the radius
  37768. */
  37769. get radiusScale(): number;
  37770. /**
  37771. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37772. */
  37773. set positionScale(scale: number);
  37774. /**
  37775. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37776. */
  37777. get positionScale(): number;
  37778. /**
  37779. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37780. * behaviour is triggered, in radians.
  37781. */
  37782. set defaultElevation(elevation: number);
  37783. /**
  37784. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37785. * behaviour is triggered, in radians.
  37786. */
  37787. get defaultElevation(): number;
  37788. /**
  37789. * Sets the time (in milliseconds) taken to return to the default beta position.
  37790. * Negative value indicates camera should not return to default.
  37791. */
  37792. set elevationReturnTime(speed: number);
  37793. /**
  37794. * Gets the time (in milliseconds) taken to return to the default beta position.
  37795. * Negative value indicates camera should not return to default.
  37796. */
  37797. get elevationReturnTime(): number;
  37798. /**
  37799. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37800. */
  37801. set elevationReturnWaitTime(time: number);
  37802. /**
  37803. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37804. */
  37805. get elevationReturnWaitTime(): number;
  37806. /**
  37807. * Sets the flag that indicates if user zooming should stop animation.
  37808. */
  37809. set zoomStopsAnimation(flag: boolean);
  37810. /**
  37811. * Gets the flag that indicates if user zooming should stop animation.
  37812. */
  37813. get zoomStopsAnimation(): boolean;
  37814. /**
  37815. * Sets the transition time when framing the mesh, in milliseconds
  37816. */
  37817. set framingTime(time: number);
  37818. /**
  37819. * Gets the transition time when framing the mesh, in milliseconds
  37820. */
  37821. get framingTime(): number;
  37822. /**
  37823. * Define if the behavior should automatically change the configured
  37824. * camera limits and sensibilities.
  37825. */
  37826. autoCorrectCameraLimitsAndSensibility: boolean;
  37827. private _onPrePointerObservableObserver;
  37828. private _onAfterCheckInputsObserver;
  37829. private _onMeshTargetChangedObserver;
  37830. private _attachedCamera;
  37831. private _isPointerDown;
  37832. private _lastInteractionTime;
  37833. /**
  37834. * Initializes the behavior.
  37835. */
  37836. init(): void;
  37837. /**
  37838. * Attaches the behavior to its arc rotate camera.
  37839. * @param camera Defines the camera to attach the behavior to
  37840. */
  37841. attach(camera: ArcRotateCamera): void;
  37842. /**
  37843. * Detaches the behavior from its current arc rotate camera.
  37844. */
  37845. detach(): void;
  37846. private _animatables;
  37847. private _betaIsAnimating;
  37848. private _betaTransition;
  37849. private _radiusTransition;
  37850. private _vectorTransition;
  37851. /**
  37852. * Targets the given mesh and updates zoom level accordingly.
  37853. * @param mesh The mesh to target.
  37854. * @param radius Optional. If a cached radius position already exists, overrides default.
  37855. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37856. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37857. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37858. */
  37859. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37860. /**
  37861. * Targets the given mesh with its children and updates zoom level accordingly.
  37862. * @param mesh The mesh to target.
  37863. * @param radius Optional. If a cached radius position already exists, overrides default.
  37864. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37865. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37866. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37867. */
  37868. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37869. /**
  37870. * Targets the given meshes with their children and updates zoom level accordingly.
  37871. * @param meshes The mesh to target.
  37872. * @param radius Optional. If a cached radius position already exists, overrides default.
  37873. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37874. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37875. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37876. */
  37877. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37878. /**
  37879. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37880. * @param minimumWorld Determines the smaller position of the bounding box extend
  37881. * @param maximumWorld Determines the bigger position of the bounding box extend
  37882. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37883. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37884. */
  37885. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37886. /**
  37887. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37888. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37889. * frustum width.
  37890. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37891. * to fully enclose the mesh in the viewing frustum.
  37892. */
  37893. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37894. /**
  37895. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37896. * is automatically returned to its default position (expected to be above ground plane).
  37897. */
  37898. private _maintainCameraAboveGround;
  37899. /**
  37900. * Returns the frustum slope based on the canvas ratio and camera FOV
  37901. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37902. */
  37903. private _getFrustumSlope;
  37904. /**
  37905. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37906. */
  37907. private _clearAnimationLocks;
  37908. /**
  37909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37910. */
  37911. private _applyUserInteraction;
  37912. /**
  37913. * Stops and removes all animations that have been applied to the camera
  37914. */
  37915. stopAllAnimations(): void;
  37916. /**
  37917. * Gets a value indicating if the user is moving the camera
  37918. */
  37919. get isUserIsMoving(): boolean;
  37920. /**
  37921. * The camera can move all the way towards the mesh.
  37922. */
  37923. static IgnoreBoundsSizeMode: number;
  37924. /**
  37925. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37926. */
  37927. static FitFrustumSidesMode: number;
  37928. }
  37929. }
  37930. declare module BABYLON {
  37931. /**
  37932. * Base class for Camera Pointer Inputs.
  37933. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37934. * for example usage.
  37935. */
  37936. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37937. /**
  37938. * Defines the camera the input is attached to.
  37939. */
  37940. abstract camera: Camera;
  37941. /**
  37942. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37943. */
  37944. protected _altKey: boolean;
  37945. protected _ctrlKey: boolean;
  37946. protected _metaKey: boolean;
  37947. protected _shiftKey: boolean;
  37948. /**
  37949. * Which mouse buttons were pressed at time of last mouse event.
  37950. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37951. */
  37952. protected _buttonsPressed: number;
  37953. /**
  37954. * Defines the buttons associated with the input to handle camera move.
  37955. */
  37956. buttons: number[];
  37957. /**
  37958. * Attach the input controls to a specific dom element to get the input from.
  37959. * @param element Defines the element the controls should be listened from
  37960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37961. */
  37962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37963. /**
  37964. * Detach the current controls from the specified dom element.
  37965. * @param element Defines the element to stop listening the inputs from
  37966. */
  37967. detachControl(element: Nullable<HTMLElement>): void;
  37968. /**
  37969. * Gets the class name of the current input.
  37970. * @returns the class name
  37971. */
  37972. getClassName(): string;
  37973. /**
  37974. * Get the friendly name associated with the input class.
  37975. * @returns the input friendly name
  37976. */
  37977. getSimpleName(): string;
  37978. /**
  37979. * Called on pointer POINTERDOUBLETAP event.
  37980. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37981. */
  37982. protected onDoubleTap(type: string): void;
  37983. /**
  37984. * Called on pointer POINTERMOVE event if only a single touch is active.
  37985. * Override this method to provide functionality.
  37986. */
  37987. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37988. /**
  37989. * Called on pointer POINTERMOVE event if multiple touches are active.
  37990. * Override this method to provide functionality.
  37991. */
  37992. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37993. /**
  37994. * Called on JS contextmenu event.
  37995. * Override this method to provide functionality.
  37996. */
  37997. protected onContextMenu(evt: PointerEvent): void;
  37998. /**
  37999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38000. * press.
  38001. * Override this method to provide functionality.
  38002. */
  38003. protected onButtonDown(evt: PointerEvent): void;
  38004. /**
  38005. * Called each time a new POINTERUP event occurs. Ie, for each button
  38006. * release.
  38007. * Override this method to provide functionality.
  38008. */
  38009. protected onButtonUp(evt: PointerEvent): void;
  38010. /**
  38011. * Called when window becomes inactive.
  38012. * Override this method to provide functionality.
  38013. */
  38014. protected onLostFocus(): void;
  38015. private _pointerInput;
  38016. private _observer;
  38017. private _onLostFocus;
  38018. private pointA;
  38019. private pointB;
  38020. }
  38021. }
  38022. declare module BABYLON {
  38023. /**
  38024. * Manage the pointers inputs to control an arc rotate camera.
  38025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38026. */
  38027. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38028. /**
  38029. * Defines the camera the input is attached to.
  38030. */
  38031. camera: ArcRotateCamera;
  38032. /**
  38033. * Gets the class name of the current input.
  38034. * @returns the class name
  38035. */
  38036. getClassName(): string;
  38037. /**
  38038. * Defines the buttons associated with the input to handle camera move.
  38039. */
  38040. buttons: number[];
  38041. /**
  38042. * Defines the pointer angular sensibility along the X axis or how fast is
  38043. * the camera rotating.
  38044. */
  38045. angularSensibilityX: number;
  38046. /**
  38047. * Defines the pointer angular sensibility along the Y axis or how fast is
  38048. * the camera rotating.
  38049. */
  38050. angularSensibilityY: number;
  38051. /**
  38052. * Defines the pointer pinch precision or how fast is the camera zooming.
  38053. */
  38054. pinchPrecision: number;
  38055. /**
  38056. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38057. * from 0.
  38058. * It defines the percentage of current camera.radius to use as delta when
  38059. * pinch zoom is used.
  38060. */
  38061. pinchDeltaPercentage: number;
  38062. /**
  38063. * Defines the pointer panning sensibility or how fast is the camera moving.
  38064. */
  38065. panningSensibility: number;
  38066. /**
  38067. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38068. */
  38069. multiTouchPanning: boolean;
  38070. /**
  38071. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38072. * zoom (pinch) through multitouch.
  38073. */
  38074. multiTouchPanAndZoom: boolean;
  38075. /**
  38076. * Revers pinch action direction.
  38077. */
  38078. pinchInwards: boolean;
  38079. private _isPanClick;
  38080. private _twoFingerActivityCount;
  38081. private _isPinching;
  38082. /**
  38083. * Called on pointer POINTERMOVE event if only a single touch is active.
  38084. */
  38085. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38086. /**
  38087. * Called on pointer POINTERDOUBLETAP event.
  38088. */
  38089. protected onDoubleTap(type: string): void;
  38090. /**
  38091. * Called on pointer POINTERMOVE event if multiple touches are active.
  38092. */
  38093. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38094. /**
  38095. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38096. * press.
  38097. */
  38098. protected onButtonDown(evt: PointerEvent): void;
  38099. /**
  38100. * Called each time a new POINTERUP event occurs. Ie, for each button
  38101. * release.
  38102. */
  38103. protected onButtonUp(evt: PointerEvent): void;
  38104. /**
  38105. * Called when window becomes inactive.
  38106. */
  38107. protected onLostFocus(): void;
  38108. }
  38109. }
  38110. declare module BABYLON {
  38111. /**
  38112. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38114. */
  38115. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38116. /**
  38117. * Defines the camera the input is attached to.
  38118. */
  38119. camera: ArcRotateCamera;
  38120. /**
  38121. * Defines the list of key codes associated with the up action (increase alpha)
  38122. */
  38123. keysUp: number[];
  38124. /**
  38125. * Defines the list of key codes associated with the down action (decrease alpha)
  38126. */
  38127. keysDown: number[];
  38128. /**
  38129. * Defines the list of key codes associated with the left action (increase beta)
  38130. */
  38131. keysLeft: number[];
  38132. /**
  38133. * Defines the list of key codes associated with the right action (decrease beta)
  38134. */
  38135. keysRight: number[];
  38136. /**
  38137. * Defines the list of key codes associated with the reset action.
  38138. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38139. */
  38140. keysReset: number[];
  38141. /**
  38142. * Defines the panning sensibility of the inputs.
  38143. * (How fast is the camera paning)
  38144. */
  38145. panningSensibility: number;
  38146. /**
  38147. * Defines the zooming sensibility of the inputs.
  38148. * (How fast is the camera zooming)
  38149. */
  38150. zoomingSensibility: number;
  38151. /**
  38152. * Defines wether maintaining the alt key down switch the movement mode from
  38153. * orientation to zoom.
  38154. */
  38155. useAltToZoom: boolean;
  38156. /**
  38157. * Rotation speed of the camera
  38158. */
  38159. angularSpeed: number;
  38160. private _keys;
  38161. private _ctrlPressed;
  38162. private _altPressed;
  38163. private _onCanvasBlurObserver;
  38164. private _onKeyboardObserver;
  38165. private _engine;
  38166. private _scene;
  38167. /**
  38168. * Attach the input controls to a specific dom element to get the input from.
  38169. * @param element Defines the element the controls should be listened from
  38170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38171. */
  38172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38173. /**
  38174. * Detach the current controls from the specified dom element.
  38175. * @param element Defines the element to stop listening the inputs from
  38176. */
  38177. detachControl(element: Nullable<HTMLElement>): void;
  38178. /**
  38179. * Update the current camera state depending on the inputs that have been used this frame.
  38180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38181. */
  38182. checkInputs(): void;
  38183. /**
  38184. * Gets the class name of the current intput.
  38185. * @returns the class name
  38186. */
  38187. getClassName(): string;
  38188. /**
  38189. * Get the friendly name associated with the input class.
  38190. * @returns the input friendly name
  38191. */
  38192. getSimpleName(): string;
  38193. }
  38194. }
  38195. declare module BABYLON {
  38196. /**
  38197. * Manage the mouse wheel inputs to control an arc rotate camera.
  38198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38199. */
  38200. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38201. /**
  38202. * Defines the camera the input is attached to.
  38203. */
  38204. camera: ArcRotateCamera;
  38205. /**
  38206. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38207. */
  38208. wheelPrecision: number;
  38209. /**
  38210. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38211. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38212. */
  38213. wheelDeltaPercentage: number;
  38214. private _wheel;
  38215. private _observer;
  38216. private computeDeltaFromMouseWheelLegacyEvent;
  38217. /**
  38218. * Attach the input controls to a specific dom element to get the input from.
  38219. * @param element Defines the element the controls should be listened from
  38220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38221. */
  38222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38223. /**
  38224. * Detach the current controls from the specified dom element.
  38225. * @param element Defines the element to stop listening the inputs from
  38226. */
  38227. detachControl(element: Nullable<HTMLElement>): void;
  38228. /**
  38229. * Gets the class name of the current intput.
  38230. * @returns the class name
  38231. */
  38232. getClassName(): string;
  38233. /**
  38234. * Get the friendly name associated with the input class.
  38235. * @returns the input friendly name
  38236. */
  38237. getSimpleName(): string;
  38238. }
  38239. }
  38240. declare module BABYLON {
  38241. /**
  38242. * Default Inputs manager for the ArcRotateCamera.
  38243. * It groups all the default supported inputs for ease of use.
  38244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38245. */
  38246. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38247. /**
  38248. * Instantiates a new ArcRotateCameraInputsManager.
  38249. * @param camera Defines the camera the inputs belong to
  38250. */
  38251. constructor(camera: ArcRotateCamera);
  38252. /**
  38253. * Add mouse wheel input support to the input manager.
  38254. * @returns the current input manager
  38255. */
  38256. addMouseWheel(): ArcRotateCameraInputsManager;
  38257. /**
  38258. * Add pointers input support to the input manager.
  38259. * @returns the current input manager
  38260. */
  38261. addPointers(): ArcRotateCameraInputsManager;
  38262. /**
  38263. * Add keyboard input support to the input manager.
  38264. * @returns the current input manager
  38265. */
  38266. addKeyboard(): ArcRotateCameraInputsManager;
  38267. }
  38268. }
  38269. declare module BABYLON {
  38270. /**
  38271. * This represents an orbital type of camera.
  38272. *
  38273. * 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.
  38274. * 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.
  38275. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38276. */
  38277. export class ArcRotateCamera extends TargetCamera {
  38278. /**
  38279. * Defines the rotation angle of the camera along the longitudinal axis.
  38280. */
  38281. alpha: number;
  38282. /**
  38283. * Defines the rotation angle of the camera along the latitudinal axis.
  38284. */
  38285. beta: number;
  38286. /**
  38287. * Defines the radius of the camera from it s target point.
  38288. */
  38289. radius: number;
  38290. protected _target: Vector3;
  38291. protected _targetHost: Nullable<AbstractMesh>;
  38292. /**
  38293. * Defines the target point of the camera.
  38294. * The camera looks towards it form the radius distance.
  38295. */
  38296. get target(): Vector3;
  38297. set target(value: Vector3);
  38298. /**
  38299. * Define the current local position of the camera in the scene
  38300. */
  38301. get position(): Vector3;
  38302. set position(newPosition: Vector3);
  38303. protected _upVector: Vector3;
  38304. protected _upToYMatrix: Matrix;
  38305. protected _YToUpMatrix: Matrix;
  38306. /**
  38307. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38308. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38309. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38310. */
  38311. set upVector(vec: Vector3);
  38312. get upVector(): Vector3;
  38313. /**
  38314. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38315. */
  38316. setMatUp(): void;
  38317. /**
  38318. * Current inertia value on the longitudinal axis.
  38319. * The bigger this number the longer it will take for the camera to stop.
  38320. */
  38321. inertialAlphaOffset: number;
  38322. /**
  38323. * Current inertia value on the latitudinal axis.
  38324. * The bigger this number the longer it will take for the camera to stop.
  38325. */
  38326. inertialBetaOffset: number;
  38327. /**
  38328. * Current inertia value on the radius axis.
  38329. * The bigger this number the longer it will take for the camera to stop.
  38330. */
  38331. inertialRadiusOffset: number;
  38332. /**
  38333. * Minimum allowed angle on the longitudinal axis.
  38334. * This can help limiting how the Camera is able to move in the scene.
  38335. */
  38336. lowerAlphaLimit: Nullable<number>;
  38337. /**
  38338. * Maximum allowed angle on the longitudinal axis.
  38339. * This can help limiting how the Camera is able to move in the scene.
  38340. */
  38341. upperAlphaLimit: Nullable<number>;
  38342. /**
  38343. * Minimum allowed angle on the latitudinal axis.
  38344. * This can help limiting how the Camera is able to move in the scene.
  38345. */
  38346. lowerBetaLimit: number;
  38347. /**
  38348. * Maximum allowed angle on the latitudinal axis.
  38349. * This can help limiting how the Camera is able to move in the scene.
  38350. */
  38351. upperBetaLimit: number;
  38352. /**
  38353. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38354. * This can help limiting how the Camera is able to move in the scene.
  38355. */
  38356. lowerRadiusLimit: Nullable<number>;
  38357. /**
  38358. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38359. * This can help limiting how the Camera is able to move in the scene.
  38360. */
  38361. upperRadiusLimit: Nullable<number>;
  38362. /**
  38363. * Defines the current inertia value used during panning of the camera along the X axis.
  38364. */
  38365. inertialPanningX: number;
  38366. /**
  38367. * Defines the current inertia value used during panning of the camera along the Y axis.
  38368. */
  38369. inertialPanningY: number;
  38370. /**
  38371. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38372. * Basically if your fingers moves away from more than this distance you will be considered
  38373. * in pinch mode.
  38374. */
  38375. pinchToPanMaxDistance: number;
  38376. /**
  38377. * Defines the maximum distance the camera can pan.
  38378. * This could help keeping the cammera always in your scene.
  38379. */
  38380. panningDistanceLimit: Nullable<number>;
  38381. /**
  38382. * Defines the target of the camera before paning.
  38383. */
  38384. panningOriginTarget: Vector3;
  38385. /**
  38386. * Defines the value of the inertia used during panning.
  38387. * 0 would mean stop inertia and one would mean no decelleration at all.
  38388. */
  38389. panningInertia: number;
  38390. /**
  38391. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38392. */
  38393. get angularSensibilityX(): number;
  38394. set angularSensibilityX(value: number);
  38395. /**
  38396. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38397. */
  38398. get angularSensibilityY(): number;
  38399. set angularSensibilityY(value: number);
  38400. /**
  38401. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38402. */
  38403. get pinchPrecision(): number;
  38404. set pinchPrecision(value: number);
  38405. /**
  38406. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38407. * It will be used instead of pinchDeltaPrecision if different from 0.
  38408. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38409. */
  38410. get pinchDeltaPercentage(): number;
  38411. set pinchDeltaPercentage(value: number);
  38412. /**
  38413. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38414. */
  38415. get panningSensibility(): number;
  38416. set panningSensibility(value: number);
  38417. /**
  38418. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38419. */
  38420. get keysUp(): number[];
  38421. set keysUp(value: number[]);
  38422. /**
  38423. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38424. */
  38425. get keysDown(): number[];
  38426. set keysDown(value: number[]);
  38427. /**
  38428. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38429. */
  38430. get keysLeft(): number[];
  38431. set keysLeft(value: number[]);
  38432. /**
  38433. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38434. */
  38435. get keysRight(): number[];
  38436. set keysRight(value: number[]);
  38437. /**
  38438. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38439. */
  38440. get wheelPrecision(): number;
  38441. set wheelPrecision(value: number);
  38442. /**
  38443. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38444. * It will be used instead of pinchDeltaPrecision if different from 0.
  38445. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38446. */
  38447. get wheelDeltaPercentage(): number;
  38448. set wheelDeltaPercentage(value: number);
  38449. /**
  38450. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38451. */
  38452. zoomOnFactor: number;
  38453. /**
  38454. * Defines a screen offset for the camera position.
  38455. */
  38456. targetScreenOffset: Vector2;
  38457. /**
  38458. * Allows the camera to be completely reversed.
  38459. * If false the camera can not arrive upside down.
  38460. */
  38461. allowUpsideDown: boolean;
  38462. /**
  38463. * Define if double tap/click is used to restore the previously saved state of the camera.
  38464. */
  38465. useInputToRestoreState: boolean;
  38466. /** @hidden */
  38467. _viewMatrix: Matrix;
  38468. /** @hidden */
  38469. _useCtrlForPanning: boolean;
  38470. /** @hidden */
  38471. _panningMouseButton: number;
  38472. /**
  38473. * Defines the input associated to the camera.
  38474. */
  38475. inputs: ArcRotateCameraInputsManager;
  38476. /** @hidden */
  38477. _reset: () => void;
  38478. /**
  38479. * Defines the allowed panning axis.
  38480. */
  38481. panningAxis: Vector3;
  38482. protected _localDirection: Vector3;
  38483. protected _transformedDirection: Vector3;
  38484. private _bouncingBehavior;
  38485. /**
  38486. * Gets the bouncing behavior of the camera if it has been enabled.
  38487. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38488. */
  38489. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38490. /**
  38491. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38493. */
  38494. get useBouncingBehavior(): boolean;
  38495. set useBouncingBehavior(value: boolean);
  38496. private _framingBehavior;
  38497. /**
  38498. * Gets the framing behavior of the camera if it has been enabled.
  38499. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38500. */
  38501. get framingBehavior(): Nullable<FramingBehavior>;
  38502. /**
  38503. * Defines if the framing behavior of the camera is enabled on the camera.
  38504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38505. */
  38506. get useFramingBehavior(): boolean;
  38507. set useFramingBehavior(value: boolean);
  38508. private _autoRotationBehavior;
  38509. /**
  38510. * Gets the auto rotation behavior of the camera if it has been enabled.
  38511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38512. */
  38513. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38514. /**
  38515. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38516. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38517. */
  38518. get useAutoRotationBehavior(): boolean;
  38519. set useAutoRotationBehavior(value: boolean);
  38520. /**
  38521. * Observable triggered when the mesh target has been changed on the camera.
  38522. */
  38523. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38524. /**
  38525. * Event raised when the camera is colliding with a mesh.
  38526. */
  38527. onCollide: (collidedMesh: AbstractMesh) => void;
  38528. /**
  38529. * Defines whether the camera should check collision with the objects oh the scene.
  38530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38531. */
  38532. checkCollisions: boolean;
  38533. /**
  38534. * Defines the collision radius of the camera.
  38535. * This simulates a sphere around the camera.
  38536. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38537. */
  38538. collisionRadius: Vector3;
  38539. protected _collider: Collider;
  38540. protected _previousPosition: Vector3;
  38541. protected _collisionVelocity: Vector3;
  38542. protected _newPosition: Vector3;
  38543. protected _previousAlpha: number;
  38544. protected _previousBeta: number;
  38545. protected _previousRadius: number;
  38546. protected _collisionTriggered: boolean;
  38547. protected _targetBoundingCenter: Nullable<Vector3>;
  38548. private _computationVector;
  38549. /**
  38550. * Instantiates a new ArcRotateCamera in a given scene
  38551. * @param name Defines the name of the camera
  38552. * @param alpha Defines the camera rotation along the logitudinal axis
  38553. * @param beta Defines the camera rotation along the latitudinal axis
  38554. * @param radius Defines the camera distance from its target
  38555. * @param target Defines the camera target
  38556. * @param scene Defines the scene the camera belongs to
  38557. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38558. */
  38559. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38560. /** @hidden */
  38561. _initCache(): void;
  38562. /** @hidden */
  38563. _updateCache(ignoreParentClass?: boolean): void;
  38564. protected _getTargetPosition(): Vector3;
  38565. private _storedAlpha;
  38566. private _storedBeta;
  38567. private _storedRadius;
  38568. private _storedTarget;
  38569. private _storedTargetScreenOffset;
  38570. /**
  38571. * Stores the current state of the camera (alpha, beta, radius and target)
  38572. * @returns the camera itself
  38573. */
  38574. storeState(): Camera;
  38575. /**
  38576. * @hidden
  38577. * Restored camera state. You must call storeState() first
  38578. */
  38579. _restoreStateValues(): boolean;
  38580. /** @hidden */
  38581. _isSynchronizedViewMatrix(): boolean;
  38582. /**
  38583. * Attached controls to the current camera.
  38584. * @param element Defines the element the controls should be listened from
  38585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38586. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38587. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38588. */
  38589. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38590. /**
  38591. * Detach the current controls from the camera.
  38592. * The camera will stop reacting to inputs.
  38593. * @param element Defines the element to stop listening the inputs from
  38594. */
  38595. detachControl(element: HTMLElement): void;
  38596. /** @hidden */
  38597. _checkInputs(): void;
  38598. protected _checkLimits(): void;
  38599. /**
  38600. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38601. */
  38602. rebuildAnglesAndRadius(): void;
  38603. /**
  38604. * Use a position to define the current camera related information like alpha, beta and radius
  38605. * @param position Defines the position to set the camera at
  38606. */
  38607. setPosition(position: Vector3): void;
  38608. /**
  38609. * Defines the target the camera should look at.
  38610. * This will automatically adapt alpha beta and radius to fit within the new target.
  38611. * @param target Defines the new target as a Vector or a mesh
  38612. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38613. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38614. */
  38615. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38616. /** @hidden */
  38617. _getViewMatrix(): Matrix;
  38618. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38619. /**
  38620. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38621. * @param meshes Defines the mesh to zoom on
  38622. * @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)
  38623. */
  38624. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38625. /**
  38626. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38627. * The target will be changed but the radius
  38628. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38629. * @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)
  38630. */
  38631. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38632. min: Vector3;
  38633. max: Vector3;
  38634. distance: number;
  38635. }, doNotUpdateMaxZ?: boolean): void;
  38636. /**
  38637. * @override
  38638. * Override Camera.createRigCamera
  38639. */
  38640. createRigCamera(name: string, cameraIndex: number): Camera;
  38641. /**
  38642. * @hidden
  38643. * @override
  38644. * Override Camera._updateRigCameras
  38645. */
  38646. _updateRigCameras(): void;
  38647. /**
  38648. * Destroy the camera and release the current resources hold by it.
  38649. */
  38650. dispose(): void;
  38651. /**
  38652. * Gets the current object class name.
  38653. * @return the class name
  38654. */
  38655. getClassName(): string;
  38656. }
  38657. }
  38658. declare module BABYLON {
  38659. /**
  38660. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38662. */
  38663. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38664. /**
  38665. * Gets the name of the behavior.
  38666. */
  38667. get name(): string;
  38668. private _zoomStopsAnimation;
  38669. private _idleRotationSpeed;
  38670. private _idleRotationWaitTime;
  38671. private _idleRotationSpinupTime;
  38672. /**
  38673. * Sets the flag that indicates if user zooming should stop animation.
  38674. */
  38675. set zoomStopsAnimation(flag: boolean);
  38676. /**
  38677. * Gets the flag that indicates if user zooming should stop animation.
  38678. */
  38679. get zoomStopsAnimation(): boolean;
  38680. /**
  38681. * Sets the default speed at which the camera rotates around the model.
  38682. */
  38683. set idleRotationSpeed(speed: number);
  38684. /**
  38685. * Gets the default speed at which the camera rotates around the model.
  38686. */
  38687. get idleRotationSpeed(): number;
  38688. /**
  38689. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38690. */
  38691. set idleRotationWaitTime(time: number);
  38692. /**
  38693. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38694. */
  38695. get idleRotationWaitTime(): number;
  38696. /**
  38697. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38698. */
  38699. set idleRotationSpinupTime(time: number);
  38700. /**
  38701. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38702. */
  38703. get idleRotationSpinupTime(): number;
  38704. /**
  38705. * Gets a value indicating if the camera is currently rotating because of this behavior
  38706. */
  38707. get rotationInProgress(): boolean;
  38708. private _onPrePointerObservableObserver;
  38709. private _onAfterCheckInputsObserver;
  38710. private _attachedCamera;
  38711. private _isPointerDown;
  38712. private _lastFrameTime;
  38713. private _lastInteractionTime;
  38714. private _cameraRotationSpeed;
  38715. /**
  38716. * Initializes the behavior.
  38717. */
  38718. init(): void;
  38719. /**
  38720. * Attaches the behavior to its arc rotate camera.
  38721. * @param camera Defines the camera to attach the behavior to
  38722. */
  38723. attach(camera: ArcRotateCamera): void;
  38724. /**
  38725. * Detaches the behavior from its current arc rotate camera.
  38726. */
  38727. detach(): void;
  38728. /**
  38729. * Returns true if user is scrolling.
  38730. * @return true if user is scrolling.
  38731. */
  38732. private _userIsZooming;
  38733. private _lastFrameRadius;
  38734. private _shouldAnimationStopForInteraction;
  38735. /**
  38736. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38737. */
  38738. private _applyUserInteraction;
  38739. private _userIsMoving;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /**
  38744. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38745. */
  38746. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38747. private ui;
  38748. /**
  38749. * The name of the behavior
  38750. */
  38751. name: string;
  38752. /**
  38753. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38754. */
  38755. distanceAwayFromFace: number;
  38756. /**
  38757. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38758. */
  38759. distanceAwayFromBottomOfFace: number;
  38760. private _faceVectors;
  38761. private _target;
  38762. private _scene;
  38763. private _onRenderObserver;
  38764. private _tmpMatrix;
  38765. private _tmpVector;
  38766. /**
  38767. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38768. * @param ui The transform node that should be attched to the mesh
  38769. */
  38770. constructor(ui: TransformNode);
  38771. /**
  38772. * Initializes the behavior
  38773. */
  38774. init(): void;
  38775. private _closestFace;
  38776. private _zeroVector;
  38777. private _lookAtTmpMatrix;
  38778. private _lookAtToRef;
  38779. /**
  38780. * Attaches the AttachToBoxBehavior to the passed in mesh
  38781. * @param target The mesh that the specified node will be attached to
  38782. */
  38783. attach(target: Mesh): void;
  38784. /**
  38785. * Detaches the behavior from the mesh
  38786. */
  38787. detach(): void;
  38788. }
  38789. }
  38790. declare module BABYLON {
  38791. /**
  38792. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38793. */
  38794. export class FadeInOutBehavior implements Behavior<Mesh> {
  38795. /**
  38796. * Time in milliseconds to delay before fading in (Default: 0)
  38797. */
  38798. delay: number;
  38799. /**
  38800. * Time in milliseconds for the mesh to fade in (Default: 300)
  38801. */
  38802. fadeInTime: number;
  38803. private _millisecondsPerFrame;
  38804. private _hovered;
  38805. private _hoverValue;
  38806. private _ownerNode;
  38807. /**
  38808. * Instatiates the FadeInOutBehavior
  38809. */
  38810. constructor();
  38811. /**
  38812. * The name of the behavior
  38813. */
  38814. get name(): string;
  38815. /**
  38816. * Initializes the behavior
  38817. */
  38818. init(): void;
  38819. /**
  38820. * Attaches the fade behavior on the passed in mesh
  38821. * @param ownerNode The mesh that will be faded in/out once attached
  38822. */
  38823. attach(ownerNode: Mesh): void;
  38824. /**
  38825. * Detaches the behavior from the mesh
  38826. */
  38827. detach(): void;
  38828. /**
  38829. * Triggers the mesh to begin fading in or out
  38830. * @param value if the object should fade in or out (true to fade in)
  38831. */
  38832. fadeIn(value: boolean): void;
  38833. private _update;
  38834. private _setAllVisibility;
  38835. }
  38836. }
  38837. declare module BABYLON {
  38838. /**
  38839. * Class containing a set of static utilities functions for managing Pivots
  38840. * @hidden
  38841. */
  38842. export class PivotTools {
  38843. private static _PivotCached;
  38844. private static _OldPivotPoint;
  38845. private static _PivotTranslation;
  38846. private static _PivotTmpVector;
  38847. /** @hidden */
  38848. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38849. /** @hidden */
  38850. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38851. }
  38852. }
  38853. declare module BABYLON {
  38854. /**
  38855. * Class containing static functions to help procedurally build meshes
  38856. */
  38857. export class PlaneBuilder {
  38858. /**
  38859. * Creates a plane mesh
  38860. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38861. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38862. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38864. * * 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
  38865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38866. * @param name defines the name of the mesh
  38867. * @param options defines the options used to create the mesh
  38868. * @param scene defines the hosting scene
  38869. * @returns the plane mesh
  38870. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38871. */
  38872. static CreatePlane(name: string, options: {
  38873. size?: number;
  38874. width?: number;
  38875. height?: number;
  38876. sideOrientation?: number;
  38877. frontUVs?: Vector4;
  38878. backUVs?: Vector4;
  38879. updatable?: boolean;
  38880. sourcePlane?: Plane;
  38881. }, scene?: Nullable<Scene>): Mesh;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /**
  38886. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38887. */
  38888. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38889. private static _AnyMouseID;
  38890. /**
  38891. * Abstract mesh the behavior is set on
  38892. */
  38893. attachedNode: AbstractMesh;
  38894. private _dragPlane;
  38895. private _scene;
  38896. private _pointerObserver;
  38897. private _beforeRenderObserver;
  38898. private static _planeScene;
  38899. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38900. /**
  38901. * 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)
  38902. */
  38903. maxDragAngle: number;
  38904. /**
  38905. * @hidden
  38906. */
  38907. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38908. /**
  38909. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38910. */
  38911. currentDraggingPointerID: number;
  38912. /**
  38913. * The last position where the pointer hit the drag plane in world space
  38914. */
  38915. lastDragPosition: Vector3;
  38916. /**
  38917. * If the behavior is currently in a dragging state
  38918. */
  38919. dragging: boolean;
  38920. /**
  38921. * 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)
  38922. */
  38923. dragDeltaRatio: number;
  38924. /**
  38925. * If the drag plane orientation should be updated during the dragging (Default: true)
  38926. */
  38927. updateDragPlane: boolean;
  38928. private _debugMode;
  38929. private _moving;
  38930. /**
  38931. * Fires each time the attached mesh is dragged with the pointer
  38932. * * delta between last drag position and current drag position in world space
  38933. * * dragDistance along the drag axis
  38934. * * dragPlaneNormal normal of the current drag plane used during the drag
  38935. * * dragPlanePoint in world space where the drag intersects the drag plane
  38936. */
  38937. onDragObservable: Observable<{
  38938. delta: Vector3;
  38939. dragPlanePoint: Vector3;
  38940. dragPlaneNormal: Vector3;
  38941. dragDistance: number;
  38942. pointerId: number;
  38943. }>;
  38944. /**
  38945. * Fires each time a drag begins (eg. mouse down on mesh)
  38946. */
  38947. onDragStartObservable: Observable<{
  38948. dragPlanePoint: Vector3;
  38949. pointerId: number;
  38950. }>;
  38951. /**
  38952. * Fires each time a drag ends (eg. mouse release after drag)
  38953. */
  38954. onDragEndObservable: Observable<{
  38955. dragPlanePoint: Vector3;
  38956. pointerId: number;
  38957. }>;
  38958. /**
  38959. * If the attached mesh should be moved when dragged
  38960. */
  38961. moveAttached: boolean;
  38962. /**
  38963. * If the drag behavior will react to drag events (Default: true)
  38964. */
  38965. enabled: boolean;
  38966. /**
  38967. * If pointer events should start and release the drag (Default: true)
  38968. */
  38969. startAndReleaseDragOnPointerEvents: boolean;
  38970. /**
  38971. * If camera controls should be detached during the drag
  38972. */
  38973. detachCameraControls: boolean;
  38974. /**
  38975. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38976. */
  38977. useObjectOrientationForDragging: boolean;
  38978. private _options;
  38979. /**
  38980. * Gets the options used by the behavior
  38981. */
  38982. get options(): {
  38983. dragAxis?: Vector3;
  38984. dragPlaneNormal?: Vector3;
  38985. };
  38986. /**
  38987. * Sets the options used by the behavior
  38988. */
  38989. set options(options: {
  38990. dragAxis?: Vector3;
  38991. dragPlaneNormal?: Vector3;
  38992. });
  38993. /**
  38994. * Creates a pointer drag behavior that can be attached to a mesh
  38995. * @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)
  38996. */
  38997. constructor(options?: {
  38998. dragAxis?: Vector3;
  38999. dragPlaneNormal?: Vector3;
  39000. });
  39001. /**
  39002. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39003. */
  39004. validateDrag: (targetPosition: Vector3) => boolean;
  39005. /**
  39006. * The name of the behavior
  39007. */
  39008. get name(): string;
  39009. /**
  39010. * Initializes the behavior
  39011. */
  39012. init(): void;
  39013. private _tmpVector;
  39014. private _alternatePickedPoint;
  39015. private _worldDragAxis;
  39016. private _targetPosition;
  39017. private _attachedElement;
  39018. /**
  39019. * Attaches the drag behavior the passed in mesh
  39020. * @param ownerNode The mesh that will be dragged around once attached
  39021. * @param predicate Predicate to use for pick filtering
  39022. */
  39023. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39024. /**
  39025. * Force relase the drag action by code.
  39026. */
  39027. releaseDrag(): void;
  39028. private _startDragRay;
  39029. private _lastPointerRay;
  39030. /**
  39031. * Simulates the start of a pointer drag event on the behavior
  39032. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39033. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39034. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39035. */
  39036. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39037. private _startDrag;
  39038. private _dragDelta;
  39039. private _moveDrag;
  39040. private _pickWithRayOnDragPlane;
  39041. private _pointA;
  39042. private _pointB;
  39043. private _pointC;
  39044. private _lineA;
  39045. private _lineB;
  39046. private _localAxis;
  39047. private _lookAt;
  39048. private _updateDragPlanePosition;
  39049. /**
  39050. * Detaches the behavior from the mesh
  39051. */
  39052. detach(): void;
  39053. }
  39054. }
  39055. declare module BABYLON {
  39056. /**
  39057. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39058. */
  39059. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39060. private _dragBehaviorA;
  39061. private _dragBehaviorB;
  39062. private _startDistance;
  39063. private _initialScale;
  39064. private _targetScale;
  39065. private _ownerNode;
  39066. private _sceneRenderObserver;
  39067. /**
  39068. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39069. */
  39070. constructor();
  39071. /**
  39072. * The name of the behavior
  39073. */
  39074. get name(): string;
  39075. /**
  39076. * Initializes the behavior
  39077. */
  39078. init(): void;
  39079. private _getCurrentDistance;
  39080. /**
  39081. * Attaches the scale behavior the passed in mesh
  39082. * @param ownerNode The mesh that will be scaled around once attached
  39083. */
  39084. attach(ownerNode: Mesh): void;
  39085. /**
  39086. * Detaches the behavior from the mesh
  39087. */
  39088. detach(): void;
  39089. }
  39090. }
  39091. declare module BABYLON {
  39092. /**
  39093. * 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
  39094. */
  39095. export class SixDofDragBehavior implements Behavior<Mesh> {
  39096. private static _virtualScene;
  39097. private _ownerNode;
  39098. private _sceneRenderObserver;
  39099. private _scene;
  39100. private _targetPosition;
  39101. private _virtualOriginMesh;
  39102. private _virtualDragMesh;
  39103. private _pointerObserver;
  39104. private _moving;
  39105. private _startingOrientation;
  39106. /**
  39107. * 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)
  39108. */
  39109. private zDragFactor;
  39110. /**
  39111. * If the object should rotate to face the drag origin
  39112. */
  39113. rotateDraggedObject: boolean;
  39114. /**
  39115. * If the behavior is currently in a dragging state
  39116. */
  39117. dragging: boolean;
  39118. /**
  39119. * 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)
  39120. */
  39121. dragDeltaRatio: number;
  39122. /**
  39123. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39124. */
  39125. currentDraggingPointerID: number;
  39126. /**
  39127. * If camera controls should be detached during the drag
  39128. */
  39129. detachCameraControls: boolean;
  39130. /**
  39131. * Fires each time a drag starts
  39132. */
  39133. onDragStartObservable: Observable<{}>;
  39134. /**
  39135. * Fires each time a drag ends (eg. mouse release after drag)
  39136. */
  39137. onDragEndObservable: Observable<{}>;
  39138. /**
  39139. * 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
  39140. */
  39141. constructor();
  39142. /**
  39143. * The name of the behavior
  39144. */
  39145. get name(): string;
  39146. /**
  39147. * Initializes the behavior
  39148. */
  39149. init(): void;
  39150. /**
  39151. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39152. */
  39153. private get _pointerCamera();
  39154. /**
  39155. * Attaches the scale behavior the passed in mesh
  39156. * @param ownerNode The mesh that will be scaled around once attached
  39157. */
  39158. attach(ownerNode: Mesh): void;
  39159. /**
  39160. * Detaches the behavior from the mesh
  39161. */
  39162. detach(): void;
  39163. }
  39164. }
  39165. declare module BABYLON {
  39166. /**
  39167. * Class used to apply inverse kinematics to bones
  39168. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39169. */
  39170. export class BoneIKController {
  39171. private static _tmpVecs;
  39172. private static _tmpQuat;
  39173. private static _tmpMats;
  39174. /**
  39175. * Gets or sets the target mesh
  39176. */
  39177. targetMesh: AbstractMesh;
  39178. /** Gets or sets the mesh used as pole */
  39179. poleTargetMesh: AbstractMesh;
  39180. /**
  39181. * Gets or sets the bone used as pole
  39182. */
  39183. poleTargetBone: Nullable<Bone>;
  39184. /**
  39185. * Gets or sets the target position
  39186. */
  39187. targetPosition: Vector3;
  39188. /**
  39189. * Gets or sets the pole target position
  39190. */
  39191. poleTargetPosition: Vector3;
  39192. /**
  39193. * Gets or sets the pole target local offset
  39194. */
  39195. poleTargetLocalOffset: Vector3;
  39196. /**
  39197. * Gets or sets the pole angle
  39198. */
  39199. poleAngle: number;
  39200. /**
  39201. * Gets or sets the mesh associated with the controller
  39202. */
  39203. mesh: AbstractMesh;
  39204. /**
  39205. * 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)
  39206. */
  39207. slerpAmount: number;
  39208. private _bone1Quat;
  39209. private _bone1Mat;
  39210. private _bone2Ang;
  39211. private _bone1;
  39212. private _bone2;
  39213. private _bone1Length;
  39214. private _bone2Length;
  39215. private _maxAngle;
  39216. private _maxReach;
  39217. private _rightHandedSystem;
  39218. private _bendAxis;
  39219. private _slerping;
  39220. private _adjustRoll;
  39221. /**
  39222. * Gets or sets maximum allowed angle
  39223. */
  39224. get maxAngle(): number;
  39225. set maxAngle(value: number);
  39226. /**
  39227. * Creates a new BoneIKController
  39228. * @param mesh defines the mesh to control
  39229. * @param bone defines the bone to control
  39230. * @param options defines options to set up the controller
  39231. */
  39232. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39233. targetMesh?: AbstractMesh;
  39234. poleTargetMesh?: AbstractMesh;
  39235. poleTargetBone?: Bone;
  39236. poleTargetLocalOffset?: Vector3;
  39237. poleAngle?: number;
  39238. bendAxis?: Vector3;
  39239. maxAngle?: number;
  39240. slerpAmount?: number;
  39241. });
  39242. private _setMaxAngle;
  39243. /**
  39244. * Force the controller to update the bones
  39245. */
  39246. update(): void;
  39247. }
  39248. }
  39249. declare module BABYLON {
  39250. /**
  39251. * Class used to make a bone look toward a point in space
  39252. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39253. */
  39254. export class BoneLookController {
  39255. private static _tmpVecs;
  39256. private static _tmpQuat;
  39257. private static _tmpMats;
  39258. /**
  39259. * The target Vector3 that the bone will look at
  39260. */
  39261. target: Vector3;
  39262. /**
  39263. * The mesh that the bone is attached to
  39264. */
  39265. mesh: AbstractMesh;
  39266. /**
  39267. * The bone that will be looking to the target
  39268. */
  39269. bone: Bone;
  39270. /**
  39271. * The up axis of the coordinate system that is used when the bone is rotated
  39272. */
  39273. upAxis: Vector3;
  39274. /**
  39275. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39276. */
  39277. upAxisSpace: Space;
  39278. /**
  39279. * Used to make an adjustment to the yaw of the bone
  39280. */
  39281. adjustYaw: number;
  39282. /**
  39283. * Used to make an adjustment to the pitch of the bone
  39284. */
  39285. adjustPitch: number;
  39286. /**
  39287. * Used to make an adjustment to the roll of the bone
  39288. */
  39289. adjustRoll: number;
  39290. /**
  39291. * 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)
  39292. */
  39293. slerpAmount: number;
  39294. private _minYaw;
  39295. private _maxYaw;
  39296. private _minPitch;
  39297. private _maxPitch;
  39298. private _minYawSin;
  39299. private _minYawCos;
  39300. private _maxYawSin;
  39301. private _maxYawCos;
  39302. private _midYawConstraint;
  39303. private _minPitchTan;
  39304. private _maxPitchTan;
  39305. private _boneQuat;
  39306. private _slerping;
  39307. private _transformYawPitch;
  39308. private _transformYawPitchInv;
  39309. private _firstFrameSkipped;
  39310. private _yawRange;
  39311. private _fowardAxis;
  39312. /**
  39313. * Gets or sets the minimum yaw angle that the bone can look to
  39314. */
  39315. get minYaw(): number;
  39316. set minYaw(value: number);
  39317. /**
  39318. * Gets or sets the maximum yaw angle that the bone can look to
  39319. */
  39320. get maxYaw(): number;
  39321. set maxYaw(value: number);
  39322. /**
  39323. * Gets or sets the minimum pitch angle that the bone can look to
  39324. */
  39325. get minPitch(): number;
  39326. set minPitch(value: number);
  39327. /**
  39328. * Gets or sets the maximum pitch angle that the bone can look to
  39329. */
  39330. get maxPitch(): number;
  39331. set maxPitch(value: number);
  39332. /**
  39333. * Create a BoneLookController
  39334. * @param mesh the mesh that the bone belongs to
  39335. * @param bone the bone that will be looking to the target
  39336. * @param target the target Vector3 to look at
  39337. * @param options optional settings:
  39338. * * maxYaw: the maximum angle the bone will yaw to
  39339. * * minYaw: the minimum angle the bone will yaw to
  39340. * * maxPitch: the maximum angle the bone will pitch to
  39341. * * minPitch: the minimum angle the bone will yaw to
  39342. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39343. * * upAxis: the up axis of the coordinate system
  39344. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39345. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39346. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39347. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39348. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39349. * * adjustRoll: used to make an adjustment to the roll of the bone
  39350. **/
  39351. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39352. maxYaw?: number;
  39353. minYaw?: number;
  39354. maxPitch?: number;
  39355. minPitch?: number;
  39356. slerpAmount?: number;
  39357. upAxis?: Vector3;
  39358. upAxisSpace?: Space;
  39359. yawAxis?: Vector3;
  39360. pitchAxis?: Vector3;
  39361. adjustYaw?: number;
  39362. adjustPitch?: number;
  39363. adjustRoll?: number;
  39364. });
  39365. /**
  39366. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39367. */
  39368. update(): void;
  39369. private _getAngleDiff;
  39370. private _getAngleBetween;
  39371. private _isAngleBetween;
  39372. }
  39373. }
  39374. declare module BABYLON {
  39375. /**
  39376. * Manage the gamepad inputs to control an arc rotate camera.
  39377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39378. */
  39379. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39380. /**
  39381. * Defines the camera the input is attached to.
  39382. */
  39383. camera: ArcRotateCamera;
  39384. /**
  39385. * Defines the gamepad the input is gathering event from.
  39386. */
  39387. gamepad: Nullable<Gamepad>;
  39388. /**
  39389. * Defines the gamepad rotation sensiblity.
  39390. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39391. */
  39392. gamepadRotationSensibility: number;
  39393. /**
  39394. * Defines the gamepad move sensiblity.
  39395. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39396. */
  39397. gamepadMoveSensibility: number;
  39398. private _yAxisScale;
  39399. /**
  39400. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39401. */
  39402. get invertYAxis(): boolean;
  39403. set invertYAxis(value: boolean);
  39404. private _onGamepadConnectedObserver;
  39405. private _onGamepadDisconnectedObserver;
  39406. /**
  39407. * Attach the input controls to a specific dom element to get the input from.
  39408. * @param element Defines the element the controls should be listened from
  39409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39410. */
  39411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39412. /**
  39413. * Detach the current controls from the specified dom element.
  39414. * @param element Defines the element to stop listening the inputs from
  39415. */
  39416. detachControl(element: Nullable<HTMLElement>): void;
  39417. /**
  39418. * Update the current camera state depending on the inputs that have been used this frame.
  39419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39420. */
  39421. checkInputs(): void;
  39422. /**
  39423. * Gets the class name of the current intput.
  39424. * @returns the class name
  39425. */
  39426. getClassName(): string;
  39427. /**
  39428. * Get the friendly name associated with the input class.
  39429. * @returns the input friendly name
  39430. */
  39431. getSimpleName(): string;
  39432. }
  39433. }
  39434. declare module BABYLON {
  39435. interface ArcRotateCameraInputsManager {
  39436. /**
  39437. * Add orientation input support to the input manager.
  39438. * @returns the current input manager
  39439. */
  39440. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39441. }
  39442. /**
  39443. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39445. */
  39446. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39447. /**
  39448. * Defines the camera the input is attached to.
  39449. */
  39450. camera: ArcRotateCamera;
  39451. /**
  39452. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39453. */
  39454. alphaCorrection: number;
  39455. /**
  39456. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39457. */
  39458. gammaCorrection: number;
  39459. private _alpha;
  39460. private _gamma;
  39461. private _dirty;
  39462. private _deviceOrientationHandler;
  39463. /**
  39464. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39465. */
  39466. constructor();
  39467. /**
  39468. * Attach the input controls to a specific dom element to get the input from.
  39469. * @param element Defines the element the controls should be listened from
  39470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39471. */
  39472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39473. /** @hidden */
  39474. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39475. /**
  39476. * Update the current camera state depending on the inputs that have been used this frame.
  39477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39478. */
  39479. checkInputs(): void;
  39480. /**
  39481. * Detach the current controls from the specified dom element.
  39482. * @param element Defines the element to stop listening the inputs from
  39483. */
  39484. detachControl(element: Nullable<HTMLElement>): void;
  39485. /**
  39486. * Gets the class name of the current intput.
  39487. * @returns the class name
  39488. */
  39489. getClassName(): string;
  39490. /**
  39491. * Get the friendly name associated with the input class.
  39492. * @returns the input friendly name
  39493. */
  39494. getSimpleName(): string;
  39495. }
  39496. }
  39497. declare module BABYLON {
  39498. /**
  39499. * Listen to mouse events to control the camera.
  39500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39501. */
  39502. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39503. /**
  39504. * Defines the camera the input is attached to.
  39505. */
  39506. camera: FlyCamera;
  39507. /**
  39508. * Defines if touch is enabled. (Default is true.)
  39509. */
  39510. touchEnabled: boolean;
  39511. /**
  39512. * Defines the buttons associated with the input to handle camera rotation.
  39513. */
  39514. buttons: number[];
  39515. /**
  39516. * Assign buttons for Yaw control.
  39517. */
  39518. buttonsYaw: number[];
  39519. /**
  39520. * Assign buttons for Pitch control.
  39521. */
  39522. buttonsPitch: number[];
  39523. /**
  39524. * Assign buttons for Roll control.
  39525. */
  39526. buttonsRoll: number[];
  39527. /**
  39528. * Detect if any button is being pressed while mouse is moved.
  39529. * -1 = Mouse locked.
  39530. * 0 = Left button.
  39531. * 1 = Middle Button.
  39532. * 2 = Right Button.
  39533. */
  39534. activeButton: number;
  39535. /**
  39536. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39537. * Higher values reduce its sensitivity.
  39538. */
  39539. angularSensibility: number;
  39540. private _mousemoveCallback;
  39541. private _observer;
  39542. private _rollObserver;
  39543. private previousPosition;
  39544. private noPreventDefault;
  39545. private element;
  39546. /**
  39547. * Listen to mouse events to control the camera.
  39548. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39550. */
  39551. constructor(touchEnabled?: boolean);
  39552. /**
  39553. * Attach the mouse control to the HTML DOM element.
  39554. * @param element Defines the element that listens to the input events.
  39555. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39556. */
  39557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39558. /**
  39559. * Detach the current controls from the specified dom element.
  39560. * @param element Defines the element to stop listening the inputs from
  39561. */
  39562. detachControl(element: Nullable<HTMLElement>): void;
  39563. /**
  39564. * Gets the class name of the current input.
  39565. * @returns the class name.
  39566. */
  39567. getClassName(): string;
  39568. /**
  39569. * Get the friendly name associated with the input class.
  39570. * @returns the input's friendly name.
  39571. */
  39572. getSimpleName(): string;
  39573. private _pointerInput;
  39574. private _onMouseMove;
  39575. /**
  39576. * Rotate camera by mouse offset.
  39577. */
  39578. private rotateCamera;
  39579. }
  39580. }
  39581. declare module BABYLON {
  39582. /**
  39583. * Default Inputs manager for the FlyCamera.
  39584. * It groups all the default supported inputs for ease of use.
  39585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39586. */
  39587. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39588. /**
  39589. * Instantiates a new FlyCameraInputsManager.
  39590. * @param camera Defines the camera the inputs belong to.
  39591. */
  39592. constructor(camera: FlyCamera);
  39593. /**
  39594. * Add keyboard input support to the input manager.
  39595. * @returns the new FlyCameraKeyboardMoveInput().
  39596. */
  39597. addKeyboard(): FlyCameraInputsManager;
  39598. /**
  39599. * Add mouse input support to the input manager.
  39600. * @param touchEnabled Enable touch screen support.
  39601. * @returns the new FlyCameraMouseInput().
  39602. */
  39603. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39604. }
  39605. }
  39606. declare module BABYLON {
  39607. /**
  39608. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39609. * such as in a 3D Space Shooter or a Flight Simulator.
  39610. */
  39611. export class FlyCamera extends TargetCamera {
  39612. /**
  39613. * Define the collision ellipsoid of the camera.
  39614. * This is helpful for simulating a camera body, like a player's body.
  39615. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39616. */
  39617. ellipsoid: Vector3;
  39618. /**
  39619. * Define an offset for the position of the ellipsoid around the camera.
  39620. * This can be helpful if the camera is attached away from the player's body center,
  39621. * such as at its head.
  39622. */
  39623. ellipsoidOffset: Vector3;
  39624. /**
  39625. * Enable or disable collisions of the camera with the rest of the scene objects.
  39626. */
  39627. checkCollisions: boolean;
  39628. /**
  39629. * Enable or disable gravity on the camera.
  39630. */
  39631. applyGravity: boolean;
  39632. /**
  39633. * Define the current direction the camera is moving to.
  39634. */
  39635. cameraDirection: Vector3;
  39636. /**
  39637. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39638. * This overrides and empties cameraRotation.
  39639. */
  39640. rotationQuaternion: Quaternion;
  39641. /**
  39642. * Track Roll to maintain the wanted Rolling when looking around.
  39643. */
  39644. _trackRoll: number;
  39645. /**
  39646. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39647. */
  39648. rollCorrect: number;
  39649. /**
  39650. * Mimic a banked turn, Rolling the camera when Yawing.
  39651. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39652. */
  39653. bankedTurn: boolean;
  39654. /**
  39655. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39656. */
  39657. bankedTurnLimit: number;
  39658. /**
  39659. * Value of 0 disables the banked Roll.
  39660. * Value of 1 is equal to the Yaw angle in radians.
  39661. */
  39662. bankedTurnMultiplier: number;
  39663. /**
  39664. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39665. */
  39666. inputs: FlyCameraInputsManager;
  39667. /**
  39668. * Gets the input sensibility for mouse input.
  39669. * Higher values reduce sensitivity.
  39670. */
  39671. get angularSensibility(): number;
  39672. /**
  39673. * Sets the input sensibility for a mouse input.
  39674. * Higher values reduce sensitivity.
  39675. */
  39676. set angularSensibility(value: number);
  39677. /**
  39678. * Get the keys for camera movement forward.
  39679. */
  39680. get keysForward(): number[];
  39681. /**
  39682. * Set the keys for camera movement forward.
  39683. */
  39684. set keysForward(value: number[]);
  39685. /**
  39686. * Get the keys for camera movement backward.
  39687. */
  39688. get keysBackward(): number[];
  39689. set keysBackward(value: number[]);
  39690. /**
  39691. * Get the keys for camera movement up.
  39692. */
  39693. get keysUp(): number[];
  39694. /**
  39695. * Set the keys for camera movement up.
  39696. */
  39697. set keysUp(value: number[]);
  39698. /**
  39699. * Get the keys for camera movement down.
  39700. */
  39701. get keysDown(): number[];
  39702. /**
  39703. * Set the keys for camera movement down.
  39704. */
  39705. set keysDown(value: number[]);
  39706. /**
  39707. * Get the keys for camera movement left.
  39708. */
  39709. get keysLeft(): number[];
  39710. /**
  39711. * Set the keys for camera movement left.
  39712. */
  39713. set keysLeft(value: number[]);
  39714. /**
  39715. * Set the keys for camera movement right.
  39716. */
  39717. get keysRight(): number[];
  39718. /**
  39719. * Set the keys for camera movement right.
  39720. */
  39721. set keysRight(value: number[]);
  39722. /**
  39723. * Event raised when the camera collides with a mesh in the scene.
  39724. */
  39725. onCollide: (collidedMesh: AbstractMesh) => void;
  39726. private _collider;
  39727. private _needMoveForGravity;
  39728. private _oldPosition;
  39729. private _diffPosition;
  39730. private _newPosition;
  39731. /** @hidden */
  39732. _localDirection: Vector3;
  39733. /** @hidden */
  39734. _transformedDirection: Vector3;
  39735. /**
  39736. * Instantiates a FlyCamera.
  39737. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39738. * such as in a 3D Space Shooter or a Flight Simulator.
  39739. * @param name Define the name of the camera in the scene.
  39740. * @param position Define the starting position of the camera in the scene.
  39741. * @param scene Define the scene the camera belongs to.
  39742. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39743. */
  39744. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39745. /**
  39746. * Attach a control to the HTML DOM element.
  39747. * @param element Defines the element that listens to the input events.
  39748. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39749. */
  39750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39751. /**
  39752. * Detach a control from the HTML DOM element.
  39753. * The camera will stop reacting to that input.
  39754. * @param element Defines the element that listens to the input events.
  39755. */
  39756. detachControl(element: HTMLElement): void;
  39757. private _collisionMask;
  39758. /**
  39759. * Get the mask that the camera ignores in collision events.
  39760. */
  39761. get collisionMask(): number;
  39762. /**
  39763. * Set the mask that the camera ignores in collision events.
  39764. */
  39765. set collisionMask(mask: number);
  39766. /** @hidden */
  39767. _collideWithWorld(displacement: Vector3): void;
  39768. /** @hidden */
  39769. private _onCollisionPositionChange;
  39770. /** @hidden */
  39771. _checkInputs(): void;
  39772. /** @hidden */
  39773. _decideIfNeedsToMove(): boolean;
  39774. /** @hidden */
  39775. _updatePosition(): void;
  39776. /**
  39777. * Restore the Roll to its target value at the rate specified.
  39778. * @param rate - Higher means slower restoring.
  39779. * @hidden
  39780. */
  39781. restoreRoll(rate: number): void;
  39782. /**
  39783. * Destroy the camera and release the current resources held by it.
  39784. */
  39785. dispose(): void;
  39786. /**
  39787. * Get the current object class name.
  39788. * @returns the class name.
  39789. */
  39790. getClassName(): string;
  39791. }
  39792. }
  39793. declare module BABYLON {
  39794. /**
  39795. * Listen to keyboard events to control the camera.
  39796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39797. */
  39798. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39799. /**
  39800. * Defines the camera the input is attached to.
  39801. */
  39802. camera: FlyCamera;
  39803. /**
  39804. * The list of keyboard keys used to control the forward move of the camera.
  39805. */
  39806. keysForward: number[];
  39807. /**
  39808. * The list of keyboard keys used to control the backward move of the camera.
  39809. */
  39810. keysBackward: number[];
  39811. /**
  39812. * The list of keyboard keys used to control the forward move of the camera.
  39813. */
  39814. keysUp: number[];
  39815. /**
  39816. * The list of keyboard keys used to control the backward move of the camera.
  39817. */
  39818. keysDown: number[];
  39819. /**
  39820. * The list of keyboard keys used to control the right strafe move of the camera.
  39821. */
  39822. keysRight: number[];
  39823. /**
  39824. * The list of keyboard keys used to control the left strafe move of the camera.
  39825. */
  39826. keysLeft: number[];
  39827. private _keys;
  39828. private _onCanvasBlurObserver;
  39829. private _onKeyboardObserver;
  39830. private _engine;
  39831. private _scene;
  39832. /**
  39833. * Attach the input controls to a specific dom element to get the input from.
  39834. * @param element Defines the element the controls should be listened from
  39835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39836. */
  39837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39838. /**
  39839. * Detach the current controls from the specified dom element.
  39840. * @param element Defines the element to stop listening the inputs from
  39841. */
  39842. detachControl(element: Nullable<HTMLElement>): void;
  39843. /**
  39844. * Gets the class name of the current intput.
  39845. * @returns the class name
  39846. */
  39847. getClassName(): string;
  39848. /** @hidden */
  39849. _onLostFocus(e: FocusEvent): void;
  39850. /**
  39851. * Get the friendly name associated with the input class.
  39852. * @returns the input friendly name
  39853. */
  39854. getSimpleName(): string;
  39855. /**
  39856. * Update the current camera state depending on the inputs that have been used this frame.
  39857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39858. */
  39859. checkInputs(): void;
  39860. }
  39861. }
  39862. declare module BABYLON {
  39863. /**
  39864. * Manage the mouse wheel inputs to control a follow camera.
  39865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39866. */
  39867. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39868. /**
  39869. * Defines the camera the input is attached to.
  39870. */
  39871. camera: FollowCamera;
  39872. /**
  39873. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39874. */
  39875. axisControlRadius: boolean;
  39876. /**
  39877. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39878. */
  39879. axisControlHeight: boolean;
  39880. /**
  39881. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39882. */
  39883. axisControlRotation: boolean;
  39884. /**
  39885. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39886. * relation to mouseWheel events.
  39887. */
  39888. wheelPrecision: number;
  39889. /**
  39890. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39891. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39892. */
  39893. wheelDeltaPercentage: number;
  39894. private _wheel;
  39895. private _observer;
  39896. /**
  39897. * Attach the input controls to a specific dom element to get the input from.
  39898. * @param element Defines the element the controls should be listened from
  39899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39900. */
  39901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39902. /**
  39903. * Detach the current controls from the specified dom element.
  39904. * @param element Defines the element to stop listening the inputs from
  39905. */
  39906. detachControl(element: Nullable<HTMLElement>): void;
  39907. /**
  39908. * Gets the class name of the current intput.
  39909. * @returns the class name
  39910. */
  39911. getClassName(): string;
  39912. /**
  39913. * Get the friendly name associated with the input class.
  39914. * @returns the input friendly name
  39915. */
  39916. getSimpleName(): string;
  39917. }
  39918. }
  39919. declare module BABYLON {
  39920. /**
  39921. * Manage the pointers inputs to control an follow camera.
  39922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39923. */
  39924. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39925. /**
  39926. * Defines the camera the input is attached to.
  39927. */
  39928. camera: FollowCamera;
  39929. /**
  39930. * Gets the class name of the current input.
  39931. * @returns the class name
  39932. */
  39933. getClassName(): string;
  39934. /**
  39935. * Defines the pointer angular sensibility along the X axis or how fast is
  39936. * the camera rotating.
  39937. * A negative number will reverse the axis direction.
  39938. */
  39939. angularSensibilityX: number;
  39940. /**
  39941. * Defines the pointer angular sensibility along the Y axis or how fast is
  39942. * the camera rotating.
  39943. * A negative number will reverse the axis direction.
  39944. */
  39945. angularSensibilityY: number;
  39946. /**
  39947. * Defines the pointer pinch precision or how fast is the camera zooming.
  39948. * A negative number will reverse the axis direction.
  39949. */
  39950. pinchPrecision: number;
  39951. /**
  39952. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39953. * from 0.
  39954. * It defines the percentage of current camera.radius to use as delta when
  39955. * pinch zoom is used.
  39956. */
  39957. pinchDeltaPercentage: number;
  39958. /**
  39959. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39960. */
  39961. axisXControlRadius: boolean;
  39962. /**
  39963. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39964. */
  39965. axisXControlHeight: boolean;
  39966. /**
  39967. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39968. */
  39969. axisXControlRotation: boolean;
  39970. /**
  39971. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39972. */
  39973. axisYControlRadius: boolean;
  39974. /**
  39975. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39976. */
  39977. axisYControlHeight: boolean;
  39978. /**
  39979. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39980. */
  39981. axisYControlRotation: boolean;
  39982. /**
  39983. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39984. */
  39985. axisPinchControlRadius: boolean;
  39986. /**
  39987. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39988. */
  39989. axisPinchControlHeight: boolean;
  39990. /**
  39991. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39992. */
  39993. axisPinchControlRotation: boolean;
  39994. /**
  39995. * Log error messages if basic misconfiguration has occurred.
  39996. */
  39997. warningEnable: boolean;
  39998. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39999. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40000. private _warningCounter;
  40001. private _warning;
  40002. }
  40003. }
  40004. declare module BABYLON {
  40005. /**
  40006. * Default Inputs manager for the FollowCamera.
  40007. * It groups all the default supported inputs for ease of use.
  40008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40009. */
  40010. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40011. /**
  40012. * Instantiates a new FollowCameraInputsManager.
  40013. * @param camera Defines the camera the inputs belong to
  40014. */
  40015. constructor(camera: FollowCamera);
  40016. /**
  40017. * Add keyboard input support to the input manager.
  40018. * @returns the current input manager
  40019. */
  40020. addKeyboard(): FollowCameraInputsManager;
  40021. /**
  40022. * Add mouse wheel input support to the input manager.
  40023. * @returns the current input manager
  40024. */
  40025. addMouseWheel(): FollowCameraInputsManager;
  40026. /**
  40027. * Add pointers input support to the input manager.
  40028. * @returns the current input manager
  40029. */
  40030. addPointers(): FollowCameraInputsManager;
  40031. /**
  40032. * Add orientation input support to the input manager.
  40033. * @returns the current input manager
  40034. */
  40035. addVRDeviceOrientation(): FollowCameraInputsManager;
  40036. }
  40037. }
  40038. declare module BABYLON {
  40039. /**
  40040. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40041. * an arc rotate version arcFollowCamera are available.
  40042. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40043. */
  40044. export class FollowCamera extends TargetCamera {
  40045. /**
  40046. * Distance the follow camera should follow an object at
  40047. */
  40048. radius: number;
  40049. /**
  40050. * Minimum allowed distance of the camera to the axis of rotation
  40051. * (The camera can not get closer).
  40052. * This can help limiting how the Camera is able to move in the scene.
  40053. */
  40054. lowerRadiusLimit: Nullable<number>;
  40055. /**
  40056. * Maximum allowed distance of the camera to the axis of rotation
  40057. * (The camera can not get further).
  40058. * This can help limiting how the Camera is able to move in the scene.
  40059. */
  40060. upperRadiusLimit: Nullable<number>;
  40061. /**
  40062. * Define a rotation offset between the camera and the object it follows
  40063. */
  40064. rotationOffset: number;
  40065. /**
  40066. * Minimum allowed angle to camera position relative to target object.
  40067. * This can help limiting how the Camera is able to move in the scene.
  40068. */
  40069. lowerRotationOffsetLimit: Nullable<number>;
  40070. /**
  40071. * Maximum allowed angle to camera position relative to target object.
  40072. * This can help limiting how the Camera is able to move in the scene.
  40073. */
  40074. upperRotationOffsetLimit: Nullable<number>;
  40075. /**
  40076. * Define a height offset between the camera and the object it follows.
  40077. * It can help following an object from the top (like a car chaing a plane)
  40078. */
  40079. heightOffset: number;
  40080. /**
  40081. * Minimum allowed height of camera position relative to target object.
  40082. * This can help limiting how the Camera is able to move in the scene.
  40083. */
  40084. lowerHeightOffsetLimit: Nullable<number>;
  40085. /**
  40086. * Maximum allowed height of camera position relative to target object.
  40087. * This can help limiting how the Camera is able to move in the scene.
  40088. */
  40089. upperHeightOffsetLimit: Nullable<number>;
  40090. /**
  40091. * Define how fast the camera can accelerate to follow it s target.
  40092. */
  40093. cameraAcceleration: number;
  40094. /**
  40095. * Define the speed limit of the camera following an object.
  40096. */
  40097. maxCameraSpeed: number;
  40098. /**
  40099. * Define the target of the camera.
  40100. */
  40101. lockedTarget: Nullable<AbstractMesh>;
  40102. /**
  40103. * Defines the input associated with the camera.
  40104. */
  40105. inputs: FollowCameraInputsManager;
  40106. /**
  40107. * Instantiates the follow camera.
  40108. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40109. * @param name Define the name of the camera in the scene
  40110. * @param position Define the position of the camera
  40111. * @param scene Define the scene the camera belong to
  40112. * @param lockedTarget Define the target of the camera
  40113. */
  40114. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40115. private _follow;
  40116. /**
  40117. * Attached controls to the current camera.
  40118. * @param element Defines the element the controls should be listened from
  40119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40120. */
  40121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40122. /**
  40123. * Detach the current controls from the camera.
  40124. * The camera will stop reacting to inputs.
  40125. * @param element Defines the element to stop listening the inputs from
  40126. */
  40127. detachControl(element: HTMLElement): void;
  40128. /** @hidden */
  40129. _checkInputs(): void;
  40130. private _checkLimits;
  40131. /**
  40132. * Gets the camera class name.
  40133. * @returns the class name
  40134. */
  40135. getClassName(): string;
  40136. }
  40137. /**
  40138. * Arc Rotate version of the follow camera.
  40139. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40140. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40141. */
  40142. export class ArcFollowCamera extends TargetCamera {
  40143. /** The longitudinal angle of the camera */
  40144. alpha: number;
  40145. /** The latitudinal angle of the camera */
  40146. beta: number;
  40147. /** The radius of the camera from its target */
  40148. radius: number;
  40149. /** Define the camera target (the messh it should follow) */
  40150. target: Nullable<AbstractMesh>;
  40151. private _cartesianCoordinates;
  40152. /**
  40153. * Instantiates a new ArcFollowCamera
  40154. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40155. * @param name Define the name of the camera
  40156. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40157. * @param beta Define the rotation angle of the camera around the elevation axis
  40158. * @param radius Define the radius of the camera from its target point
  40159. * @param target Define the target of the camera
  40160. * @param scene Define the scene the camera belongs to
  40161. */
  40162. constructor(name: string,
  40163. /** The longitudinal angle of the camera */
  40164. alpha: number,
  40165. /** The latitudinal angle of the camera */
  40166. beta: number,
  40167. /** The radius of the camera from its target */
  40168. radius: number,
  40169. /** Define the camera target (the messh it should follow) */
  40170. target: Nullable<AbstractMesh>, scene: Scene);
  40171. private _follow;
  40172. /** @hidden */
  40173. _checkInputs(): void;
  40174. /**
  40175. * Returns the class name of the object.
  40176. * It is mostly used internally for serialization purposes.
  40177. */
  40178. getClassName(): string;
  40179. }
  40180. }
  40181. declare module BABYLON {
  40182. /**
  40183. * Manage the keyboard inputs to control the movement of a follow camera.
  40184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40185. */
  40186. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40187. /**
  40188. * Defines the camera the input is attached to.
  40189. */
  40190. camera: FollowCamera;
  40191. /**
  40192. * Defines the list of key codes associated with the up action (increase heightOffset)
  40193. */
  40194. keysHeightOffsetIncr: number[];
  40195. /**
  40196. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40197. */
  40198. keysHeightOffsetDecr: number[];
  40199. /**
  40200. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40201. */
  40202. keysHeightOffsetModifierAlt: boolean;
  40203. /**
  40204. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40205. */
  40206. keysHeightOffsetModifierCtrl: boolean;
  40207. /**
  40208. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40209. */
  40210. keysHeightOffsetModifierShift: boolean;
  40211. /**
  40212. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40213. */
  40214. keysRotationOffsetIncr: number[];
  40215. /**
  40216. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40217. */
  40218. keysRotationOffsetDecr: number[];
  40219. /**
  40220. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40221. */
  40222. keysRotationOffsetModifierAlt: boolean;
  40223. /**
  40224. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40225. */
  40226. keysRotationOffsetModifierCtrl: boolean;
  40227. /**
  40228. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40229. */
  40230. keysRotationOffsetModifierShift: boolean;
  40231. /**
  40232. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40233. */
  40234. keysRadiusIncr: number[];
  40235. /**
  40236. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40237. */
  40238. keysRadiusDecr: number[];
  40239. /**
  40240. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40241. */
  40242. keysRadiusModifierAlt: boolean;
  40243. /**
  40244. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40245. */
  40246. keysRadiusModifierCtrl: boolean;
  40247. /**
  40248. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40249. */
  40250. keysRadiusModifierShift: boolean;
  40251. /**
  40252. * Defines the rate of change of heightOffset.
  40253. */
  40254. heightSensibility: number;
  40255. /**
  40256. * Defines the rate of change of rotationOffset.
  40257. */
  40258. rotationSensibility: number;
  40259. /**
  40260. * Defines the rate of change of radius.
  40261. */
  40262. radiusSensibility: number;
  40263. private _keys;
  40264. private _ctrlPressed;
  40265. private _altPressed;
  40266. private _shiftPressed;
  40267. private _onCanvasBlurObserver;
  40268. private _onKeyboardObserver;
  40269. private _engine;
  40270. private _scene;
  40271. /**
  40272. * Attach the input controls to a specific dom element to get the input from.
  40273. * @param element Defines the element the controls should be listened from
  40274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40275. */
  40276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40277. /**
  40278. * Detach the current controls from the specified dom element.
  40279. * @param element Defines the element to stop listening the inputs from
  40280. */
  40281. detachControl(element: Nullable<HTMLElement>): void;
  40282. /**
  40283. * Update the current camera state depending on the inputs that have been used this frame.
  40284. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40285. */
  40286. checkInputs(): void;
  40287. /**
  40288. * Gets the class name of the current input.
  40289. * @returns the class name
  40290. */
  40291. getClassName(): string;
  40292. /**
  40293. * Get the friendly name associated with the input class.
  40294. * @returns the input friendly name
  40295. */
  40296. getSimpleName(): string;
  40297. /**
  40298. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40299. * allow modification of the heightOffset value.
  40300. */
  40301. private _modifierHeightOffset;
  40302. /**
  40303. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40304. * allow modification of the rotationOffset value.
  40305. */
  40306. private _modifierRotationOffset;
  40307. /**
  40308. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40309. * allow modification of the radius value.
  40310. */
  40311. private _modifierRadius;
  40312. }
  40313. }
  40314. declare module BABYLON {
  40315. interface FreeCameraInputsManager {
  40316. /**
  40317. * @hidden
  40318. */
  40319. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40320. /**
  40321. * Add orientation input support to the input manager.
  40322. * @returns the current input manager
  40323. */
  40324. addDeviceOrientation(): FreeCameraInputsManager;
  40325. }
  40326. /**
  40327. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40328. * Screen rotation is taken into account.
  40329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40330. */
  40331. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40332. private _camera;
  40333. private _screenOrientationAngle;
  40334. private _constantTranform;
  40335. private _screenQuaternion;
  40336. private _alpha;
  40337. private _beta;
  40338. private _gamma;
  40339. /**
  40340. * Can be used to detect if a device orientation sensor is available on a device
  40341. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40342. * @returns a promise that will resolve on orientation change
  40343. */
  40344. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40345. /**
  40346. * @hidden
  40347. */
  40348. _onDeviceOrientationChangedObservable: Observable<void>;
  40349. /**
  40350. * Instantiates a new input
  40351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40352. */
  40353. constructor();
  40354. /**
  40355. * Define the camera controlled by the input.
  40356. */
  40357. get camera(): FreeCamera;
  40358. set camera(camera: FreeCamera);
  40359. /**
  40360. * Attach the input controls to a specific dom element to get the input from.
  40361. * @param element Defines the element the controls should be listened from
  40362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40363. */
  40364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40365. private _orientationChanged;
  40366. private _deviceOrientation;
  40367. /**
  40368. * Detach the current controls from the specified dom element.
  40369. * @param element Defines the element to stop listening the inputs from
  40370. */
  40371. detachControl(element: Nullable<HTMLElement>): void;
  40372. /**
  40373. * Update the current camera state depending on the inputs that have been used this frame.
  40374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40375. */
  40376. checkInputs(): void;
  40377. /**
  40378. * Gets the class name of the current intput.
  40379. * @returns the class name
  40380. */
  40381. getClassName(): string;
  40382. /**
  40383. * Get the friendly name associated with the input class.
  40384. * @returns the input friendly name
  40385. */
  40386. getSimpleName(): string;
  40387. }
  40388. }
  40389. declare module BABYLON {
  40390. /**
  40391. * Manage the gamepad inputs to control a free camera.
  40392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40393. */
  40394. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40395. /**
  40396. * Define the camera the input is attached to.
  40397. */
  40398. camera: FreeCamera;
  40399. /**
  40400. * Define the Gamepad controlling the input
  40401. */
  40402. gamepad: Nullable<Gamepad>;
  40403. /**
  40404. * Defines the gamepad rotation sensiblity.
  40405. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40406. */
  40407. gamepadAngularSensibility: number;
  40408. /**
  40409. * Defines the gamepad move sensiblity.
  40410. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40411. */
  40412. gamepadMoveSensibility: number;
  40413. private _yAxisScale;
  40414. /**
  40415. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40416. */
  40417. get invertYAxis(): boolean;
  40418. set invertYAxis(value: boolean);
  40419. private _onGamepadConnectedObserver;
  40420. private _onGamepadDisconnectedObserver;
  40421. private _cameraTransform;
  40422. private _deltaTransform;
  40423. private _vector3;
  40424. private _vector2;
  40425. /**
  40426. * Attach the input controls to a specific dom element to get the input from.
  40427. * @param element Defines the element the controls should be listened from
  40428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40429. */
  40430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40431. /**
  40432. * Detach the current controls from the specified dom element.
  40433. * @param element Defines the element to stop listening the inputs from
  40434. */
  40435. detachControl(element: Nullable<HTMLElement>): void;
  40436. /**
  40437. * Update the current camera state depending on the inputs that have been used this frame.
  40438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40439. */
  40440. checkInputs(): void;
  40441. /**
  40442. * Gets the class name of the current intput.
  40443. * @returns the class name
  40444. */
  40445. getClassName(): string;
  40446. /**
  40447. * Get the friendly name associated with the input class.
  40448. * @returns the input friendly name
  40449. */
  40450. getSimpleName(): string;
  40451. }
  40452. }
  40453. declare module BABYLON {
  40454. /**
  40455. * Defines the potential axis of a Joystick
  40456. */
  40457. export enum JoystickAxis {
  40458. /** X axis */
  40459. X = 0,
  40460. /** Y axis */
  40461. Y = 1,
  40462. /** Z axis */
  40463. Z = 2
  40464. }
  40465. /**
  40466. * Class used to define virtual joystick (used in touch mode)
  40467. */
  40468. export class VirtualJoystick {
  40469. /**
  40470. * Gets or sets a boolean indicating that left and right values must be inverted
  40471. */
  40472. reverseLeftRight: boolean;
  40473. /**
  40474. * Gets or sets a boolean indicating that up and down values must be inverted
  40475. */
  40476. reverseUpDown: boolean;
  40477. /**
  40478. * Gets the offset value for the position (ie. the change of the position value)
  40479. */
  40480. deltaPosition: Vector3;
  40481. /**
  40482. * Gets a boolean indicating if the virtual joystick was pressed
  40483. */
  40484. pressed: boolean;
  40485. /**
  40486. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40487. */
  40488. static Canvas: Nullable<HTMLCanvasElement>;
  40489. private static _globalJoystickIndex;
  40490. private static vjCanvasContext;
  40491. private static vjCanvasWidth;
  40492. private static vjCanvasHeight;
  40493. private static halfWidth;
  40494. private _action;
  40495. private _axisTargetedByLeftAndRight;
  40496. private _axisTargetedByUpAndDown;
  40497. private _joystickSensibility;
  40498. private _inversedSensibility;
  40499. private _joystickPointerID;
  40500. private _joystickColor;
  40501. private _joystickPointerPos;
  40502. private _joystickPreviousPointerPos;
  40503. private _joystickPointerStartPos;
  40504. private _deltaJoystickVector;
  40505. private _leftJoystick;
  40506. private _touches;
  40507. private _onPointerDownHandlerRef;
  40508. private _onPointerMoveHandlerRef;
  40509. private _onPointerUpHandlerRef;
  40510. private _onResize;
  40511. /**
  40512. * Creates a new virtual joystick
  40513. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40514. */
  40515. constructor(leftJoystick?: boolean);
  40516. /**
  40517. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40518. * @param newJoystickSensibility defines the new sensibility
  40519. */
  40520. setJoystickSensibility(newJoystickSensibility: number): void;
  40521. private _onPointerDown;
  40522. private _onPointerMove;
  40523. private _onPointerUp;
  40524. /**
  40525. * Change the color of the virtual joystick
  40526. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40527. */
  40528. setJoystickColor(newColor: string): void;
  40529. /**
  40530. * Defines a callback to call when the joystick is touched
  40531. * @param action defines the callback
  40532. */
  40533. setActionOnTouch(action: () => any): void;
  40534. /**
  40535. * Defines which axis you'd like to control for left & right
  40536. * @param axis defines the axis to use
  40537. */
  40538. setAxisForLeftRight(axis: JoystickAxis): void;
  40539. /**
  40540. * Defines which axis you'd like to control for up & down
  40541. * @param axis defines the axis to use
  40542. */
  40543. setAxisForUpDown(axis: JoystickAxis): void;
  40544. private _drawVirtualJoystick;
  40545. /**
  40546. * Release internal HTML canvas
  40547. */
  40548. releaseCanvas(): void;
  40549. }
  40550. }
  40551. declare module BABYLON {
  40552. interface FreeCameraInputsManager {
  40553. /**
  40554. * Add virtual joystick input support to the input manager.
  40555. * @returns the current input manager
  40556. */
  40557. addVirtualJoystick(): FreeCameraInputsManager;
  40558. }
  40559. /**
  40560. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40562. */
  40563. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40564. /**
  40565. * Defines the camera the input is attached to.
  40566. */
  40567. camera: FreeCamera;
  40568. private _leftjoystick;
  40569. private _rightjoystick;
  40570. /**
  40571. * Gets the left stick of the virtual joystick.
  40572. * @returns The virtual Joystick
  40573. */
  40574. getLeftJoystick(): VirtualJoystick;
  40575. /**
  40576. * Gets the right stick of the virtual joystick.
  40577. * @returns The virtual Joystick
  40578. */
  40579. getRightJoystick(): VirtualJoystick;
  40580. /**
  40581. * Update the current camera state depending on the inputs that have been used this frame.
  40582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40583. */
  40584. checkInputs(): void;
  40585. /**
  40586. * Attach the input controls to a specific dom element to get the input from.
  40587. * @param element Defines the element the controls should be listened from
  40588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40589. */
  40590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40591. /**
  40592. * Detach the current controls from the specified dom element.
  40593. * @param element Defines the element to stop listening the inputs from
  40594. */
  40595. detachControl(element: Nullable<HTMLElement>): void;
  40596. /**
  40597. * Gets the class name of the current intput.
  40598. * @returns the class name
  40599. */
  40600. getClassName(): string;
  40601. /**
  40602. * Get the friendly name associated with the input class.
  40603. * @returns the input friendly name
  40604. */
  40605. getSimpleName(): string;
  40606. }
  40607. }
  40608. declare module BABYLON {
  40609. /**
  40610. * This represents a FPS type of camera controlled by touch.
  40611. * This is like a universal camera minus the Gamepad controls.
  40612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40613. */
  40614. export class TouchCamera extends FreeCamera {
  40615. /**
  40616. * Defines the touch sensibility for rotation.
  40617. * The higher the faster.
  40618. */
  40619. get touchAngularSensibility(): number;
  40620. set touchAngularSensibility(value: number);
  40621. /**
  40622. * Defines the touch sensibility for move.
  40623. * The higher the faster.
  40624. */
  40625. get touchMoveSensibility(): number;
  40626. set touchMoveSensibility(value: number);
  40627. /**
  40628. * Instantiates a new touch camera.
  40629. * This represents a FPS type of camera controlled by touch.
  40630. * This is like a universal camera minus the Gamepad controls.
  40631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40632. * @param name Define the name of the camera in the scene
  40633. * @param position Define the start position of the camera in the scene
  40634. * @param scene Define the scene the camera belongs to
  40635. */
  40636. constructor(name: string, position: Vector3, scene: Scene);
  40637. /**
  40638. * Gets the current object class name.
  40639. * @return the class name
  40640. */
  40641. getClassName(): string;
  40642. /** @hidden */
  40643. _setupInputs(): void;
  40644. }
  40645. }
  40646. declare module BABYLON {
  40647. /**
  40648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40649. * being tilted forward or back and left or right.
  40650. */
  40651. export class DeviceOrientationCamera extends FreeCamera {
  40652. private _initialQuaternion;
  40653. private _quaternionCache;
  40654. private _tmpDragQuaternion;
  40655. private _disablePointerInputWhenUsingDeviceOrientation;
  40656. /**
  40657. * Creates a new device orientation camera
  40658. * @param name The name of the camera
  40659. * @param position The start position camera
  40660. * @param scene The scene the camera belongs to
  40661. */
  40662. constructor(name: string, position: Vector3, scene: Scene);
  40663. /**
  40664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40665. */
  40666. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40667. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40668. private _dragFactor;
  40669. /**
  40670. * Enabled turning on the y axis when the orientation sensor is active
  40671. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40672. */
  40673. enableHorizontalDragging(dragFactor?: number): void;
  40674. /**
  40675. * Gets the current instance class name ("DeviceOrientationCamera").
  40676. * This helps avoiding instanceof at run time.
  40677. * @returns the class name
  40678. */
  40679. getClassName(): string;
  40680. /**
  40681. * @hidden
  40682. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40683. */
  40684. _checkInputs(): void;
  40685. /**
  40686. * Reset the camera to its default orientation on the specified axis only.
  40687. * @param axis The axis to reset
  40688. */
  40689. resetToCurrentRotation(axis?: Axis): void;
  40690. }
  40691. }
  40692. declare module BABYLON {
  40693. /**
  40694. * Defines supported buttons for XBox360 compatible gamepads
  40695. */
  40696. export enum Xbox360Button {
  40697. /** A */
  40698. A = 0,
  40699. /** B */
  40700. B = 1,
  40701. /** X */
  40702. X = 2,
  40703. /** Y */
  40704. Y = 3,
  40705. /** Start */
  40706. Start = 4,
  40707. /** Back */
  40708. Back = 5,
  40709. /** Left button */
  40710. LB = 6,
  40711. /** Right button */
  40712. RB = 7,
  40713. /** Left stick */
  40714. LeftStick = 8,
  40715. /** Right stick */
  40716. RightStick = 9
  40717. }
  40718. /** Defines values for XBox360 DPad */
  40719. export enum Xbox360Dpad {
  40720. /** Up */
  40721. Up = 0,
  40722. /** Down */
  40723. Down = 1,
  40724. /** Left */
  40725. Left = 2,
  40726. /** Right */
  40727. Right = 3
  40728. }
  40729. /**
  40730. * Defines a XBox360 gamepad
  40731. */
  40732. export class Xbox360Pad extends Gamepad {
  40733. private _leftTrigger;
  40734. private _rightTrigger;
  40735. private _onlefttriggerchanged;
  40736. private _onrighttriggerchanged;
  40737. private _onbuttondown;
  40738. private _onbuttonup;
  40739. private _ondpaddown;
  40740. private _ondpadup;
  40741. /** Observable raised when a button is pressed */
  40742. onButtonDownObservable: Observable<Xbox360Button>;
  40743. /** Observable raised when a button is released */
  40744. onButtonUpObservable: Observable<Xbox360Button>;
  40745. /** Observable raised when a pad is pressed */
  40746. onPadDownObservable: Observable<Xbox360Dpad>;
  40747. /** Observable raised when a pad is released */
  40748. onPadUpObservable: Observable<Xbox360Dpad>;
  40749. private _buttonA;
  40750. private _buttonB;
  40751. private _buttonX;
  40752. private _buttonY;
  40753. private _buttonBack;
  40754. private _buttonStart;
  40755. private _buttonLB;
  40756. private _buttonRB;
  40757. private _buttonLeftStick;
  40758. private _buttonRightStick;
  40759. private _dPadUp;
  40760. private _dPadDown;
  40761. private _dPadLeft;
  40762. private _dPadRight;
  40763. private _isXboxOnePad;
  40764. /**
  40765. * Creates a new XBox360 gamepad object
  40766. * @param id defines the id of this gamepad
  40767. * @param index defines its index
  40768. * @param gamepad defines the internal HTML gamepad object
  40769. * @param xboxOne defines if it is a XBox One gamepad
  40770. */
  40771. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40772. /**
  40773. * Defines the callback to call when left trigger is pressed
  40774. * @param callback defines the callback to use
  40775. */
  40776. onlefttriggerchanged(callback: (value: number) => void): void;
  40777. /**
  40778. * Defines the callback to call when right trigger is pressed
  40779. * @param callback defines the callback to use
  40780. */
  40781. onrighttriggerchanged(callback: (value: number) => void): void;
  40782. /**
  40783. * Gets the left trigger value
  40784. */
  40785. get leftTrigger(): number;
  40786. /**
  40787. * Sets the left trigger value
  40788. */
  40789. set leftTrigger(newValue: number);
  40790. /**
  40791. * Gets the right trigger value
  40792. */
  40793. get rightTrigger(): number;
  40794. /**
  40795. * Sets the right trigger value
  40796. */
  40797. set rightTrigger(newValue: number);
  40798. /**
  40799. * Defines the callback to call when a button is pressed
  40800. * @param callback defines the callback to use
  40801. */
  40802. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40803. /**
  40804. * Defines the callback to call when a button is released
  40805. * @param callback defines the callback to use
  40806. */
  40807. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40808. /**
  40809. * Defines the callback to call when a pad is pressed
  40810. * @param callback defines the callback to use
  40811. */
  40812. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40813. /**
  40814. * Defines the callback to call when a pad is released
  40815. * @param callback defines the callback to use
  40816. */
  40817. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40818. private _setButtonValue;
  40819. private _setDPadValue;
  40820. /**
  40821. * Gets the value of the `A` button
  40822. */
  40823. get buttonA(): number;
  40824. /**
  40825. * Sets the value of the `A` button
  40826. */
  40827. set buttonA(value: number);
  40828. /**
  40829. * Gets the value of the `B` button
  40830. */
  40831. get buttonB(): number;
  40832. /**
  40833. * Sets the value of the `B` button
  40834. */
  40835. set buttonB(value: number);
  40836. /**
  40837. * Gets the value of the `X` button
  40838. */
  40839. get buttonX(): number;
  40840. /**
  40841. * Sets the value of the `X` button
  40842. */
  40843. set buttonX(value: number);
  40844. /**
  40845. * Gets the value of the `Y` button
  40846. */
  40847. get buttonY(): number;
  40848. /**
  40849. * Sets the value of the `Y` button
  40850. */
  40851. set buttonY(value: number);
  40852. /**
  40853. * Gets the value of the `Start` button
  40854. */
  40855. get buttonStart(): number;
  40856. /**
  40857. * Sets the value of the `Start` button
  40858. */
  40859. set buttonStart(value: number);
  40860. /**
  40861. * Gets the value of the `Back` button
  40862. */
  40863. get buttonBack(): number;
  40864. /**
  40865. * Sets the value of the `Back` button
  40866. */
  40867. set buttonBack(value: number);
  40868. /**
  40869. * Gets the value of the `Left` button
  40870. */
  40871. get buttonLB(): number;
  40872. /**
  40873. * Sets the value of the `Left` button
  40874. */
  40875. set buttonLB(value: number);
  40876. /**
  40877. * Gets the value of the `Right` button
  40878. */
  40879. get buttonRB(): number;
  40880. /**
  40881. * Sets the value of the `Right` button
  40882. */
  40883. set buttonRB(value: number);
  40884. /**
  40885. * Gets the value of the Left joystick
  40886. */
  40887. get buttonLeftStick(): number;
  40888. /**
  40889. * Sets the value of the Left joystick
  40890. */
  40891. set buttonLeftStick(value: number);
  40892. /**
  40893. * Gets the value of the Right joystick
  40894. */
  40895. get buttonRightStick(): number;
  40896. /**
  40897. * Sets the value of the Right joystick
  40898. */
  40899. set buttonRightStick(value: number);
  40900. /**
  40901. * Gets the value of D-pad up
  40902. */
  40903. get dPadUp(): number;
  40904. /**
  40905. * Sets the value of D-pad up
  40906. */
  40907. set dPadUp(value: number);
  40908. /**
  40909. * Gets the value of D-pad down
  40910. */
  40911. get dPadDown(): number;
  40912. /**
  40913. * Sets the value of D-pad down
  40914. */
  40915. set dPadDown(value: number);
  40916. /**
  40917. * Gets the value of D-pad left
  40918. */
  40919. get dPadLeft(): number;
  40920. /**
  40921. * Sets the value of D-pad left
  40922. */
  40923. set dPadLeft(value: number);
  40924. /**
  40925. * Gets the value of D-pad right
  40926. */
  40927. get dPadRight(): number;
  40928. /**
  40929. * Sets the value of D-pad right
  40930. */
  40931. set dPadRight(value: number);
  40932. /**
  40933. * Force the gamepad to synchronize with device values
  40934. */
  40935. update(): void;
  40936. /**
  40937. * Disposes the gamepad
  40938. */
  40939. dispose(): void;
  40940. }
  40941. }
  40942. declare module BABYLON {
  40943. /**
  40944. * Defines supported buttons for DualShock compatible gamepads
  40945. */
  40946. export enum DualShockButton {
  40947. /** Cross */
  40948. Cross = 0,
  40949. /** Circle */
  40950. Circle = 1,
  40951. /** Square */
  40952. Square = 2,
  40953. /** Triangle */
  40954. Triangle = 3,
  40955. /** Options */
  40956. Options = 4,
  40957. /** Share */
  40958. Share = 5,
  40959. /** L1 */
  40960. L1 = 6,
  40961. /** R1 */
  40962. R1 = 7,
  40963. /** Left stick */
  40964. LeftStick = 8,
  40965. /** Right stick */
  40966. RightStick = 9
  40967. }
  40968. /** Defines values for DualShock DPad */
  40969. export enum DualShockDpad {
  40970. /** Up */
  40971. Up = 0,
  40972. /** Down */
  40973. Down = 1,
  40974. /** Left */
  40975. Left = 2,
  40976. /** Right */
  40977. Right = 3
  40978. }
  40979. /**
  40980. * Defines a DualShock gamepad
  40981. */
  40982. export class DualShockPad extends Gamepad {
  40983. private _leftTrigger;
  40984. private _rightTrigger;
  40985. private _onlefttriggerchanged;
  40986. private _onrighttriggerchanged;
  40987. private _onbuttondown;
  40988. private _onbuttonup;
  40989. private _ondpaddown;
  40990. private _ondpadup;
  40991. /** Observable raised when a button is pressed */
  40992. onButtonDownObservable: Observable<DualShockButton>;
  40993. /** Observable raised when a button is released */
  40994. onButtonUpObservable: Observable<DualShockButton>;
  40995. /** Observable raised when a pad is pressed */
  40996. onPadDownObservable: Observable<DualShockDpad>;
  40997. /** Observable raised when a pad is released */
  40998. onPadUpObservable: Observable<DualShockDpad>;
  40999. private _buttonCross;
  41000. private _buttonCircle;
  41001. private _buttonSquare;
  41002. private _buttonTriangle;
  41003. private _buttonShare;
  41004. private _buttonOptions;
  41005. private _buttonL1;
  41006. private _buttonR1;
  41007. private _buttonLeftStick;
  41008. private _buttonRightStick;
  41009. private _dPadUp;
  41010. private _dPadDown;
  41011. private _dPadLeft;
  41012. private _dPadRight;
  41013. /**
  41014. * Creates a new DualShock gamepad object
  41015. * @param id defines the id of this gamepad
  41016. * @param index defines its index
  41017. * @param gamepad defines the internal HTML gamepad object
  41018. */
  41019. constructor(id: string, index: number, gamepad: any);
  41020. /**
  41021. * Defines the callback to call when left trigger is pressed
  41022. * @param callback defines the callback to use
  41023. */
  41024. onlefttriggerchanged(callback: (value: number) => void): void;
  41025. /**
  41026. * Defines the callback to call when right trigger is pressed
  41027. * @param callback defines the callback to use
  41028. */
  41029. onrighttriggerchanged(callback: (value: number) => void): void;
  41030. /**
  41031. * Gets the left trigger value
  41032. */
  41033. get leftTrigger(): number;
  41034. /**
  41035. * Sets the left trigger value
  41036. */
  41037. set leftTrigger(newValue: number);
  41038. /**
  41039. * Gets the right trigger value
  41040. */
  41041. get rightTrigger(): number;
  41042. /**
  41043. * Sets the right trigger value
  41044. */
  41045. set rightTrigger(newValue: number);
  41046. /**
  41047. * Defines the callback to call when a button is pressed
  41048. * @param callback defines the callback to use
  41049. */
  41050. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41051. /**
  41052. * Defines the callback to call when a button is released
  41053. * @param callback defines the callback to use
  41054. */
  41055. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41056. /**
  41057. * Defines the callback to call when a pad is pressed
  41058. * @param callback defines the callback to use
  41059. */
  41060. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41061. /**
  41062. * Defines the callback to call when a pad is released
  41063. * @param callback defines the callback to use
  41064. */
  41065. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41066. private _setButtonValue;
  41067. private _setDPadValue;
  41068. /**
  41069. * Gets the value of the `Cross` button
  41070. */
  41071. get buttonCross(): number;
  41072. /**
  41073. * Sets the value of the `Cross` button
  41074. */
  41075. set buttonCross(value: number);
  41076. /**
  41077. * Gets the value of the `Circle` button
  41078. */
  41079. get buttonCircle(): number;
  41080. /**
  41081. * Sets the value of the `Circle` button
  41082. */
  41083. set buttonCircle(value: number);
  41084. /**
  41085. * Gets the value of the `Square` button
  41086. */
  41087. get buttonSquare(): number;
  41088. /**
  41089. * Sets the value of the `Square` button
  41090. */
  41091. set buttonSquare(value: number);
  41092. /**
  41093. * Gets the value of the `Triangle` button
  41094. */
  41095. get buttonTriangle(): number;
  41096. /**
  41097. * Sets the value of the `Triangle` button
  41098. */
  41099. set buttonTriangle(value: number);
  41100. /**
  41101. * Gets the value of the `Options` button
  41102. */
  41103. get buttonOptions(): number;
  41104. /**
  41105. * Sets the value of the `Options` button
  41106. */
  41107. set buttonOptions(value: number);
  41108. /**
  41109. * Gets the value of the `Share` button
  41110. */
  41111. get buttonShare(): number;
  41112. /**
  41113. * Sets the value of the `Share` button
  41114. */
  41115. set buttonShare(value: number);
  41116. /**
  41117. * Gets the value of the `L1` button
  41118. */
  41119. get buttonL1(): number;
  41120. /**
  41121. * Sets the value of the `L1` button
  41122. */
  41123. set buttonL1(value: number);
  41124. /**
  41125. * Gets the value of the `R1` button
  41126. */
  41127. get buttonR1(): number;
  41128. /**
  41129. * Sets the value of the `R1` button
  41130. */
  41131. set buttonR1(value: number);
  41132. /**
  41133. * Gets the value of the Left joystick
  41134. */
  41135. get buttonLeftStick(): number;
  41136. /**
  41137. * Sets the value of the Left joystick
  41138. */
  41139. set buttonLeftStick(value: number);
  41140. /**
  41141. * Gets the value of the Right joystick
  41142. */
  41143. get buttonRightStick(): number;
  41144. /**
  41145. * Sets the value of the Right joystick
  41146. */
  41147. set buttonRightStick(value: number);
  41148. /**
  41149. * Gets the value of D-pad up
  41150. */
  41151. get dPadUp(): number;
  41152. /**
  41153. * Sets the value of D-pad up
  41154. */
  41155. set dPadUp(value: number);
  41156. /**
  41157. * Gets the value of D-pad down
  41158. */
  41159. get dPadDown(): number;
  41160. /**
  41161. * Sets the value of D-pad down
  41162. */
  41163. set dPadDown(value: number);
  41164. /**
  41165. * Gets the value of D-pad left
  41166. */
  41167. get dPadLeft(): number;
  41168. /**
  41169. * Sets the value of D-pad left
  41170. */
  41171. set dPadLeft(value: number);
  41172. /**
  41173. * Gets the value of D-pad right
  41174. */
  41175. get dPadRight(): number;
  41176. /**
  41177. * Sets the value of D-pad right
  41178. */
  41179. set dPadRight(value: number);
  41180. /**
  41181. * Force the gamepad to synchronize with device values
  41182. */
  41183. update(): void;
  41184. /**
  41185. * Disposes the gamepad
  41186. */
  41187. dispose(): void;
  41188. }
  41189. }
  41190. declare module BABYLON {
  41191. /**
  41192. * Manager for handling gamepads
  41193. */
  41194. export class GamepadManager {
  41195. private _scene?;
  41196. private _babylonGamepads;
  41197. private _oneGamepadConnected;
  41198. /** @hidden */
  41199. _isMonitoring: boolean;
  41200. private _gamepadEventSupported;
  41201. private _gamepadSupport?;
  41202. /**
  41203. * observable to be triggered when the gamepad controller has been connected
  41204. */
  41205. onGamepadConnectedObservable: Observable<Gamepad>;
  41206. /**
  41207. * observable to be triggered when the gamepad controller has been disconnected
  41208. */
  41209. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41210. private _onGamepadConnectedEvent;
  41211. private _onGamepadDisconnectedEvent;
  41212. /**
  41213. * Initializes the gamepad manager
  41214. * @param _scene BabylonJS scene
  41215. */
  41216. constructor(_scene?: Scene | undefined);
  41217. /**
  41218. * The gamepads in the game pad manager
  41219. */
  41220. get gamepads(): Gamepad[];
  41221. /**
  41222. * Get the gamepad controllers based on type
  41223. * @param type The type of gamepad controller
  41224. * @returns Nullable gamepad
  41225. */
  41226. getGamepadByType(type?: number): Nullable<Gamepad>;
  41227. /**
  41228. * Disposes the gamepad manager
  41229. */
  41230. dispose(): void;
  41231. private _addNewGamepad;
  41232. private _startMonitoringGamepads;
  41233. private _stopMonitoringGamepads;
  41234. /** @hidden */
  41235. _checkGamepadsStatus(): void;
  41236. private _updateGamepadObjects;
  41237. }
  41238. }
  41239. declare module BABYLON {
  41240. interface Scene {
  41241. /** @hidden */
  41242. _gamepadManager: Nullable<GamepadManager>;
  41243. /**
  41244. * Gets the gamepad manager associated with the scene
  41245. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41246. */
  41247. gamepadManager: GamepadManager;
  41248. }
  41249. /**
  41250. * Interface representing a free camera inputs manager
  41251. */
  41252. interface FreeCameraInputsManager {
  41253. /**
  41254. * Adds gamepad input support to the FreeCameraInputsManager.
  41255. * @returns the FreeCameraInputsManager
  41256. */
  41257. addGamepad(): FreeCameraInputsManager;
  41258. }
  41259. /**
  41260. * Interface representing an arc rotate camera inputs manager
  41261. */
  41262. interface ArcRotateCameraInputsManager {
  41263. /**
  41264. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41265. * @returns the camera inputs manager
  41266. */
  41267. addGamepad(): ArcRotateCameraInputsManager;
  41268. }
  41269. /**
  41270. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41271. */
  41272. export class GamepadSystemSceneComponent implements ISceneComponent {
  41273. /**
  41274. * The component name helpfull to identify the component in the list of scene components.
  41275. */
  41276. readonly name: string;
  41277. /**
  41278. * The scene the component belongs to.
  41279. */
  41280. scene: Scene;
  41281. /**
  41282. * Creates a new instance of the component for the given scene
  41283. * @param scene Defines the scene to register the component in
  41284. */
  41285. constructor(scene: Scene);
  41286. /**
  41287. * Registers the component in a given scene
  41288. */
  41289. register(): void;
  41290. /**
  41291. * Rebuilds the elements related to this component in case of
  41292. * context lost for instance.
  41293. */
  41294. rebuild(): void;
  41295. /**
  41296. * Disposes the component and the associated ressources
  41297. */
  41298. dispose(): void;
  41299. private _beforeCameraUpdate;
  41300. }
  41301. }
  41302. declare module BABYLON {
  41303. /**
  41304. * 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,
  41305. * which still works and will still be found in many Playgrounds.
  41306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41307. */
  41308. export class UniversalCamera extends TouchCamera {
  41309. /**
  41310. * Defines the gamepad rotation sensiblity.
  41311. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41312. */
  41313. get gamepadAngularSensibility(): number;
  41314. set gamepadAngularSensibility(value: number);
  41315. /**
  41316. * Defines the gamepad move sensiblity.
  41317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41318. */
  41319. get gamepadMoveSensibility(): number;
  41320. set gamepadMoveSensibility(value: number);
  41321. /**
  41322. * 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,
  41323. * which still works and will still be found in many Playgrounds.
  41324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41325. * @param name Define the name of the camera in the scene
  41326. * @param position Define the start position of the camera in the scene
  41327. * @param scene Define the scene the camera belongs to
  41328. */
  41329. constructor(name: string, position: Vector3, scene: Scene);
  41330. /**
  41331. * Gets the current object class name.
  41332. * @return the class name
  41333. */
  41334. getClassName(): string;
  41335. }
  41336. }
  41337. declare module BABYLON {
  41338. /**
  41339. * This represents a FPS type of camera. This is only here for back compat purpose.
  41340. * Please use the UniversalCamera instead as both are identical.
  41341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41342. */
  41343. export class GamepadCamera extends UniversalCamera {
  41344. /**
  41345. * Instantiates a new Gamepad Camera
  41346. * This represents a FPS type of camera. This is only here for back compat purpose.
  41347. * Please use the UniversalCamera instead as both are identical.
  41348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41349. * @param name Define the name of the camera in the scene
  41350. * @param position Define the start position of the camera in the scene
  41351. * @param scene Define the scene the camera belongs to
  41352. */
  41353. constructor(name: string, position: Vector3, scene: Scene);
  41354. /**
  41355. * Gets the current object class name.
  41356. * @return the class name
  41357. */
  41358. getClassName(): string;
  41359. }
  41360. }
  41361. declare module BABYLON {
  41362. /** @hidden */
  41363. export var passPixelShader: {
  41364. name: string;
  41365. shader: string;
  41366. };
  41367. }
  41368. declare module BABYLON {
  41369. /** @hidden */
  41370. export var passCubePixelShader: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module BABYLON {
  41376. /**
  41377. * PassPostProcess which produces an output the same as it's input
  41378. */
  41379. export class PassPostProcess extends PostProcess {
  41380. /**
  41381. * Creates the PassPostProcess
  41382. * @param name The name of the effect.
  41383. * @param options The required width/height ratio to downsize to before computing the render pass.
  41384. * @param camera The camera to apply the render pass to.
  41385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41386. * @param engine The engine which the post process will be applied. (default: current engine)
  41387. * @param reusable If the post process can be reused on the same frame. (default: false)
  41388. * @param textureType The type of texture to be used when performing the post processing.
  41389. * @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)
  41390. */
  41391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41392. }
  41393. /**
  41394. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41395. */
  41396. export class PassCubePostProcess extends PostProcess {
  41397. private _face;
  41398. /**
  41399. * Gets or sets the cube face to display.
  41400. * * 0 is +X
  41401. * * 1 is -X
  41402. * * 2 is +Y
  41403. * * 3 is -Y
  41404. * * 4 is +Z
  41405. * * 5 is -Z
  41406. */
  41407. get face(): number;
  41408. set face(value: number);
  41409. /**
  41410. * Creates the PassCubePostProcess
  41411. * @param name The name of the effect.
  41412. * @param options The required width/height ratio to downsize to before computing the render pass.
  41413. * @param camera The camera to apply the render pass to.
  41414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41415. * @param engine The engine which the post process will be applied. (default: current engine)
  41416. * @param reusable If the post process can be reused on the same frame. (default: false)
  41417. * @param textureType The type of texture to be used when performing the post processing.
  41418. * @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)
  41419. */
  41420. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /** @hidden */
  41425. export var anaglyphPixelShader: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module BABYLON {
  41431. /**
  41432. * Postprocess used to generate anaglyphic rendering
  41433. */
  41434. export class AnaglyphPostProcess extends PostProcess {
  41435. private _passedProcess;
  41436. /**
  41437. * Creates a new AnaglyphPostProcess
  41438. * @param name defines postprocess name
  41439. * @param options defines creation options or target ratio scale
  41440. * @param rigCameras defines cameras using this postprocess
  41441. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41442. * @param engine defines hosting engine
  41443. * @param reusable defines if the postprocess will be reused multiple times per frame
  41444. */
  41445. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41446. }
  41447. }
  41448. declare module BABYLON {
  41449. /**
  41450. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41452. */
  41453. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41454. /**
  41455. * Creates a new AnaglyphArcRotateCamera
  41456. * @param name defines camera name
  41457. * @param alpha defines alpha angle (in radians)
  41458. * @param beta defines beta angle (in radians)
  41459. * @param radius defines radius
  41460. * @param target defines camera target
  41461. * @param interaxialDistance defines distance between each color axis
  41462. * @param scene defines the hosting scene
  41463. */
  41464. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41465. /**
  41466. * Gets camera class name
  41467. * @returns AnaglyphArcRotateCamera
  41468. */
  41469. getClassName(): string;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /**
  41474. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41475. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41476. */
  41477. export class AnaglyphFreeCamera extends FreeCamera {
  41478. /**
  41479. * Creates a new AnaglyphFreeCamera
  41480. * @param name defines camera name
  41481. * @param position defines initial position
  41482. * @param interaxialDistance defines distance between each color axis
  41483. * @param scene defines the hosting scene
  41484. */
  41485. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41486. /**
  41487. * Gets camera class name
  41488. * @returns AnaglyphFreeCamera
  41489. */
  41490. getClassName(): string;
  41491. }
  41492. }
  41493. declare module BABYLON {
  41494. /**
  41495. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41496. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41497. */
  41498. export class AnaglyphGamepadCamera extends GamepadCamera {
  41499. /**
  41500. * Creates a new AnaglyphGamepadCamera
  41501. * @param name defines camera name
  41502. * @param position defines initial position
  41503. * @param interaxialDistance defines distance between each color axis
  41504. * @param scene defines the hosting scene
  41505. */
  41506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41507. /**
  41508. * Gets camera class name
  41509. * @returns AnaglyphGamepadCamera
  41510. */
  41511. getClassName(): string;
  41512. }
  41513. }
  41514. declare module BABYLON {
  41515. /**
  41516. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41517. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41518. */
  41519. export class AnaglyphUniversalCamera extends UniversalCamera {
  41520. /**
  41521. * Creates a new AnaglyphUniversalCamera
  41522. * @param name defines camera name
  41523. * @param position defines initial position
  41524. * @param interaxialDistance defines distance between each color axis
  41525. * @param scene defines the hosting scene
  41526. */
  41527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41528. /**
  41529. * Gets camera class name
  41530. * @returns AnaglyphUniversalCamera
  41531. */
  41532. getClassName(): string;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /** @hidden */
  41537. export var stereoscopicInterlacePixelShader: {
  41538. name: string;
  41539. shader: string;
  41540. };
  41541. }
  41542. declare module BABYLON {
  41543. /**
  41544. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41545. */
  41546. export class StereoscopicInterlacePostProcess extends PostProcess {
  41547. private _stepSize;
  41548. private _passedProcess;
  41549. /**
  41550. * Initializes a StereoscopicInterlacePostProcess
  41551. * @param name The name of the effect.
  41552. * @param rigCameras The rig cameras to be appled to the post process
  41553. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41555. * @param engine The engine which the post process will be applied. (default: current engine)
  41556. * @param reusable If the post process can be reused on the same frame. (default: false)
  41557. */
  41558. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41559. }
  41560. }
  41561. declare module BABYLON {
  41562. /**
  41563. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41564. * @see http://doc.babylonjs.com/features/cameras
  41565. */
  41566. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41567. /**
  41568. * Creates a new StereoscopicArcRotateCamera
  41569. * @param name defines camera name
  41570. * @param alpha defines alpha angle (in radians)
  41571. * @param beta defines beta angle (in radians)
  41572. * @param radius defines radius
  41573. * @param target defines camera target
  41574. * @param interaxialDistance defines distance between each color axis
  41575. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41576. * @param scene defines the hosting scene
  41577. */
  41578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41579. /**
  41580. * Gets camera class name
  41581. * @returns StereoscopicArcRotateCamera
  41582. */
  41583. getClassName(): string;
  41584. }
  41585. }
  41586. declare module BABYLON {
  41587. /**
  41588. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41589. * @see http://doc.babylonjs.com/features/cameras
  41590. */
  41591. export class StereoscopicFreeCamera extends FreeCamera {
  41592. /**
  41593. * Creates a new StereoscopicFreeCamera
  41594. * @param name defines camera name
  41595. * @param position defines initial position
  41596. * @param interaxialDistance defines distance between each color axis
  41597. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41598. * @param scene defines the hosting scene
  41599. */
  41600. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41601. /**
  41602. * Gets camera class name
  41603. * @returns StereoscopicFreeCamera
  41604. */
  41605. getClassName(): string;
  41606. }
  41607. }
  41608. declare module BABYLON {
  41609. /**
  41610. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41611. * @see http://doc.babylonjs.com/features/cameras
  41612. */
  41613. export class StereoscopicGamepadCamera extends GamepadCamera {
  41614. /**
  41615. * Creates a new StereoscopicGamepadCamera
  41616. * @param name defines camera name
  41617. * @param position defines initial position
  41618. * @param interaxialDistance defines distance between each color axis
  41619. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41620. * @param scene defines the hosting scene
  41621. */
  41622. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41623. /**
  41624. * Gets camera class name
  41625. * @returns StereoscopicGamepadCamera
  41626. */
  41627. getClassName(): string;
  41628. }
  41629. }
  41630. declare module BABYLON {
  41631. /**
  41632. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41633. * @see http://doc.babylonjs.com/features/cameras
  41634. */
  41635. export class StereoscopicUniversalCamera extends UniversalCamera {
  41636. /**
  41637. * Creates a new StereoscopicUniversalCamera
  41638. * @param name defines camera name
  41639. * @param position defines initial position
  41640. * @param interaxialDistance defines distance between each color axis
  41641. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41642. * @param scene defines the hosting scene
  41643. */
  41644. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41645. /**
  41646. * Gets camera class name
  41647. * @returns StereoscopicUniversalCamera
  41648. */
  41649. getClassName(): string;
  41650. }
  41651. }
  41652. declare module BABYLON {
  41653. /**
  41654. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41655. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41656. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41657. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41658. */
  41659. export class VirtualJoysticksCamera extends FreeCamera {
  41660. /**
  41661. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41662. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41663. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41664. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41665. * @param name Define the name of the camera in the scene
  41666. * @param position Define the start position of the camera in the scene
  41667. * @param scene Define the scene the camera belongs to
  41668. */
  41669. constructor(name: string, position: Vector3, scene: Scene);
  41670. /**
  41671. * Gets the current object class name.
  41672. * @return the class name
  41673. */
  41674. getClassName(): string;
  41675. }
  41676. }
  41677. declare module BABYLON {
  41678. /**
  41679. * This represents all the required metrics to create a VR camera.
  41680. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41681. */
  41682. export class VRCameraMetrics {
  41683. /**
  41684. * Define the horizontal resolution off the screen.
  41685. */
  41686. hResolution: number;
  41687. /**
  41688. * Define the vertical resolution off the screen.
  41689. */
  41690. vResolution: number;
  41691. /**
  41692. * Define the horizontal screen size.
  41693. */
  41694. hScreenSize: number;
  41695. /**
  41696. * Define the vertical screen size.
  41697. */
  41698. vScreenSize: number;
  41699. /**
  41700. * Define the vertical screen center position.
  41701. */
  41702. vScreenCenter: number;
  41703. /**
  41704. * Define the distance of the eyes to the screen.
  41705. */
  41706. eyeToScreenDistance: number;
  41707. /**
  41708. * Define the distance between both lenses
  41709. */
  41710. lensSeparationDistance: number;
  41711. /**
  41712. * Define the distance between both viewer's eyes.
  41713. */
  41714. interpupillaryDistance: number;
  41715. /**
  41716. * Define the distortion factor of the VR postprocess.
  41717. * Please, touch with care.
  41718. */
  41719. distortionK: number[];
  41720. /**
  41721. * Define the chromatic aberration correction factors for the VR post process.
  41722. */
  41723. chromaAbCorrection: number[];
  41724. /**
  41725. * Define the scale factor of the post process.
  41726. * The smaller the better but the slower.
  41727. */
  41728. postProcessScaleFactor: number;
  41729. /**
  41730. * Define an offset for the lens center.
  41731. */
  41732. lensCenterOffset: number;
  41733. /**
  41734. * Define if the current vr camera should compensate the distortion of the lense or not.
  41735. */
  41736. compensateDistortion: boolean;
  41737. /**
  41738. * Defines if multiview should be enabled when rendering (Default: false)
  41739. */
  41740. multiviewEnabled: boolean;
  41741. /**
  41742. * Gets the rendering aspect ratio based on the provided resolutions.
  41743. */
  41744. get aspectRatio(): number;
  41745. /**
  41746. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41747. */
  41748. get aspectRatioFov(): number;
  41749. /**
  41750. * @hidden
  41751. */
  41752. get leftHMatrix(): Matrix;
  41753. /**
  41754. * @hidden
  41755. */
  41756. get rightHMatrix(): Matrix;
  41757. /**
  41758. * @hidden
  41759. */
  41760. get leftPreViewMatrix(): Matrix;
  41761. /**
  41762. * @hidden
  41763. */
  41764. get rightPreViewMatrix(): Matrix;
  41765. /**
  41766. * Get the default VRMetrics based on the most generic setup.
  41767. * @returns the default vr metrics
  41768. */
  41769. static GetDefault(): VRCameraMetrics;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /** @hidden */
  41774. export var vrDistortionCorrectionPixelShader: {
  41775. name: string;
  41776. shader: string;
  41777. };
  41778. }
  41779. declare module BABYLON {
  41780. /**
  41781. * VRDistortionCorrectionPostProcess used for mobile VR
  41782. */
  41783. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41784. private _isRightEye;
  41785. private _distortionFactors;
  41786. private _postProcessScaleFactor;
  41787. private _lensCenterOffset;
  41788. private _scaleIn;
  41789. private _scaleFactor;
  41790. private _lensCenter;
  41791. /**
  41792. * Initializes the VRDistortionCorrectionPostProcess
  41793. * @param name The name of the effect.
  41794. * @param camera The camera to apply the render pass to.
  41795. * @param isRightEye If this is for the right eye distortion
  41796. * @param vrMetrics All the required metrics for the VR camera
  41797. */
  41798. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41799. }
  41800. }
  41801. declare module BABYLON {
  41802. /**
  41803. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41804. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41805. */
  41806. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41807. /**
  41808. * Creates a new VRDeviceOrientationArcRotateCamera
  41809. * @param name defines camera name
  41810. * @param alpha defines the camera rotation along the logitudinal axis
  41811. * @param beta defines the camera rotation along the latitudinal axis
  41812. * @param radius defines the camera distance from its target
  41813. * @param target defines the camera target
  41814. * @param scene defines the scene the camera belongs to
  41815. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41816. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41817. */
  41818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41819. /**
  41820. * Gets camera class name
  41821. * @returns VRDeviceOrientationArcRotateCamera
  41822. */
  41823. getClassName(): string;
  41824. }
  41825. }
  41826. declare module BABYLON {
  41827. /**
  41828. * Camera used to simulate VR rendering (based on FreeCamera)
  41829. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41830. */
  41831. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41832. /**
  41833. * Creates a new VRDeviceOrientationFreeCamera
  41834. * @param name defines camera name
  41835. * @param position defines the start position of the camera
  41836. * @param scene defines the scene the camera belongs to
  41837. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41838. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41839. */
  41840. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41841. /**
  41842. * Gets camera class name
  41843. * @returns VRDeviceOrientationFreeCamera
  41844. */
  41845. getClassName(): string;
  41846. }
  41847. }
  41848. declare module BABYLON {
  41849. /**
  41850. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41851. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41852. */
  41853. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41854. /**
  41855. * Creates a new VRDeviceOrientationGamepadCamera
  41856. * @param name defines camera name
  41857. * @param position defines the start position of the camera
  41858. * @param scene defines the scene the camera belongs to
  41859. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41860. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41861. */
  41862. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41863. /**
  41864. * Gets camera class name
  41865. * @returns VRDeviceOrientationGamepadCamera
  41866. */
  41867. getClassName(): string;
  41868. }
  41869. }
  41870. declare module BABYLON {
  41871. /** @hidden */
  41872. export var imageProcessingPixelShader: {
  41873. name: string;
  41874. shader: string;
  41875. };
  41876. }
  41877. declare module BABYLON {
  41878. /**
  41879. * ImageProcessingPostProcess
  41880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41881. */
  41882. export class ImageProcessingPostProcess extends PostProcess {
  41883. /**
  41884. * Default configuration related to image processing available in the PBR Material.
  41885. */
  41886. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41887. /**
  41888. * Gets the image processing configuration used either in this material.
  41889. */
  41890. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41891. /**
  41892. * Sets the Default image processing configuration used either in the this material.
  41893. *
  41894. * If sets to null, the scene one is in use.
  41895. */
  41896. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41897. /**
  41898. * Keep track of the image processing observer to allow dispose and replace.
  41899. */
  41900. private _imageProcessingObserver;
  41901. /**
  41902. * Attaches a new image processing configuration to the PBR Material.
  41903. * @param configuration
  41904. */
  41905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41906. /**
  41907. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41908. */
  41909. get colorCurves(): Nullable<ColorCurves>;
  41910. /**
  41911. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41912. */
  41913. set colorCurves(value: Nullable<ColorCurves>);
  41914. /**
  41915. * Gets wether the color curves effect is enabled.
  41916. */
  41917. get colorCurvesEnabled(): boolean;
  41918. /**
  41919. * Sets wether the color curves effect is enabled.
  41920. */
  41921. set colorCurvesEnabled(value: boolean);
  41922. /**
  41923. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41924. */
  41925. get colorGradingTexture(): Nullable<BaseTexture>;
  41926. /**
  41927. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41928. */
  41929. set colorGradingTexture(value: Nullable<BaseTexture>);
  41930. /**
  41931. * Gets wether the color grading effect is enabled.
  41932. */
  41933. get colorGradingEnabled(): boolean;
  41934. /**
  41935. * Gets wether the color grading effect is enabled.
  41936. */
  41937. set colorGradingEnabled(value: boolean);
  41938. /**
  41939. * Gets exposure used in the effect.
  41940. */
  41941. get exposure(): number;
  41942. /**
  41943. * Sets exposure used in the effect.
  41944. */
  41945. set exposure(value: number);
  41946. /**
  41947. * Gets wether tonemapping is enabled or not.
  41948. */
  41949. get toneMappingEnabled(): boolean;
  41950. /**
  41951. * Sets wether tonemapping is enabled or not
  41952. */
  41953. set toneMappingEnabled(value: boolean);
  41954. /**
  41955. * Gets the type of tone mapping effect.
  41956. */
  41957. get toneMappingType(): number;
  41958. /**
  41959. * Sets the type of tone mapping effect.
  41960. */
  41961. set toneMappingType(value: number);
  41962. /**
  41963. * Gets contrast used in the effect.
  41964. */
  41965. get contrast(): number;
  41966. /**
  41967. * Sets contrast used in the effect.
  41968. */
  41969. set contrast(value: number);
  41970. /**
  41971. * Gets Vignette stretch size.
  41972. */
  41973. get vignetteStretch(): number;
  41974. /**
  41975. * Sets Vignette stretch size.
  41976. */
  41977. set vignetteStretch(value: number);
  41978. /**
  41979. * Gets Vignette centre X Offset.
  41980. */
  41981. get vignetteCentreX(): number;
  41982. /**
  41983. * Sets Vignette centre X Offset.
  41984. */
  41985. set vignetteCentreX(value: number);
  41986. /**
  41987. * Gets Vignette centre Y Offset.
  41988. */
  41989. get vignetteCentreY(): number;
  41990. /**
  41991. * Sets Vignette centre Y Offset.
  41992. */
  41993. set vignetteCentreY(value: number);
  41994. /**
  41995. * Gets Vignette weight or intensity of the vignette effect.
  41996. */
  41997. get vignetteWeight(): number;
  41998. /**
  41999. * Sets Vignette weight or intensity of the vignette effect.
  42000. */
  42001. set vignetteWeight(value: number);
  42002. /**
  42003. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42004. * if vignetteEnabled is set to true.
  42005. */
  42006. get vignetteColor(): Color4;
  42007. /**
  42008. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42009. * if vignetteEnabled is set to true.
  42010. */
  42011. set vignetteColor(value: Color4);
  42012. /**
  42013. * Gets Camera field of view used by the Vignette effect.
  42014. */
  42015. get vignetteCameraFov(): number;
  42016. /**
  42017. * Sets Camera field of view used by the Vignette effect.
  42018. */
  42019. set vignetteCameraFov(value: number);
  42020. /**
  42021. * Gets the vignette blend mode allowing different kind of effect.
  42022. */
  42023. get vignetteBlendMode(): number;
  42024. /**
  42025. * Sets the vignette blend mode allowing different kind of effect.
  42026. */
  42027. set vignetteBlendMode(value: number);
  42028. /**
  42029. * Gets wether the vignette effect is enabled.
  42030. */
  42031. get vignetteEnabled(): boolean;
  42032. /**
  42033. * Sets wether the vignette effect is enabled.
  42034. */
  42035. set vignetteEnabled(value: boolean);
  42036. private _fromLinearSpace;
  42037. /**
  42038. * Gets wether the input of the processing is in Gamma or Linear Space.
  42039. */
  42040. get fromLinearSpace(): boolean;
  42041. /**
  42042. * Sets wether the input of the processing is in Gamma or Linear Space.
  42043. */
  42044. set fromLinearSpace(value: boolean);
  42045. /**
  42046. * Defines cache preventing GC.
  42047. */
  42048. private _defines;
  42049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42050. /**
  42051. * "ImageProcessingPostProcess"
  42052. * @returns "ImageProcessingPostProcess"
  42053. */
  42054. getClassName(): string;
  42055. protected _updateParameters(): void;
  42056. dispose(camera?: Camera): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * Class containing static functions to help procedurally build meshes
  42062. */
  42063. export class GroundBuilder {
  42064. /**
  42065. * Creates a ground mesh
  42066. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42067. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42069. * @param name defines the name of the mesh
  42070. * @param options defines the options used to create the mesh
  42071. * @param scene defines the hosting scene
  42072. * @returns the ground mesh
  42073. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42074. */
  42075. static CreateGround(name: string, options: {
  42076. width?: number;
  42077. height?: number;
  42078. subdivisions?: number;
  42079. subdivisionsX?: number;
  42080. subdivisionsY?: number;
  42081. updatable?: boolean;
  42082. }, scene: any): Mesh;
  42083. /**
  42084. * Creates a tiled ground mesh
  42085. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42086. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42087. * * 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
  42088. * * 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
  42089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42090. * @param name defines the name of the mesh
  42091. * @param options defines the options used to create the mesh
  42092. * @param scene defines the hosting scene
  42093. * @returns the tiled ground mesh
  42094. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42095. */
  42096. static CreateTiledGround(name: string, options: {
  42097. xmin: number;
  42098. zmin: number;
  42099. xmax: number;
  42100. zmax: number;
  42101. subdivisions?: {
  42102. w: number;
  42103. h: number;
  42104. };
  42105. precision?: {
  42106. w: number;
  42107. h: number;
  42108. };
  42109. updatable?: boolean;
  42110. }, scene?: Nullable<Scene>): Mesh;
  42111. /**
  42112. * Creates a ground mesh from a height map
  42113. * * The parameter `url` sets the URL of the height map image resource.
  42114. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42115. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42116. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42117. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42118. * * 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.
  42119. * * 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).
  42120. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42122. * @param name defines the name of the mesh
  42123. * @param url defines the url to the height map
  42124. * @param options defines the options used to create the mesh
  42125. * @param scene defines the hosting scene
  42126. * @returns the ground mesh
  42127. * @see https://doc.babylonjs.com/babylon101/height_map
  42128. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42129. */
  42130. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42131. width?: number;
  42132. height?: number;
  42133. subdivisions?: number;
  42134. minHeight?: number;
  42135. maxHeight?: number;
  42136. colorFilter?: Color3;
  42137. alphaFilter?: number;
  42138. updatable?: boolean;
  42139. onReady?: (mesh: GroundMesh) => void;
  42140. }, scene?: Nullable<Scene>): GroundMesh;
  42141. }
  42142. }
  42143. declare module BABYLON {
  42144. /**
  42145. * Class containing static functions to help procedurally build meshes
  42146. */
  42147. export class TorusBuilder {
  42148. /**
  42149. * Creates a torus mesh
  42150. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42151. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42152. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42154. * * 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
  42155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42156. * @param name defines the name of the mesh
  42157. * @param options defines the options used to create the mesh
  42158. * @param scene defines the hosting scene
  42159. * @returns the torus mesh
  42160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42161. */
  42162. static CreateTorus(name: string, options: {
  42163. diameter?: number;
  42164. thickness?: number;
  42165. tessellation?: number;
  42166. updatable?: boolean;
  42167. sideOrientation?: number;
  42168. frontUVs?: Vector4;
  42169. backUVs?: Vector4;
  42170. }, scene: any): Mesh;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. /**
  42175. * Class containing static functions to help procedurally build meshes
  42176. */
  42177. export class CylinderBuilder {
  42178. /**
  42179. * Creates a cylinder or a cone mesh
  42180. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42181. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42182. * * 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.
  42183. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42184. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42185. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42186. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42187. * * 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).
  42188. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42189. * * 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).
  42190. * * 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
  42191. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42192. * * 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
  42193. * * 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.
  42194. * * If `enclose` is false, a ring surface is one element.
  42195. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42196. * * 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
  42197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42198. * * 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
  42199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42200. * @param name defines the name of the mesh
  42201. * @param options defines the options used to create the mesh
  42202. * @param scene defines the hosting scene
  42203. * @returns the cylinder mesh
  42204. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42205. */
  42206. static CreateCylinder(name: string, options: {
  42207. height?: number;
  42208. diameterTop?: number;
  42209. diameterBottom?: number;
  42210. diameter?: number;
  42211. tessellation?: number;
  42212. subdivisions?: number;
  42213. arc?: number;
  42214. faceColors?: Color4[];
  42215. faceUV?: Vector4[];
  42216. updatable?: boolean;
  42217. hasRings?: boolean;
  42218. enclose?: boolean;
  42219. cap?: number;
  42220. sideOrientation?: number;
  42221. frontUVs?: Vector4;
  42222. backUVs?: Vector4;
  42223. }, scene: any): Mesh;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * States of the webXR experience
  42229. */
  42230. export enum WebXRState {
  42231. /**
  42232. * Transitioning to being in XR mode
  42233. */
  42234. ENTERING_XR = 0,
  42235. /**
  42236. * Transitioning to non XR mode
  42237. */
  42238. EXITING_XR = 1,
  42239. /**
  42240. * In XR mode and presenting
  42241. */
  42242. IN_XR = 2,
  42243. /**
  42244. * Not entered XR mode
  42245. */
  42246. NOT_IN_XR = 3
  42247. }
  42248. /**
  42249. * Abstraction of the XR render target
  42250. */
  42251. export interface WebXRRenderTarget extends IDisposable {
  42252. /**
  42253. * xrpresent context of the canvas which can be used to display/mirror xr content
  42254. */
  42255. canvasContext: WebGLRenderingContext;
  42256. /**
  42257. * xr layer for the canvas
  42258. */
  42259. xrLayer: Nullable<XRWebGLLayer>;
  42260. /**
  42261. * Initializes the xr layer for the session
  42262. * @param xrSession xr session
  42263. * @returns a promise that will resolve once the XR Layer has been created
  42264. */
  42265. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42266. }
  42267. }
  42268. declare module BABYLON {
  42269. /**
  42270. * COnfiguration object for WebXR output canvas
  42271. */
  42272. export class WebXRManagedOutputCanvasOptions {
  42273. /**
  42274. * Options for this XR Layer output
  42275. */
  42276. canvasOptions: XRWebGLLayerOptions;
  42277. /**
  42278. * CSS styling for a newly created canvas (if not provided)
  42279. */
  42280. newCanvasCssStyle?: string;
  42281. /**
  42282. * Get the default values of the configuration object
  42283. * @returns default values of this configuration object
  42284. */
  42285. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42286. }
  42287. /**
  42288. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42289. */
  42290. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42291. private configuration;
  42292. private _engine;
  42293. private _canvas;
  42294. /**
  42295. * xrpresent context of the canvas which can be used to display/mirror xr content
  42296. */
  42297. canvasContext: WebGLRenderingContext;
  42298. /**
  42299. * xr layer for the canvas
  42300. */
  42301. xrLayer: Nullable<XRWebGLLayer>;
  42302. /**
  42303. * Initializes the xr layer for the session
  42304. * @param xrSession xr session
  42305. * @returns a promise that will resolve once the XR Layer has been created
  42306. */
  42307. initializeXRLayerAsync(xrSession: any): any;
  42308. /**
  42309. * Initializes the canvas to be added/removed upon entering/exiting xr
  42310. * @param engine the Babylon engine
  42311. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42312. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42313. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42314. */
  42315. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42316. /**
  42317. * Disposes of the object
  42318. */
  42319. dispose(): void;
  42320. private _setManagedOutputCanvas;
  42321. private _addCanvas;
  42322. private _removeCanvas;
  42323. }
  42324. }
  42325. declare module BABYLON {
  42326. /**
  42327. * Manages an XRSession to work with Babylon's engine
  42328. * @see https://doc.babylonjs.com/how_to/webxr
  42329. */
  42330. export class WebXRSessionManager implements IDisposable {
  42331. /** The scene which the session should be created for */
  42332. scene: Scene;
  42333. /**
  42334. * Fires every time a new xrFrame arrives which can be used to update the camera
  42335. */
  42336. onXRFrameObservable: Observable<XRFrame>;
  42337. /**
  42338. * Fires when the xr session is ended either by the device or manually done
  42339. */
  42340. onXRSessionEnded: Observable<any>;
  42341. /**
  42342. * Fires when the xr session is ended either by the device or manually done
  42343. */
  42344. onXRSessionInit: Observable<XRSession>;
  42345. /**
  42346. * Underlying xr session
  42347. */
  42348. session: XRSession;
  42349. /**
  42350. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42351. * or get the offset the player is currently at.
  42352. */
  42353. viewerReferenceSpace: XRReferenceSpace;
  42354. /**
  42355. * The current reference space used in this session. This reference space can constantly change!
  42356. * It is mainly used to offset the camera's position.
  42357. */
  42358. referenceSpace: XRReferenceSpace;
  42359. /**
  42360. * The base reference space from which the session started. good if you want to reset your
  42361. * reference space
  42362. */
  42363. baseReferenceSpace: XRReferenceSpace;
  42364. /**
  42365. * Used just in case of a failure to initialize an immersive session.
  42366. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42367. */
  42368. defaultHeightCompensation: number;
  42369. /**
  42370. * Current XR frame
  42371. */
  42372. currentFrame: Nullable<XRFrame>;
  42373. /** WebXR timestamp updated every frame */
  42374. currentTimestamp: number;
  42375. private _xrNavigator;
  42376. private baseLayer;
  42377. private _rttProvider;
  42378. private _sessionEnded;
  42379. /**
  42380. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42381. * @param scene The scene which the session should be created for
  42382. */
  42383. constructor(
  42384. /** The scene which the session should be created for */
  42385. scene: Scene);
  42386. /**
  42387. * Initializes the manager
  42388. * After initialization enterXR can be called to start an XR session
  42389. * @returns Promise which resolves after it is initialized
  42390. */
  42391. initializeAsync(): Promise<void>;
  42392. /**
  42393. * Initializes an xr session
  42394. * @param xrSessionMode mode to initialize
  42395. * @param optionalFeatures defines optional values to pass to the session builder
  42396. * @returns a promise which will resolve once the session has been initialized
  42397. */
  42398. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42399. /**
  42400. * Sets the reference space on the xr session
  42401. * @param referenceSpace space to set
  42402. * @returns a promise that will resolve once the reference space has been set
  42403. */
  42404. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42405. /**
  42406. * Updates the render state of the session
  42407. * @param state state to set
  42408. * @returns a promise that resolves once the render state has been updated
  42409. */
  42410. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42411. /**
  42412. * Starts rendering to the xr layer
  42413. * @returns a promise that will resolve once rendering has started
  42414. */
  42415. startRenderingToXRAsync(): Promise<void>;
  42416. /**
  42417. * Gets the correct render target texture to be rendered this frame for this eye
  42418. * @param eye the eye for which to get the render target
  42419. * @returns the render target for the specified eye
  42420. */
  42421. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42422. /**
  42423. * Stops the xrSession and restores the renderloop
  42424. * @returns Promise which resolves after it exits XR
  42425. */
  42426. exitXRAsync(): Promise<void>;
  42427. /**
  42428. * Checks if a session would be supported for the creation options specified
  42429. * @param sessionMode session mode to check if supported eg. immersive-vr
  42430. * @returns true if supported
  42431. */
  42432. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42433. /**
  42434. * Creates a WebXRRenderTarget object for the XR session
  42435. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42436. * @param options optional options to provide when creating a new render target
  42437. * @returns a WebXR render target to which the session can render
  42438. */
  42439. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42440. /**
  42441. * @hidden
  42442. * Converts the render layer of xrSession to a render target
  42443. * @param session session to create render target for
  42444. * @param scene scene the new render target should be created for
  42445. * @param baseLayer the webgl layer to create the render target for
  42446. */
  42447. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42448. /**
  42449. * Disposes of the session manager
  42450. */
  42451. dispose(): void;
  42452. /**
  42453. * Gets a promise returning true when fullfiled if the given session mode is supported
  42454. * @param sessionMode defines the session to test
  42455. * @returns a promise
  42456. */
  42457. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42458. }
  42459. }
  42460. declare module BABYLON {
  42461. /**
  42462. * WebXR Camera which holds the views for the xrSession
  42463. * @see https://doc.babylonjs.com/how_to/webxr
  42464. */
  42465. export class WebXRCamera extends FreeCamera {
  42466. private _xrSessionManager;
  42467. /**
  42468. * Is the camera in debug mode. Used when using an emulator
  42469. */
  42470. debugMode: boolean;
  42471. private _firstFrame;
  42472. private _referencedPosition;
  42473. private _referenceQuaternion;
  42474. private _xrInvPositionCache;
  42475. private _xrInvQuaternionCache;
  42476. /**
  42477. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42478. * @param name the name of the camera
  42479. * @param scene the scene to add the camera to
  42480. */
  42481. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42482. private _updateNumberOfRigCameras;
  42483. /** @hidden */
  42484. _updateForDualEyeDebugging(): void;
  42485. /**
  42486. * Updates the cameras position from the current pose information of the XR session
  42487. * @param xrSessionManager the session containing pose information
  42488. */
  42489. update(): void;
  42490. private _updateReferenceSpace;
  42491. private _updateReferenceSpaceOffset;
  42492. private _updateFromXRSession;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * Defining the interface required for a (webxr) feature
  42498. */
  42499. export interface IWebXRFeature extends IDisposable {
  42500. /**
  42501. * Attach the feature to the session
  42502. * Will usually be called by the features manager
  42503. *
  42504. * @returns true if successful.
  42505. */
  42506. attach(): boolean;
  42507. /**
  42508. * Detach the feature from the session
  42509. * Will usually be called by the features manager
  42510. *
  42511. * @returns true if successful.
  42512. */
  42513. detach(): boolean;
  42514. }
  42515. /**
  42516. * Defining the constructor of a feature. Used to register the modules.
  42517. */
  42518. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42519. /**
  42520. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42521. * It is mainly used in AR sessions.
  42522. *
  42523. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42524. */
  42525. export class WebXRFeaturesManager implements IDisposable {
  42526. private _xrSessionManager;
  42527. private static readonly _AvailableFeatures;
  42528. /**
  42529. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42530. * Mainly used internally.
  42531. *
  42532. * @param featureName the name of the feature to register
  42533. * @param constructorFunction the function used to construct the module
  42534. * @param version the (babylon) version of the module
  42535. * @param stable is that a stable version of this module
  42536. */
  42537. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42538. /**
  42539. * Returns a constructor of a specific feature.
  42540. *
  42541. * @param featureName the name of the feature to construct
  42542. * @param version the version of the feature to load
  42543. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42544. * @param options optional options provided to the module.
  42545. * @returns a function that, when called, will return a new instance of this feature
  42546. */
  42547. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42548. /**
  42549. * Return the latest unstable version of this feature
  42550. * @param featureName the name of the feature to search
  42551. * @returns the version number. if not found will return -1
  42552. */
  42553. static GetLatestVersionOfFeature(featureName: string): number;
  42554. /**
  42555. * Return the latest stable version of this feature
  42556. * @param featureName the name of the feature to search
  42557. * @returns the version number. if not found will return -1
  42558. */
  42559. static GetStableVersionOfFeature(featureName: string): number;
  42560. /**
  42561. * Can be used to return the list of features currently registered
  42562. *
  42563. * @returns an Array of available features
  42564. */
  42565. static GetAvailableFeatures(): string[];
  42566. /**
  42567. * Gets the versions available for a specific feature
  42568. * @param featureName the name of the feature
  42569. * @returns an array with the available versions
  42570. */
  42571. static GetAvailableVersions(featureName: string): string[];
  42572. private _features;
  42573. /**
  42574. * constructs a new features manages.
  42575. *
  42576. * @param _xrSessionManager an instance of WebXRSessionManager
  42577. */
  42578. constructor(_xrSessionManager: WebXRSessionManager);
  42579. /**
  42580. * 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.
  42581. *
  42582. * @param featureName the name of the feature to load or the class of the feature
  42583. * @param version optional version to load. if not provided the latest version will be enabled
  42584. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42585. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42586. * @returns a new constructed feature or throws an error if feature not found.
  42587. */
  42588. enableFeature(featureName: string | {
  42589. Name: string;
  42590. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42591. /**
  42592. * Used to disable an already-enabled feature
  42593. * @param featureName the feature to disable
  42594. * @returns true if disable was successful
  42595. */
  42596. disableFeature(featureName: string | {
  42597. Name: string;
  42598. }): boolean;
  42599. /**
  42600. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42601. * Can be used during a session to start a feature
  42602. * @param featureName the name of feature to attach
  42603. */
  42604. attachFeature(featureName: string): void;
  42605. /**
  42606. * Can be used inside a session or when the session ends to detach a specific feature
  42607. * @param featureName the name of the feature to detach
  42608. */
  42609. detachFeature(featureName: string): void;
  42610. /**
  42611. * Get the list of enabled features
  42612. * @returns an array of enabled features
  42613. */
  42614. getEnabledFeatures(): string[];
  42615. /**
  42616. * get the implementation of an enabled feature.
  42617. * @param featureName the name of the feature to load
  42618. * @returns the feature class, if found
  42619. */
  42620. getEnabledFeature(featureName: string): IWebXRFeature;
  42621. /**
  42622. * dispose this features manager
  42623. */
  42624. dispose(): void;
  42625. }
  42626. }
  42627. declare module BABYLON {
  42628. /**
  42629. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42630. * @see https://doc.babylonjs.com/how_to/webxr
  42631. */
  42632. export class WebXRExperienceHelper implements IDisposable {
  42633. private scene;
  42634. /**
  42635. * Camera used to render xr content
  42636. */
  42637. camera: WebXRCamera;
  42638. /**
  42639. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42640. */
  42641. state: WebXRState;
  42642. private _setState;
  42643. /**
  42644. * Fires when the state of the experience helper has changed
  42645. */
  42646. onStateChangedObservable: Observable<WebXRState>;
  42647. /**
  42648. * Observers registered here will be triggered after the camera's initial transformation is set
  42649. * This can be used to set a different ground level or an extra rotation.
  42650. *
  42651. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42652. * to the position set after this observable is done executing.
  42653. */
  42654. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42655. /** Session manager used to keep track of xr session */
  42656. sessionManager: WebXRSessionManager;
  42657. /** A features manager for this xr session */
  42658. featuresManager: WebXRFeaturesManager;
  42659. private _nonVRCamera;
  42660. private _originalSceneAutoClear;
  42661. private _supported;
  42662. /**
  42663. * Creates the experience helper
  42664. * @param scene the scene to attach the experience helper to
  42665. * @returns a promise for the experience helper
  42666. */
  42667. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42668. /**
  42669. * Creates a WebXRExperienceHelper
  42670. * @param scene The scene the helper should be created in
  42671. */
  42672. private constructor();
  42673. /**
  42674. * Exits XR mode and returns the scene to its original state
  42675. * @returns promise that resolves after xr mode has exited
  42676. */
  42677. exitXRAsync(): Promise<void>;
  42678. /**
  42679. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42680. * @param sessionMode options for the XR session
  42681. * @param referenceSpaceType frame of reference of the XR session
  42682. * @param renderTarget the output canvas that will be used to enter XR mode
  42683. * @returns promise that resolves after xr mode has entered
  42684. */
  42685. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42686. /**
  42687. * Disposes of the experience helper
  42688. */
  42689. dispose(): void;
  42690. private _nonXRToXRCamera;
  42691. }
  42692. }
  42693. declare module BABYLON {
  42694. /**
  42695. * Represents an XR input
  42696. */
  42697. export class WebXRController {
  42698. private scene;
  42699. /** The underlying input source for the controller */
  42700. inputSource: XRInputSource;
  42701. private parentContainer;
  42702. /**
  42703. * 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
  42704. */
  42705. grip?: AbstractMesh;
  42706. /**
  42707. * Pointer which can be used to select objects or attach a visible laser to
  42708. */
  42709. pointer: AbstractMesh;
  42710. private _gamepadMode;
  42711. /**
  42712. * If available, this is the gamepad object related to this controller.
  42713. * Using this object it is possible to get click events and trackpad changes of the
  42714. * webxr controller that is currently being used.
  42715. */
  42716. gamepadController?: WebVRController;
  42717. /**
  42718. * Event that fires when the controller is removed/disposed
  42719. */
  42720. onDisposeObservable: Observable<{}>;
  42721. private _tmpQuaternion;
  42722. private _tmpVector;
  42723. /**
  42724. * Creates the controller
  42725. * @see https://doc.babylonjs.com/how_to/webxr
  42726. * @param scene the scene which the controller should be associated to
  42727. * @param inputSource the underlying input source for the controller
  42728. * @param parentContainer parent that the controller meshes should be children of
  42729. */
  42730. constructor(scene: Scene,
  42731. /** The underlying input source for the controller */
  42732. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42733. /**
  42734. * Updates the controller pose based on the given XRFrame
  42735. * @param xrFrame xr frame to update the pose with
  42736. * @param referenceSpace reference space to use
  42737. */
  42738. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42739. /**
  42740. * Gets a world space ray coming from the controller
  42741. * @param result the resulting ray
  42742. */
  42743. getWorldPointerRayToRef(result: Ray): void;
  42744. /**
  42745. * Get the scene associated with this controller
  42746. * @returns the scene object
  42747. */
  42748. getScene(): Scene;
  42749. /**
  42750. * Disposes of the object
  42751. */
  42752. dispose(): void;
  42753. }
  42754. }
  42755. declare module BABYLON {
  42756. /**
  42757. * XR input used to track XR inputs such as controllers/rays
  42758. */
  42759. export class WebXRInput implements IDisposable {
  42760. /**
  42761. * Base experience the input listens to
  42762. */
  42763. baseExperience: WebXRExperienceHelper;
  42764. /**
  42765. * XR controllers being tracked
  42766. */
  42767. controllers: Array<WebXRController>;
  42768. private _frameObserver;
  42769. private _stateObserver;
  42770. /**
  42771. * Event when a controller has been connected/added
  42772. */
  42773. onControllerAddedObservable: Observable<WebXRController>;
  42774. /**
  42775. * Event when a controller has been removed/disconnected
  42776. */
  42777. onControllerRemovedObservable: Observable<WebXRController>;
  42778. /**
  42779. * Initializes the WebXRInput
  42780. * @param baseExperience experience helper which the input should be created for
  42781. */
  42782. constructor(
  42783. /**
  42784. * Base experience the input listens to
  42785. */
  42786. baseExperience: WebXRExperienceHelper);
  42787. private _onInputSourcesChange;
  42788. private _addAndRemoveControllers;
  42789. /**
  42790. * Disposes of the object
  42791. */
  42792. dispose(): void;
  42793. }
  42794. }
  42795. declare module BABYLON {
  42796. /**
  42797. * Class used to represent data loading progression
  42798. */
  42799. export class SceneLoaderProgressEvent {
  42800. /** defines if data length to load can be evaluated */
  42801. readonly lengthComputable: boolean;
  42802. /** defines the loaded data length */
  42803. readonly loaded: number;
  42804. /** defines the data length to load */
  42805. readonly total: number;
  42806. /**
  42807. * Create a new progress event
  42808. * @param lengthComputable defines if data length to load can be evaluated
  42809. * @param loaded defines the loaded data length
  42810. * @param total defines the data length to load
  42811. */
  42812. constructor(
  42813. /** defines if data length to load can be evaluated */
  42814. lengthComputable: boolean,
  42815. /** defines the loaded data length */
  42816. loaded: number,
  42817. /** defines the data length to load */
  42818. total: number);
  42819. /**
  42820. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42821. * @param event defines the source event
  42822. * @returns a new SceneLoaderProgressEvent
  42823. */
  42824. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42825. }
  42826. /**
  42827. * Interface used by SceneLoader plugins to define supported file extensions
  42828. */
  42829. export interface ISceneLoaderPluginExtensions {
  42830. /**
  42831. * Defines the list of supported extensions
  42832. */
  42833. [extension: string]: {
  42834. isBinary: boolean;
  42835. };
  42836. }
  42837. /**
  42838. * Interface used by SceneLoader plugin factory
  42839. */
  42840. export interface ISceneLoaderPluginFactory {
  42841. /**
  42842. * Defines the name of the factory
  42843. */
  42844. name: string;
  42845. /**
  42846. * Function called to create a new plugin
  42847. * @return the new plugin
  42848. */
  42849. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42850. /**
  42851. * The callback that returns true if the data can be directly loaded.
  42852. * @param data string containing the file data
  42853. * @returns if the data can be loaded directly
  42854. */
  42855. canDirectLoad?(data: string): boolean;
  42856. }
  42857. /**
  42858. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42859. */
  42860. export interface ISceneLoaderPluginBase {
  42861. /**
  42862. * The friendly name of this plugin.
  42863. */
  42864. name: string;
  42865. /**
  42866. * The file extensions supported by this plugin.
  42867. */
  42868. extensions: string | ISceneLoaderPluginExtensions;
  42869. /**
  42870. * The callback called when loading from a url.
  42871. * @param scene scene loading this url
  42872. * @param url url to load
  42873. * @param onSuccess callback called when the file successfully loads
  42874. * @param onProgress callback called while file is loading (if the server supports this mode)
  42875. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42876. * @param onError callback called when the file fails to load
  42877. * @returns a file request object
  42878. */
  42879. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42880. /**
  42881. * The callback called when loading from a file object.
  42882. * @param scene scene loading this file
  42883. * @param file defines the file to load
  42884. * @param onSuccess defines the callback to call when data is loaded
  42885. * @param onProgress defines the callback to call during loading process
  42886. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42887. * @param onError defines the callback to call when an error occurs
  42888. * @returns a file request object
  42889. */
  42890. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42891. /**
  42892. * The callback that returns true if the data can be directly loaded.
  42893. * @param data string containing the file data
  42894. * @returns if the data can be loaded directly
  42895. */
  42896. canDirectLoad?(data: string): boolean;
  42897. /**
  42898. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42899. * @param scene scene loading this data
  42900. * @param data string containing the data
  42901. * @returns data to pass to the plugin
  42902. */
  42903. directLoad?(scene: Scene, data: string): any;
  42904. /**
  42905. * The callback that allows custom handling of the root url based on the response url.
  42906. * @param rootUrl the original root url
  42907. * @param responseURL the response url if available
  42908. * @returns the new root url
  42909. */
  42910. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42911. }
  42912. /**
  42913. * Interface used to define a SceneLoader plugin
  42914. */
  42915. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42916. /**
  42917. * Import meshes into a scene.
  42918. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42919. * @param scene The scene to import into
  42920. * @param data The data to import
  42921. * @param rootUrl The root url for scene and resources
  42922. * @param meshes The meshes array to import into
  42923. * @param particleSystems The particle systems array to import into
  42924. * @param skeletons The skeletons array to import into
  42925. * @param onError The callback when import fails
  42926. * @returns True if successful or false otherwise
  42927. */
  42928. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42929. /**
  42930. * Load into a scene.
  42931. * @param scene The scene to load into
  42932. * @param data The data to import
  42933. * @param rootUrl The root url for scene and resources
  42934. * @param onError The callback when import fails
  42935. * @returns True if successful or false otherwise
  42936. */
  42937. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42938. /**
  42939. * Load into an asset container.
  42940. * @param scene The scene to load into
  42941. * @param data The data to import
  42942. * @param rootUrl The root url for scene and resources
  42943. * @param onError The callback when import fails
  42944. * @returns The loaded asset container
  42945. */
  42946. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42947. }
  42948. /**
  42949. * Interface used to define an async SceneLoader plugin
  42950. */
  42951. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42952. /**
  42953. * Import meshes into a scene.
  42954. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42955. * @param scene The scene to import into
  42956. * @param data The data to import
  42957. * @param rootUrl The root url for scene and resources
  42958. * @param onProgress The callback when the load progresses
  42959. * @param fileName Defines the name of the file to load
  42960. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42961. */
  42962. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42963. meshes: AbstractMesh[];
  42964. particleSystems: IParticleSystem[];
  42965. skeletons: Skeleton[];
  42966. animationGroups: AnimationGroup[];
  42967. }>;
  42968. /**
  42969. * Load into a scene.
  42970. * @param scene The scene to load into
  42971. * @param data The data to import
  42972. * @param rootUrl The root url for scene and resources
  42973. * @param onProgress The callback when the load progresses
  42974. * @param fileName Defines the name of the file to load
  42975. * @returns Nothing
  42976. */
  42977. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42978. /**
  42979. * Load into an asset container.
  42980. * @param scene The scene to load into
  42981. * @param data The data to import
  42982. * @param rootUrl The root url for scene and resources
  42983. * @param onProgress The callback when the load progresses
  42984. * @param fileName Defines the name of the file to load
  42985. * @returns The loaded asset container
  42986. */
  42987. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42988. }
  42989. /**
  42990. * Mode that determines how to handle old animation groups before loading new ones.
  42991. */
  42992. export enum SceneLoaderAnimationGroupLoadingMode {
  42993. /**
  42994. * Reset all old animations to initial state then dispose them.
  42995. */
  42996. Clean = 0,
  42997. /**
  42998. * Stop all old animations.
  42999. */
  43000. Stop = 1,
  43001. /**
  43002. * Restart old animations from first frame.
  43003. */
  43004. Sync = 2,
  43005. /**
  43006. * Old animations remains untouched.
  43007. */
  43008. NoSync = 3
  43009. }
  43010. /**
  43011. * Class used to load scene from various file formats using registered plugins
  43012. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43013. */
  43014. export class SceneLoader {
  43015. /**
  43016. * No logging while loading
  43017. */
  43018. static readonly NO_LOGGING: number;
  43019. /**
  43020. * Minimal logging while loading
  43021. */
  43022. static readonly MINIMAL_LOGGING: number;
  43023. /**
  43024. * Summary logging while loading
  43025. */
  43026. static readonly SUMMARY_LOGGING: number;
  43027. /**
  43028. * Detailled logging while loading
  43029. */
  43030. static readonly DETAILED_LOGGING: number;
  43031. /**
  43032. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43033. */
  43034. static get ForceFullSceneLoadingForIncremental(): boolean;
  43035. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43036. /**
  43037. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43038. */
  43039. static get ShowLoadingScreen(): boolean;
  43040. static set ShowLoadingScreen(value: boolean);
  43041. /**
  43042. * Defines the current logging level (while loading the scene)
  43043. * @ignorenaming
  43044. */
  43045. static get loggingLevel(): number;
  43046. static set loggingLevel(value: number);
  43047. /**
  43048. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43049. */
  43050. static get CleanBoneMatrixWeights(): boolean;
  43051. static set CleanBoneMatrixWeights(value: boolean);
  43052. /**
  43053. * Event raised when a plugin is used to load a scene
  43054. */
  43055. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43056. private static _registeredPlugins;
  43057. private static _getDefaultPlugin;
  43058. private static _getPluginForExtension;
  43059. private static _getPluginForDirectLoad;
  43060. private static _getPluginForFilename;
  43061. private static _getDirectLoad;
  43062. private static _loadData;
  43063. private static _getFileInfo;
  43064. /**
  43065. * Gets a plugin that can load the given extension
  43066. * @param extension defines the extension to load
  43067. * @returns a plugin or null if none works
  43068. */
  43069. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43070. /**
  43071. * Gets a boolean indicating that the given extension can be loaded
  43072. * @param extension defines the extension to load
  43073. * @returns true if the extension is supported
  43074. */
  43075. static IsPluginForExtensionAvailable(extension: string): boolean;
  43076. /**
  43077. * Adds a new plugin to the list of registered plugins
  43078. * @param plugin defines the plugin to add
  43079. */
  43080. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43081. /**
  43082. * Import meshes into a scene
  43083. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43084. * @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)
  43085. * @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)
  43086. * @param scene the instance of BABYLON.Scene to append to
  43087. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43088. * @param onProgress a callback with a progress event for each file being loaded
  43089. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43090. * @param pluginExtension the extension used to determine the plugin
  43091. * @returns The loaded plugin
  43092. */
  43093. 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>;
  43094. /**
  43095. * Import meshes into a scene
  43096. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43097. * @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)
  43098. * @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)
  43099. * @param scene the instance of BABYLON.Scene to append to
  43100. * @param onProgress a callback with a progress event for each file being loaded
  43101. * @param pluginExtension the extension used to determine the plugin
  43102. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43103. */
  43104. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43105. meshes: AbstractMesh[];
  43106. particleSystems: IParticleSystem[];
  43107. skeletons: Skeleton[];
  43108. animationGroups: AnimationGroup[];
  43109. }>;
  43110. /**
  43111. * Load a scene
  43112. * @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)
  43113. * @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)
  43114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43115. * @param onSuccess a callback with the scene when import succeeds
  43116. * @param onProgress a callback with a progress event for each file being loaded
  43117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43118. * @param pluginExtension the extension used to determine the plugin
  43119. * @returns The loaded plugin
  43120. */
  43121. 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>;
  43122. /**
  43123. * Load a scene
  43124. * @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)
  43125. * @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)
  43126. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43127. * @param onProgress a callback with a progress event for each file being loaded
  43128. * @param pluginExtension the extension used to determine the plugin
  43129. * @returns The loaded scene
  43130. */
  43131. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43132. /**
  43133. * Append a scene
  43134. * @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)
  43135. * @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)
  43136. * @param scene is the instance of BABYLON.Scene to append to
  43137. * @param onSuccess a callback with the scene when import succeeds
  43138. * @param onProgress a callback with a progress event for each file being loaded
  43139. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43140. * @param pluginExtension the extension used to determine the plugin
  43141. * @returns The loaded plugin
  43142. */
  43143. 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>;
  43144. /**
  43145. * Append 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 scene is the instance of BABYLON.Scene to append to
  43149. * @param onProgress a callback with a progress event for each file being loaded
  43150. * @param pluginExtension the extension used to determine the plugin
  43151. * @returns The given scene
  43152. */
  43153. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43154. /**
  43155. * Load a scene into an asset container
  43156. * @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)
  43157. * @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)
  43158. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43159. * @param onSuccess a callback with the scene when import succeeds
  43160. * @param onProgress a callback with a progress event for each file being loaded
  43161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43162. * @param pluginExtension the extension used to determine the plugin
  43163. * @returns The loaded plugin
  43164. */
  43165. 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>;
  43166. /**
  43167. * Load a scene into an asset container
  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 (default: empty string)
  43170. * @param scene is the instance of Scene to append to
  43171. * @param onProgress a callback with a progress event for each file being loaded
  43172. * @param pluginExtension the extension used to determine the plugin
  43173. * @returns The loaded asset container
  43174. */
  43175. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43176. /**
  43177. * Import animations from a file into a scene
  43178. * @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)
  43179. * @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)
  43180. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43181. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43182. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43183. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43184. * @param onSuccess a callback with the scene when import succeeds
  43185. * @param onProgress a callback with a progress event for each file being loaded
  43186. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43187. */
  43188. 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;
  43189. /**
  43190. * Import animations from a file into a scene
  43191. * @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)
  43192. * @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)
  43193. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43194. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43195. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43196. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43197. * @param onSuccess a callback with the scene when import succeeds
  43198. * @param onProgress a callback with a progress event for each file being loaded
  43199. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43200. * @returns the updated scene with imported animations
  43201. */
  43202. 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>;
  43203. }
  43204. }
  43205. declare module BABYLON {
  43206. /**
  43207. * Generic Controller
  43208. */
  43209. export class GenericController extends WebVRController {
  43210. /**
  43211. * Base Url for the controller model.
  43212. */
  43213. static readonly MODEL_BASE_URL: string;
  43214. /**
  43215. * File name for the controller model.
  43216. */
  43217. static readonly MODEL_FILENAME: string;
  43218. /**
  43219. * Creates a new GenericController from a gamepad
  43220. * @param vrGamepad the gamepad that the controller should be created from
  43221. */
  43222. constructor(vrGamepad: any);
  43223. /**
  43224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43225. * @param scene scene in which to add meshes
  43226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43227. */
  43228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43229. /**
  43230. * Called once for each button that changed state since the last frame
  43231. * @param buttonIdx Which button index changed
  43232. * @param state New state of the button
  43233. * @param changes Which properties on the state changed since last frame
  43234. */
  43235. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43236. }
  43237. }
  43238. declare module BABYLON {
  43239. /**
  43240. * Defines the WindowsMotionController object that the state of the windows motion controller
  43241. */
  43242. export class WindowsMotionController extends WebVRController {
  43243. /**
  43244. * The base url used to load the left and right controller models
  43245. */
  43246. static MODEL_BASE_URL: string;
  43247. /**
  43248. * The name of the left controller model file
  43249. */
  43250. static MODEL_LEFT_FILENAME: string;
  43251. /**
  43252. * The name of the right controller model file
  43253. */
  43254. static MODEL_RIGHT_FILENAME: string;
  43255. /**
  43256. * The controller name prefix for this controller type
  43257. */
  43258. static readonly GAMEPAD_ID_PREFIX: string;
  43259. /**
  43260. * The controller id pattern for this controller type
  43261. */
  43262. private static readonly GAMEPAD_ID_PATTERN;
  43263. private _loadedMeshInfo;
  43264. protected readonly _mapping: {
  43265. buttons: string[];
  43266. buttonMeshNames: {
  43267. 'trigger': string;
  43268. 'menu': string;
  43269. 'grip': string;
  43270. 'thumbstick': string;
  43271. 'trackpad': string;
  43272. };
  43273. buttonObservableNames: {
  43274. 'trigger': string;
  43275. 'menu': string;
  43276. 'grip': string;
  43277. 'thumbstick': string;
  43278. 'trackpad': string;
  43279. };
  43280. axisMeshNames: string[];
  43281. pointingPoseMeshName: string;
  43282. };
  43283. /**
  43284. * Fired when the trackpad on this controller is clicked
  43285. */
  43286. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the trackpad on this controller is modified
  43289. */
  43290. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43291. /**
  43292. * The current x and y values of this controller's trackpad
  43293. */
  43294. trackpad: StickValues;
  43295. /**
  43296. * Creates a new WindowsMotionController from a gamepad
  43297. * @param vrGamepad the gamepad that the controller should be created from
  43298. */
  43299. constructor(vrGamepad: any);
  43300. /**
  43301. * Fired when the trigger on this controller is modified
  43302. */
  43303. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43304. /**
  43305. * Fired when the menu button on this controller is modified
  43306. */
  43307. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43308. /**
  43309. * Fired when the grip button on this controller is modified
  43310. */
  43311. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43312. /**
  43313. * Fired when the thumbstick button on this controller is modified
  43314. */
  43315. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43316. /**
  43317. * Fired when the touchpad button on this controller is modified
  43318. */
  43319. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43320. /**
  43321. * Fired when the touchpad values on this controller are modified
  43322. */
  43323. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43324. protected _updateTrackpad(): void;
  43325. /**
  43326. * Called once per frame by the engine.
  43327. */
  43328. update(): void;
  43329. /**
  43330. * Called once for each button that changed state since the last frame
  43331. * @param buttonIdx Which button index changed
  43332. * @param state New state of the button
  43333. * @param changes Which properties on the state changed since last frame
  43334. */
  43335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43336. /**
  43337. * Moves the buttons on the controller mesh based on their current state
  43338. * @param buttonName the name of the button to move
  43339. * @param buttonValue the value of the button which determines the buttons new position
  43340. */
  43341. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43342. /**
  43343. * Moves the axis on the controller mesh based on its current state
  43344. * @param axis the index of the axis
  43345. * @param axisValue the value of the axis which determines the meshes new position
  43346. * @hidden
  43347. */
  43348. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43349. /**
  43350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43351. * @param scene scene in which to add meshes
  43352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43353. */
  43354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43355. /**
  43356. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43357. * can be transformed by button presses and axes values, based on this._mapping.
  43358. *
  43359. * @param scene scene in which the meshes exist
  43360. * @param meshes list of meshes that make up the controller model to process
  43361. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43362. */
  43363. private processModel;
  43364. private createMeshInfo;
  43365. /**
  43366. * Gets the ray of the controller in the direction the controller is pointing
  43367. * @param length the length the resulting ray should be
  43368. * @returns a ray in the direction the controller is pointing
  43369. */
  43370. getForwardRay(length?: number): Ray;
  43371. /**
  43372. * Disposes of the controller
  43373. */
  43374. dispose(): void;
  43375. }
  43376. /**
  43377. * This class represents a new windows motion controller in XR.
  43378. */
  43379. export class XRWindowsMotionController extends WindowsMotionController {
  43380. /**
  43381. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43382. */
  43383. protected readonly _mapping: {
  43384. buttons: string[];
  43385. buttonMeshNames: {
  43386. 'trigger': string;
  43387. 'menu': string;
  43388. 'grip': string;
  43389. 'thumbstick': string;
  43390. 'trackpad': string;
  43391. };
  43392. buttonObservableNames: {
  43393. 'trigger': string;
  43394. 'menu': string;
  43395. 'grip': string;
  43396. 'thumbstick': string;
  43397. 'trackpad': string;
  43398. };
  43399. axisMeshNames: string[];
  43400. pointingPoseMeshName: string;
  43401. };
  43402. /**
  43403. * Construct a new XR-Based windows motion controller
  43404. *
  43405. * @param gamepadInfo the gamepad object from the browser
  43406. */
  43407. constructor(gamepadInfo: any);
  43408. /**
  43409. * holds the thumbstick values (X,Y)
  43410. */
  43411. thumbstickValues: StickValues;
  43412. /**
  43413. * Fired when the thumbstick on this controller is clicked
  43414. */
  43415. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43416. /**
  43417. * Fired when the thumbstick on this controller is modified
  43418. */
  43419. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43420. /**
  43421. * Fired when the touchpad button on this controller is modified
  43422. */
  43423. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43424. /**
  43425. * Fired when the touchpad values on this controller are modified
  43426. */
  43427. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43428. /**
  43429. * Fired when the thumbstick button on this controller is modified
  43430. * here to prevent breaking changes
  43431. */
  43432. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43433. /**
  43434. * updating the thumbstick(!) and not the trackpad.
  43435. * This is named this way due to the difference between WebVR and XR and to avoid
  43436. * changing the parent class.
  43437. */
  43438. protected _updateTrackpad(): void;
  43439. /**
  43440. * Disposes the class with joy
  43441. */
  43442. dispose(): void;
  43443. }
  43444. }
  43445. declare module BABYLON {
  43446. /**
  43447. * Oculus Touch Controller
  43448. */
  43449. export class OculusTouchController extends WebVRController {
  43450. /**
  43451. * Base Url for the controller model.
  43452. */
  43453. static MODEL_BASE_URL: string;
  43454. /**
  43455. * File name for the left controller model.
  43456. */
  43457. static MODEL_LEFT_FILENAME: string;
  43458. /**
  43459. * File name for the right controller model.
  43460. */
  43461. static MODEL_RIGHT_FILENAME: string;
  43462. /**
  43463. * Base Url for the Quest controller model.
  43464. */
  43465. static QUEST_MODEL_BASE_URL: string;
  43466. /**
  43467. * @hidden
  43468. * If the controllers are running on a device that needs the updated Quest controller models
  43469. */
  43470. static _IsQuest: boolean;
  43471. /**
  43472. * Fired when the secondary trigger on this controller is modified
  43473. */
  43474. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43475. /**
  43476. * Fired when the thumb rest on this controller is modified
  43477. */
  43478. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Creates a new OculusTouchController from a gamepad
  43481. * @param vrGamepad the gamepad that the controller should be created from
  43482. */
  43483. constructor(vrGamepad: any);
  43484. /**
  43485. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43486. * @param scene scene in which to add meshes
  43487. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43488. */
  43489. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43490. /**
  43491. * Fired when the A button on this controller is modified
  43492. */
  43493. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43494. /**
  43495. * Fired when the B button on this controller is modified
  43496. */
  43497. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43498. /**
  43499. * Fired when the X button on this controller is modified
  43500. */
  43501. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43502. /**
  43503. * Fired when the Y button on this controller is modified
  43504. */
  43505. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43506. /**
  43507. * Called once for each button that changed state since the last frame
  43508. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43509. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43510. * 2) secondary trigger (same)
  43511. * 3) A (right) X (left), touch, pressed = value
  43512. * 4) B / Y
  43513. * 5) thumb rest
  43514. * @param buttonIdx Which button index changed
  43515. * @param state New state of the button
  43516. * @param changes Which properties on the state changed since last frame
  43517. */
  43518. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43519. }
  43520. }
  43521. declare module BABYLON {
  43522. /**
  43523. * Vive Controller
  43524. */
  43525. export class ViveController extends WebVRController {
  43526. /**
  43527. * Base Url for the controller model.
  43528. */
  43529. static MODEL_BASE_URL: string;
  43530. /**
  43531. * File name for the controller model.
  43532. */
  43533. static MODEL_FILENAME: string;
  43534. /**
  43535. * Creates a new ViveController from a gamepad
  43536. * @param vrGamepad the gamepad that the controller should be created from
  43537. */
  43538. constructor(vrGamepad: any);
  43539. /**
  43540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43541. * @param scene scene in which to add meshes
  43542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43543. */
  43544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43545. /**
  43546. * Fired when the left button on this controller is modified
  43547. */
  43548. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43549. /**
  43550. * Fired when the right button on this controller is modified
  43551. */
  43552. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43553. /**
  43554. * Fired when the menu button on this controller is modified
  43555. */
  43556. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * Vive mapping:
  43560. * 0: touchpad
  43561. * 1: trigger
  43562. * 2: left AND right buttons
  43563. * 3: menu button
  43564. * @param buttonIdx Which button index changed
  43565. * @param state New state of the button
  43566. * @param changes Which properties on the state changed since last frame
  43567. */
  43568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43569. }
  43570. }
  43571. declare module BABYLON {
  43572. /**
  43573. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43574. */
  43575. export class WebXRControllerModelLoader {
  43576. /**
  43577. * an observable that triggers when a new model (the mesh itself) was initialized.
  43578. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43579. */
  43580. onControllerModelLoaded: Observable<WebXRController>;
  43581. /**
  43582. * Creates the WebXRControllerModelLoader
  43583. * @param input xr input that creates the controllers
  43584. */
  43585. constructor(input: WebXRInput);
  43586. }
  43587. }
  43588. declare module BABYLON {
  43589. /**
  43590. * Handles pointer input automatically for the pointer of XR controllers
  43591. */
  43592. export class WebXRControllerPointerSelection {
  43593. private static _idCounter;
  43594. private _tmpRay;
  43595. /**
  43596. * Creates a WebXRControllerPointerSelection
  43597. * @param input input manager to setup pointer selection
  43598. */
  43599. constructor(input: WebXRInput);
  43600. private _convertNormalToDirectionOfRay;
  43601. private _updatePointerDistance;
  43602. }
  43603. }
  43604. declare module BABYLON {
  43605. /**
  43606. * Enables teleportation
  43607. */
  43608. export class WebXRControllerTeleportation {
  43609. private _teleportationFillColor;
  43610. private _teleportationBorderColor;
  43611. private _tmpRay;
  43612. private _tmpVector;
  43613. /**
  43614. * when set to true (default) teleportation will wait for thumbstick changes.
  43615. * When set to false teleportation will be disabled.
  43616. *
  43617. * If set to false while teleporting results can be unexpected.
  43618. */
  43619. enabled: boolean;
  43620. /**
  43621. * Creates a WebXRControllerTeleportation
  43622. * @param input input manager to add teleportation to
  43623. * @param floorMeshes floormeshes which can be teleported to
  43624. */
  43625. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43626. }
  43627. }
  43628. declare module BABYLON {
  43629. /**
  43630. * Button which can be used to enter a different mode of XR
  43631. */
  43632. export class WebXREnterExitUIButton {
  43633. /** button element */
  43634. element: HTMLElement;
  43635. /** XR initialization options for the button */
  43636. sessionMode: XRSessionMode;
  43637. /** Reference space type */
  43638. referenceSpaceType: XRReferenceSpaceType;
  43639. /**
  43640. * Creates a WebXREnterExitUIButton
  43641. * @param element button element
  43642. * @param sessionMode XR initialization session mode
  43643. * @param referenceSpaceType the type of reference space to be used
  43644. */
  43645. constructor(
  43646. /** button element */
  43647. element: HTMLElement,
  43648. /** XR initialization options for the button */
  43649. sessionMode: XRSessionMode,
  43650. /** Reference space type */
  43651. referenceSpaceType: XRReferenceSpaceType);
  43652. /**
  43653. * Overwritable function which can be used to update the button's visuals when the state changes
  43654. * @param activeButton the current active button in the UI
  43655. */
  43656. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43657. }
  43658. /**
  43659. * Options to create the webXR UI
  43660. */
  43661. export class WebXREnterExitUIOptions {
  43662. /**
  43663. * Context to enter xr with
  43664. */
  43665. renderTarget?: Nullable<WebXRRenderTarget>;
  43666. /**
  43667. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43668. */
  43669. customButtons?: Array<WebXREnterExitUIButton>;
  43670. /**
  43671. * A session mode to use when creating the default button.
  43672. * Default is immersive-vr
  43673. */
  43674. sessionMode?: XRSessionMode;
  43675. /**
  43676. * A reference space type to use when creating the default button.
  43677. * Default is local-floor
  43678. */
  43679. referenceSpaceType?: XRReferenceSpaceType;
  43680. }
  43681. /**
  43682. * UI to allow the user to enter/exit XR mode
  43683. */
  43684. export class WebXREnterExitUI implements IDisposable {
  43685. private scene;
  43686. /** version of the options passed to this UI */
  43687. options: WebXREnterExitUIOptions;
  43688. private _overlay;
  43689. private _buttons;
  43690. private _activeButton;
  43691. /**
  43692. * Fired every time the active button is changed.
  43693. *
  43694. * When xr is entered via a button that launches xr that button will be the callback parameter
  43695. *
  43696. * When exiting xr the callback parameter will be null)
  43697. */
  43698. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43699. /**
  43700. * Creates UI to allow the user to enter/exit XR mode
  43701. * @param scene the scene to add the ui to
  43702. * @param helper the xr experience helper to enter/exit xr with
  43703. * @param options options to configure the UI
  43704. * @returns the created ui
  43705. */
  43706. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43707. /**
  43708. *
  43709. * @param scene babylon scene object to use
  43710. * @param options (read-only) version of the options passed to this UI
  43711. */
  43712. private constructor();
  43713. private _updateButtons;
  43714. /**
  43715. * Disposes of the object
  43716. */
  43717. dispose(): void;
  43718. }
  43719. }
  43720. declare module BABYLON {
  43721. /**
  43722. * Options for the default xr helper
  43723. */
  43724. export class WebXRDefaultExperienceOptions {
  43725. /**
  43726. * Floor meshes that should be used for teleporting
  43727. */
  43728. floorMeshes: Array<AbstractMesh>;
  43729. /**
  43730. * Enable or disable default UI to enter XR
  43731. */
  43732. disableDefaultUI?: boolean;
  43733. /**
  43734. * optional configuration for the output canvas
  43735. */
  43736. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43737. /**
  43738. * optional UI options. This can be used among other to change session mode and reference space type
  43739. */
  43740. uiOptions?: WebXREnterExitUIOptions;
  43741. }
  43742. /**
  43743. * Default experience which provides a similar setup to the previous webVRExperience
  43744. */
  43745. export class WebXRDefaultExperience {
  43746. /**
  43747. * Base experience
  43748. */
  43749. baseExperience: WebXRExperienceHelper;
  43750. /**
  43751. * Input experience extension
  43752. */
  43753. input: WebXRInput;
  43754. /**
  43755. * Loads the controller models
  43756. */
  43757. controllerModelLoader: WebXRControllerModelLoader;
  43758. /**
  43759. * Enables laser pointer and selection
  43760. */
  43761. pointerSelection: WebXRControllerPointerSelection;
  43762. /**
  43763. * Enables teleportation
  43764. */
  43765. teleportation: WebXRControllerTeleportation;
  43766. /**
  43767. * Enables ui for entering/exiting xr
  43768. */
  43769. enterExitUI: WebXREnterExitUI;
  43770. /**
  43771. * Default target xr should render to
  43772. */
  43773. renderTarget: WebXRRenderTarget;
  43774. /**
  43775. * Creates the default xr experience
  43776. * @param scene scene
  43777. * @param options options for basic configuration
  43778. * @returns resulting WebXRDefaultExperience
  43779. */
  43780. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43781. private constructor();
  43782. /**
  43783. * DIsposes of the experience helper
  43784. */
  43785. dispose(): void;
  43786. }
  43787. }
  43788. declare module BABYLON {
  43789. /**
  43790. * Options to modify the vr teleportation behavior.
  43791. */
  43792. export interface VRTeleportationOptions {
  43793. /**
  43794. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43795. */
  43796. floorMeshName?: string;
  43797. /**
  43798. * A list of meshes to be used as the teleportation floor. (default: empty)
  43799. */
  43800. floorMeshes?: Mesh[];
  43801. /**
  43802. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43803. */
  43804. teleportationMode?: number;
  43805. /**
  43806. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43807. */
  43808. teleportationTime?: number;
  43809. /**
  43810. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43811. */
  43812. teleportationSpeed?: number;
  43813. /**
  43814. * The easing function used in the animation or null for Linear. (default CircleEase)
  43815. */
  43816. easingFunction?: EasingFunction;
  43817. }
  43818. /**
  43819. * Options to modify the vr experience helper's behavior.
  43820. */
  43821. export interface VRExperienceHelperOptions extends WebVROptions {
  43822. /**
  43823. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43824. */
  43825. createDeviceOrientationCamera?: boolean;
  43826. /**
  43827. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43828. */
  43829. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43830. /**
  43831. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43832. */
  43833. laserToggle?: boolean;
  43834. /**
  43835. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43836. */
  43837. floorMeshes?: Mesh[];
  43838. /**
  43839. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43840. */
  43841. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43842. /**
  43843. * Defines if WebXR should be used instead of WebVR (if available)
  43844. */
  43845. useXR?: boolean;
  43846. }
  43847. /**
  43848. * Event containing information after VR has been entered
  43849. */
  43850. export class OnAfterEnteringVRObservableEvent {
  43851. /**
  43852. * If entering vr was successful
  43853. */
  43854. success: boolean;
  43855. }
  43856. /**
  43857. * Helps to quickly add VR support to an existing scene.
  43858. * See http://doc.babylonjs.com/how_to/webvr_helper
  43859. */
  43860. export class VRExperienceHelper {
  43861. /** Options to modify the vr experience helper's behavior. */
  43862. webVROptions: VRExperienceHelperOptions;
  43863. private _scene;
  43864. private _position;
  43865. private _btnVR;
  43866. private _btnVRDisplayed;
  43867. private _webVRsupported;
  43868. private _webVRready;
  43869. private _webVRrequesting;
  43870. private _webVRpresenting;
  43871. private _hasEnteredVR;
  43872. private _fullscreenVRpresenting;
  43873. private _inputElement;
  43874. private _webVRCamera;
  43875. private _vrDeviceOrientationCamera;
  43876. private _deviceOrientationCamera;
  43877. private _existingCamera;
  43878. private _onKeyDown;
  43879. private _onVrDisplayPresentChange;
  43880. private _onVRDisplayChanged;
  43881. private _onVRRequestPresentStart;
  43882. private _onVRRequestPresentComplete;
  43883. /**
  43884. * 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)
  43885. */
  43886. enableGazeEvenWhenNoPointerLock: boolean;
  43887. /**
  43888. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43889. */
  43890. exitVROnDoubleTap: boolean;
  43891. /**
  43892. * Observable raised right before entering VR.
  43893. */
  43894. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43895. /**
  43896. * Observable raised when entering VR has completed.
  43897. */
  43898. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43899. /**
  43900. * Observable raised when exiting VR.
  43901. */
  43902. onExitingVRObservable: Observable<VRExperienceHelper>;
  43903. /**
  43904. * Observable raised when controller mesh is loaded.
  43905. */
  43906. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43907. /** Return this.onEnteringVRObservable
  43908. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43909. */
  43910. get onEnteringVR(): Observable<VRExperienceHelper>;
  43911. /** Return this.onExitingVRObservable
  43912. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43913. */
  43914. get onExitingVR(): Observable<VRExperienceHelper>;
  43915. /** Return this.onControllerMeshLoadedObservable
  43916. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43917. */
  43918. get onControllerMeshLoaded(): Observable<WebVRController>;
  43919. private _rayLength;
  43920. private _useCustomVRButton;
  43921. private _teleportationRequested;
  43922. private _teleportActive;
  43923. private _floorMeshName;
  43924. private _floorMeshesCollection;
  43925. private _teleportationMode;
  43926. private _teleportationTime;
  43927. private _teleportationSpeed;
  43928. private _teleportationEasing;
  43929. private _rotationAllowed;
  43930. private _teleportBackwardsVector;
  43931. private _teleportationTarget;
  43932. private _isDefaultTeleportationTarget;
  43933. private _postProcessMove;
  43934. private _teleportationFillColor;
  43935. private _teleportationBorderColor;
  43936. private _rotationAngle;
  43937. private _haloCenter;
  43938. private _cameraGazer;
  43939. private _padSensibilityUp;
  43940. private _padSensibilityDown;
  43941. private _leftController;
  43942. private _rightController;
  43943. private _gazeColor;
  43944. private _laserColor;
  43945. private _pickedLaserColor;
  43946. private _pickedGazeColor;
  43947. /**
  43948. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43949. */
  43950. onNewMeshSelected: Observable<AbstractMesh>;
  43951. /**
  43952. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43953. * This observable will provide the mesh and the controller used to select the mesh
  43954. */
  43955. onMeshSelectedWithController: Observable<{
  43956. mesh: AbstractMesh;
  43957. controller: WebVRController;
  43958. }>;
  43959. /**
  43960. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43961. */
  43962. onNewMeshPicked: Observable<PickingInfo>;
  43963. private _circleEase;
  43964. /**
  43965. * Observable raised before camera teleportation
  43966. */
  43967. onBeforeCameraTeleport: Observable<Vector3>;
  43968. /**
  43969. * Observable raised after camera teleportation
  43970. */
  43971. onAfterCameraTeleport: Observable<Vector3>;
  43972. /**
  43973. * Observable raised when current selected mesh gets unselected
  43974. */
  43975. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43976. private _raySelectionPredicate;
  43977. /**
  43978. * To be optionaly changed by user to define custom ray selection
  43979. */
  43980. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43981. /**
  43982. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43983. */
  43984. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43985. /**
  43986. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43987. */
  43988. teleportationEnabled: boolean;
  43989. private _defaultHeight;
  43990. private _teleportationInitialized;
  43991. private _interactionsEnabled;
  43992. private _interactionsRequested;
  43993. private _displayGaze;
  43994. private _displayLaserPointer;
  43995. /**
  43996. * The mesh used to display where the user is going to teleport.
  43997. */
  43998. get teleportationTarget(): Mesh;
  43999. /**
  44000. * Sets the mesh to be used to display where the user is going to teleport.
  44001. */
  44002. set teleportationTarget(value: Mesh);
  44003. /**
  44004. * 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
  44005. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44006. * See http://doc.babylonjs.com/resources/baking_transformations
  44007. */
  44008. get gazeTrackerMesh(): Mesh;
  44009. set gazeTrackerMesh(value: Mesh);
  44010. /**
  44011. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44012. */
  44013. updateGazeTrackerScale: boolean;
  44014. /**
  44015. * If the gaze trackers color should be updated when selecting meshes
  44016. */
  44017. updateGazeTrackerColor: boolean;
  44018. /**
  44019. * If the controller laser color should be updated when selecting meshes
  44020. */
  44021. updateControllerLaserColor: boolean;
  44022. /**
  44023. * The gaze tracking mesh corresponding to the left controller
  44024. */
  44025. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44026. /**
  44027. * The gaze tracking mesh corresponding to the right controller
  44028. */
  44029. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44030. /**
  44031. * If the ray of the gaze should be displayed.
  44032. */
  44033. get displayGaze(): boolean;
  44034. /**
  44035. * Sets if the ray of the gaze should be displayed.
  44036. */
  44037. set displayGaze(value: boolean);
  44038. /**
  44039. * If the ray of the LaserPointer should be displayed.
  44040. */
  44041. get displayLaserPointer(): boolean;
  44042. /**
  44043. * Sets if the ray of the LaserPointer should be displayed.
  44044. */
  44045. set displayLaserPointer(value: boolean);
  44046. /**
  44047. * The deviceOrientationCamera used as the camera when not in VR.
  44048. */
  44049. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44050. /**
  44051. * Based on the current WebVR support, returns the current VR camera used.
  44052. */
  44053. get currentVRCamera(): Nullable<Camera>;
  44054. /**
  44055. * The webVRCamera which is used when in VR.
  44056. */
  44057. get webVRCamera(): WebVRFreeCamera;
  44058. /**
  44059. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44060. */
  44061. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44062. /**
  44063. * The html button that is used to trigger entering into VR.
  44064. */
  44065. get vrButton(): Nullable<HTMLButtonElement>;
  44066. private get _teleportationRequestInitiated();
  44067. /**
  44068. * Defines wether or not Pointer lock should be requested when switching to
  44069. * full screen.
  44070. */
  44071. requestPointerLockOnFullScreen: boolean;
  44072. /**
  44073. * If asking to force XR, this will be populated with the default xr experience
  44074. */
  44075. xr: WebXRDefaultExperience;
  44076. /**
  44077. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44078. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44079. */
  44080. xrTestDone: boolean;
  44081. /**
  44082. * Instantiates a VRExperienceHelper.
  44083. * Helps to quickly add VR support to an existing scene.
  44084. * @param scene The scene the VRExperienceHelper belongs to.
  44085. * @param webVROptions Options to modify the vr experience helper's behavior.
  44086. */
  44087. constructor(scene: Scene,
  44088. /** Options to modify the vr experience helper's behavior. */
  44089. webVROptions?: VRExperienceHelperOptions);
  44090. private completeVRInit;
  44091. private _onDefaultMeshLoaded;
  44092. private _onResize;
  44093. private _onFullscreenChange;
  44094. /**
  44095. * Gets a value indicating if we are currently in VR mode.
  44096. */
  44097. get isInVRMode(): boolean;
  44098. private onVrDisplayPresentChange;
  44099. private onVRDisplayChanged;
  44100. private moveButtonToBottomRight;
  44101. private displayVRButton;
  44102. private updateButtonVisibility;
  44103. private _cachedAngularSensibility;
  44104. /**
  44105. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44106. * Otherwise, will use the fullscreen API.
  44107. */
  44108. enterVR(): void;
  44109. /**
  44110. * Attempt to exit VR, or fullscreen.
  44111. */
  44112. exitVR(): void;
  44113. /**
  44114. * The position of the vr experience helper.
  44115. */
  44116. get position(): Vector3;
  44117. /**
  44118. * Sets the position of the vr experience helper.
  44119. */
  44120. set position(value: Vector3);
  44121. /**
  44122. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44123. */
  44124. enableInteractions(): void;
  44125. private get _noControllerIsActive();
  44126. private beforeRender;
  44127. private _isTeleportationFloor;
  44128. /**
  44129. * Adds a floor mesh to be used for teleportation.
  44130. * @param floorMesh the mesh to be used for teleportation.
  44131. */
  44132. addFloorMesh(floorMesh: Mesh): void;
  44133. /**
  44134. * Removes a floor mesh from being used for teleportation.
  44135. * @param floorMesh the mesh to be removed.
  44136. */
  44137. removeFloorMesh(floorMesh: Mesh): void;
  44138. /**
  44139. * Enables interactions and teleportation using the VR controllers and gaze.
  44140. * @param vrTeleportationOptions options to modify teleportation behavior.
  44141. */
  44142. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44143. private _onNewGamepadConnected;
  44144. private _tryEnableInteractionOnController;
  44145. private _onNewGamepadDisconnected;
  44146. private _enableInteractionOnController;
  44147. private _checkTeleportWithRay;
  44148. private _checkRotate;
  44149. private _checkTeleportBackwards;
  44150. private _enableTeleportationOnController;
  44151. private _createTeleportationCircles;
  44152. private _displayTeleportationTarget;
  44153. private _hideTeleportationTarget;
  44154. private _rotateCamera;
  44155. private _moveTeleportationSelectorTo;
  44156. private _workingVector;
  44157. private _workingQuaternion;
  44158. private _workingMatrix;
  44159. /**
  44160. * Time Constant Teleportation Mode
  44161. */
  44162. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44163. /**
  44164. * Speed Constant Teleportation Mode
  44165. */
  44166. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44167. /**
  44168. * Teleports the users feet to the desired location
  44169. * @param location The location where the user's feet should be placed
  44170. */
  44171. teleportCamera(location: Vector3): void;
  44172. private _convertNormalToDirectionOfRay;
  44173. private _castRayAndSelectObject;
  44174. private _notifySelectedMeshUnselected;
  44175. /**
  44176. * Permanently set new colors for the laser pointer
  44177. * @param color the new laser color
  44178. * @param pickedColor the new laser color when picked mesh detected
  44179. */
  44180. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44181. /**
  44182. * Permanently set new colors for the gaze pointer
  44183. * @param color the new gaze color
  44184. * @param pickedColor the new gaze color when picked mesh detected
  44185. */
  44186. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44187. /**
  44188. * Sets the color of the laser ray from the vr controllers.
  44189. * @param color new color for the ray.
  44190. */
  44191. changeLaserColor(color: Color3): void;
  44192. /**
  44193. * Sets the color of the ray from the vr headsets gaze.
  44194. * @param color new color for the ray.
  44195. */
  44196. changeGazeColor(color: Color3): void;
  44197. /**
  44198. * Exits VR and disposes of the vr experience helper
  44199. */
  44200. dispose(): void;
  44201. /**
  44202. * Gets the name of the VRExperienceHelper class
  44203. * @returns "VRExperienceHelper"
  44204. */
  44205. getClassName(): string;
  44206. }
  44207. }
  44208. declare module BABYLON {
  44209. /**
  44210. * Options used for hit testing
  44211. */
  44212. export interface IWebXRHitTestOptions {
  44213. /**
  44214. * Only test when user interacted with the scene. Default - hit test every frame
  44215. */
  44216. testOnPointerDownOnly?: boolean;
  44217. /**
  44218. * The node to use to transform the local results to world coordinates
  44219. */
  44220. worldParentNode?: TransformNode;
  44221. }
  44222. /**
  44223. * Interface defining the babylon result of raycasting/hit-test
  44224. */
  44225. export interface IWebXRHitResult {
  44226. /**
  44227. * The native hit test result
  44228. */
  44229. xrHitResult: XRHitResult;
  44230. /**
  44231. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44232. */
  44233. transformationMatrix: Matrix;
  44234. }
  44235. /**
  44236. * The currently-working hit-test module.
  44237. * Hit test (or raycasting) is used to interact with the real world.
  44238. * For further information read here - https://github.com/immersive-web/hit-test
  44239. */
  44240. export class WebXRHitTestLegacy implements IWebXRFeature {
  44241. private _xrSessionManager;
  44242. /**
  44243. * options to use when constructing this feature
  44244. */
  44245. readonly options: IWebXRHitTestOptions;
  44246. /**
  44247. * The module's name
  44248. */
  44249. static readonly Name: string;
  44250. /**
  44251. * The (Babylon) version of this module.
  44252. * This is an integer representing the implementation version.
  44253. * This number does not correspond to the webxr specs version
  44254. */
  44255. static readonly Version: number;
  44256. /**
  44257. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44258. * @param event the (select) event to use to select with
  44259. * @param referenceSpace the reference space to use for this hit test
  44260. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44261. */
  44262. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44263. /**
  44264. * execute a hit test with an XR Ray
  44265. *
  44266. * @param xrSession a native xrSession that will execute this hit test
  44267. * @param xrRay the ray (position and direction) to use for raycasting
  44268. * @param referenceSpace native XR reference space to use for the hit-test
  44269. * @param filter filter function that will filter the results
  44270. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44271. */
  44272. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44273. /**
  44274. * Triggered when new babylon (transformed) hit test results are available
  44275. */
  44276. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44277. /**
  44278. * Creates a new instance of the (legacy version) hit test feature
  44279. * @param _xrSessionManager an instance of WebXRSessionManager
  44280. * @param options options to use when constructing this feature
  44281. */
  44282. constructor(_xrSessionManager: WebXRSessionManager,
  44283. /**
  44284. * options to use when constructing this feature
  44285. */
  44286. options?: IWebXRHitTestOptions);
  44287. private _onSelectEnabled;
  44288. private _xrFrameObserver;
  44289. private _attached;
  44290. /**
  44291. * Populated with the last native XR Hit Results
  44292. */
  44293. lastNativeXRHitResults: XRHitResult[];
  44294. /**
  44295. * attach this feature
  44296. * Will usually be called by the features manager
  44297. *
  44298. * @returns true if successful.
  44299. */
  44300. attach(): boolean;
  44301. /**
  44302. * detach this feature.
  44303. * Will usually be called by the features manager
  44304. *
  44305. * @returns true if successful.
  44306. */
  44307. detach(): boolean;
  44308. private _onHitTestResults;
  44309. private _onSelect;
  44310. /**
  44311. * Dispose this feature and all of the resources attached
  44312. */
  44313. dispose(): void;
  44314. }
  44315. }
  44316. declare module BABYLON {
  44317. /**
  44318. * Options used in the plane detector module
  44319. */
  44320. export interface IWebXRPlaneDetectorOptions {
  44321. /**
  44322. * The node to use to transform the local results to world coordinates
  44323. */
  44324. worldParentNode?: TransformNode;
  44325. }
  44326. /**
  44327. * A babylon interface for a webxr plane.
  44328. * A Plane is actually a polygon, built from N points in space
  44329. */
  44330. export interface IWebXRPlane {
  44331. /**
  44332. * a babylon-assigned ID for this polygon
  44333. */
  44334. id: number;
  44335. /**
  44336. * the native xr-plane object
  44337. */
  44338. xrPlane: XRPlane;
  44339. /**
  44340. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44341. */
  44342. polygonDefinition: Array<Vector3>;
  44343. /**
  44344. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44345. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44346. */
  44347. transformationMatrix: Matrix;
  44348. }
  44349. /**
  44350. * The plane detector is used to detect planes in the real world when in AR
  44351. * For more information see https://github.com/immersive-web/real-world-geometry/
  44352. */
  44353. export class WebXRPlaneDetector implements IWebXRFeature {
  44354. private _xrSessionManager;
  44355. private _options;
  44356. /**
  44357. * The module's name
  44358. */
  44359. static readonly Name: string;
  44360. /**
  44361. * The (Babylon) version of this module.
  44362. * This is an integer representing the implementation version.
  44363. * This number does not correspond to the webxr specs version
  44364. */
  44365. static readonly Version: number;
  44366. /**
  44367. * Observers registered here will be executed when a new plane was added to the session
  44368. */
  44369. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44370. /**
  44371. * Observers registered here will be executed when a plane is no longer detected in the session
  44372. */
  44373. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44374. /**
  44375. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44376. * This can execute N times every frame
  44377. */
  44378. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44379. private _enabled;
  44380. private _attached;
  44381. private _detectedPlanes;
  44382. private _lastFrameDetected;
  44383. private _observerTracked;
  44384. /**
  44385. * construct a new Plane Detector
  44386. * @param _xrSessionManager an instance of xr Session manager
  44387. * @param _options configuration to use when constructing this feature
  44388. */
  44389. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44390. /**
  44391. * attach this feature
  44392. * Will usually be called by the features manager
  44393. *
  44394. * @returns true if successful.
  44395. */
  44396. attach(): boolean;
  44397. /**
  44398. * detach this feature.
  44399. * Will usually be called by the features manager
  44400. *
  44401. * @returns true if successful.
  44402. */
  44403. detach(): boolean;
  44404. /**
  44405. * Dispose this feature and all of the resources attached
  44406. */
  44407. dispose(): void;
  44408. private _updatePlaneWithXRPlane;
  44409. /**
  44410. * avoiding using Array.find for global support.
  44411. * @param xrPlane the plane to find in the array
  44412. */
  44413. private findIndexInPlaneArray;
  44414. }
  44415. }
  44416. declare module BABYLON {
  44417. /**
  44418. * Configuration options of the anchor system
  44419. */
  44420. export interface IWebXRAnchorSystemOptions {
  44421. /**
  44422. * a node that will be used to convert local to world coordinates
  44423. */
  44424. worldParentNode?: TransformNode;
  44425. /**
  44426. * should the anchor system use plane detection.
  44427. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44428. */
  44429. usePlaneDetection?: boolean;
  44430. /**
  44431. * Should a new anchor be added every time a select event is triggered
  44432. */
  44433. addAnchorOnSelect?: boolean;
  44434. }
  44435. /**
  44436. * A babylon container for an XR Anchor
  44437. */
  44438. export interface IWebXRAnchor {
  44439. /**
  44440. * A babylon-assigned ID for this anchor
  44441. */
  44442. id: number;
  44443. /**
  44444. * The native anchor object
  44445. */
  44446. xrAnchor: XRAnchor;
  44447. /**
  44448. * Transformation matrix to apply to an object attached to this anchor
  44449. */
  44450. transformationMatrix: Matrix;
  44451. }
  44452. /**
  44453. * An implementation of the anchor system of WebXR.
  44454. * Note that the current documented implementation is not available in any browser. Future implementations
  44455. * will use the frame to create an anchor and not the session or a detected plane
  44456. * For further information see https://github.com/immersive-web/anchors/
  44457. */
  44458. export class WebXRAnchorSystem implements IWebXRFeature {
  44459. private _xrSessionManager;
  44460. private _options;
  44461. /**
  44462. * The module's name
  44463. */
  44464. static readonly Name: string;
  44465. /**
  44466. * The (Babylon) version of this module.
  44467. * This is an integer representing the implementation version.
  44468. * This number does not correspond to the webxr specs version
  44469. */
  44470. static readonly Version: number;
  44471. /**
  44472. * Observers registered here will be executed when a new anchor was added to the session
  44473. */
  44474. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44475. /**
  44476. * Observers registered here will be executed when an existing anchor updates
  44477. * This can execute N times every frame
  44478. */
  44479. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44480. /**
  44481. * Observers registered here will be executed when an anchor was removed from the session
  44482. */
  44483. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44484. private _planeDetector;
  44485. private _hitTestModule;
  44486. private _enabled;
  44487. private _attached;
  44488. private _trackedAnchors;
  44489. private _lastFrameDetected;
  44490. private _observerTracked;
  44491. /**
  44492. * constructs a new anchor system
  44493. * @param _xrSessionManager an instance of WebXRSessionManager
  44494. * @param _options configuration object for this feature
  44495. */
  44496. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44497. /**
  44498. * set the plane detector to use in order to create anchors from frames
  44499. * @param planeDetector the plane-detector module to use
  44500. * @param enable enable plane-anchors. default is true
  44501. */
  44502. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44503. /**
  44504. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44505. * @param hitTestModule the hit-test module to use.
  44506. */
  44507. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44508. /**
  44509. * attach this feature
  44510. * Will usually be called by the features manager
  44511. *
  44512. * @returns true if successful.
  44513. */
  44514. attach(): boolean;
  44515. /**
  44516. * detach this feature.
  44517. * Will usually be called by the features manager
  44518. *
  44519. * @returns true if successful.
  44520. */
  44521. detach(): boolean;
  44522. /**
  44523. * Dispose this feature and all of the resources attached
  44524. */
  44525. dispose(): void;
  44526. private _onSelect;
  44527. /**
  44528. * Add anchor at a specific XR point.
  44529. *
  44530. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44531. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44532. * @returns a promise the fulfills when the anchor was created
  44533. */
  44534. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44535. private _updateAnchorWithXRFrame;
  44536. /**
  44537. * avoiding using Array.find for global support.
  44538. * @param xrAnchor the plane to find in the array
  44539. */
  44540. private _findIndexInAnchorArray;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. /**
  44545. * Options interface for the background remover plugin
  44546. */
  44547. export interface IWebXRBackgroundRemoverOptions {
  44548. /**
  44549. * don't disable the environment helper
  44550. */
  44551. ignoreEnvironmentHelper?: boolean;
  44552. /**
  44553. * flags to configure the removal of the environment helper.
  44554. * If not set, the entire background will be removed. If set, flags should be set as well.
  44555. */
  44556. environmentHelperRemovalFlags?: {
  44557. /**
  44558. * Should the skybox be removed (default false)
  44559. */
  44560. skyBox?: boolean;
  44561. /**
  44562. * Should the ground be removed (default false)
  44563. */
  44564. ground?: boolean;
  44565. };
  44566. /**
  44567. * Further background meshes to disable when entering AR
  44568. */
  44569. backgroundMeshes?: AbstractMesh[];
  44570. }
  44571. /**
  44572. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44573. */
  44574. export class WebXRBackgroundRemover implements IWebXRFeature {
  44575. private _xrSessionManager;
  44576. /**
  44577. * read-only options to be used in this module
  44578. */
  44579. readonly options: IWebXRBackgroundRemoverOptions;
  44580. /**
  44581. * The module's name
  44582. */
  44583. static readonly Name: string;
  44584. /**
  44585. * The (Babylon) version of this module.
  44586. * This is an integer representing the implementation version.
  44587. * This number does not correspond to the webxr specs version
  44588. */
  44589. static readonly Version: number;
  44590. /**
  44591. * registered observers will be triggered when the background state changes
  44592. */
  44593. onBackgroundStateChangedObservable: Observable<boolean>;
  44594. /**
  44595. * constructs a new background remover module
  44596. * @param _xrSessionManager the session manager for this module
  44597. * @param options read-only options to be used in this module
  44598. */
  44599. constructor(_xrSessionManager: WebXRSessionManager,
  44600. /**
  44601. * read-only options to be used in this module
  44602. */
  44603. options?: IWebXRBackgroundRemoverOptions);
  44604. /**
  44605. * attach this feature
  44606. * Will usually be called by the features manager
  44607. *
  44608. * @returns true if successful.
  44609. */
  44610. attach(): boolean;
  44611. /**
  44612. * detach this feature.
  44613. * Will usually be called by the features manager
  44614. *
  44615. * @returns true if successful.
  44616. */
  44617. detach(): boolean;
  44618. private _setBackgroundState;
  44619. /**
  44620. * Dispose this feature and all of the resources attached
  44621. */
  44622. dispose(): void;
  44623. }
  44624. }
  44625. declare module BABYLON {
  44626. /**
  44627. * Contains an array of blocks representing the octree
  44628. */
  44629. export interface IOctreeContainer<T> {
  44630. /**
  44631. * Blocks within the octree
  44632. */
  44633. blocks: Array<OctreeBlock<T>>;
  44634. }
  44635. /**
  44636. * Class used to store a cell in an octree
  44637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44638. */
  44639. export class OctreeBlock<T> {
  44640. /**
  44641. * Gets the content of the current block
  44642. */
  44643. entries: T[];
  44644. /**
  44645. * Gets the list of block children
  44646. */
  44647. blocks: Array<OctreeBlock<T>>;
  44648. private _depth;
  44649. private _maxDepth;
  44650. private _capacity;
  44651. private _minPoint;
  44652. private _maxPoint;
  44653. private _boundingVectors;
  44654. private _creationFunc;
  44655. /**
  44656. * Creates a new block
  44657. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44658. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44659. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44660. * @param depth defines the current depth of this block in the octree
  44661. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44662. * @param creationFunc defines a callback to call when an element is added to the block
  44663. */
  44664. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44665. /**
  44666. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44667. */
  44668. get capacity(): number;
  44669. /**
  44670. * Gets the minimum vector (in world space) of the block's bounding box
  44671. */
  44672. get minPoint(): Vector3;
  44673. /**
  44674. * Gets the maximum vector (in world space) of the block's bounding box
  44675. */
  44676. get maxPoint(): Vector3;
  44677. /**
  44678. * Add a new element to this block
  44679. * @param entry defines the element to add
  44680. */
  44681. addEntry(entry: T): void;
  44682. /**
  44683. * Remove an element from this block
  44684. * @param entry defines the element to remove
  44685. */
  44686. removeEntry(entry: T): void;
  44687. /**
  44688. * Add an array of elements to this block
  44689. * @param entries defines the array of elements to add
  44690. */
  44691. addEntries(entries: T[]): void;
  44692. /**
  44693. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44694. * @param frustumPlanes defines the frustum planes to test
  44695. * @param selection defines the array to store current content if selection is positive
  44696. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44697. */
  44698. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44699. /**
  44700. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44701. * @param sphereCenter defines the bounding sphere center
  44702. * @param sphereRadius defines the bounding sphere radius
  44703. * @param selection defines the array to store current content if selection is positive
  44704. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44705. */
  44706. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44707. /**
  44708. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44709. * @param ray defines the ray to test with
  44710. * @param selection defines the array to store current content if selection is positive
  44711. */
  44712. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44713. /**
  44714. * Subdivide the content into child blocks (this block will then be empty)
  44715. */
  44716. createInnerBlocks(): void;
  44717. /**
  44718. * @hidden
  44719. */
  44720. 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;
  44721. }
  44722. }
  44723. declare module BABYLON {
  44724. /**
  44725. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44726. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44727. */
  44728. export class Octree<T> {
  44729. /** 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.) */
  44730. maxDepth: number;
  44731. /**
  44732. * Blocks within the octree containing objects
  44733. */
  44734. blocks: Array<OctreeBlock<T>>;
  44735. /**
  44736. * Content stored in the octree
  44737. */
  44738. dynamicContent: T[];
  44739. private _maxBlockCapacity;
  44740. private _selectionContent;
  44741. private _creationFunc;
  44742. /**
  44743. * Creates a octree
  44744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44745. * @param creationFunc function to be used to instatiate the octree
  44746. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44747. * @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.)
  44748. */
  44749. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44750. /** 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.) */
  44751. maxDepth?: number);
  44752. /**
  44753. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44754. * @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);
  44755. * @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);
  44756. * @param entries meshes to be added to the octree blocks
  44757. */
  44758. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44759. /**
  44760. * Adds a mesh to the octree
  44761. * @param entry Mesh to add to the octree
  44762. */
  44763. addMesh(entry: T): void;
  44764. /**
  44765. * Remove an element from the octree
  44766. * @param entry defines the element to remove
  44767. */
  44768. removeMesh(entry: T): void;
  44769. /**
  44770. * Selects an array of meshes within the frustum
  44771. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44772. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44773. * @returns array of meshes within the frustum
  44774. */
  44775. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44776. /**
  44777. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44778. * @param sphereCenter defines the bounding sphere center
  44779. * @param sphereRadius defines the bounding sphere radius
  44780. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44781. * @returns an array of objects that intersect the sphere
  44782. */
  44783. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44784. /**
  44785. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44786. * @param ray defines the ray to test with
  44787. * @returns array of intersected objects
  44788. */
  44789. intersectsRay(ray: Ray): SmartArray<T>;
  44790. /**
  44791. * Adds a mesh into the octree block if it intersects the block
  44792. */
  44793. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44794. /**
  44795. * Adds a submesh into the octree block if it intersects the block
  44796. */
  44797. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. interface Scene {
  44802. /**
  44803. * @hidden
  44804. * Backing Filed
  44805. */
  44806. _selectionOctree: Octree<AbstractMesh>;
  44807. /**
  44808. * Gets the octree used to boost mesh selection (picking)
  44809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44810. */
  44811. selectionOctree: Octree<AbstractMesh>;
  44812. /**
  44813. * Creates or updates the octree used to boost selection (picking)
  44814. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44815. * @param maxCapacity defines the maximum capacity per leaf
  44816. * @param maxDepth defines the maximum depth of the octree
  44817. * @returns an octree of AbstractMesh
  44818. */
  44819. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44820. }
  44821. interface AbstractMesh {
  44822. /**
  44823. * @hidden
  44824. * Backing Field
  44825. */
  44826. _submeshesOctree: Octree<SubMesh>;
  44827. /**
  44828. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44829. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44830. * @param maxCapacity defines the maximum size of each block (64 by default)
  44831. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44832. * @returns the new octree
  44833. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44835. */
  44836. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44837. }
  44838. /**
  44839. * Defines the octree scene component responsible to manage any octrees
  44840. * in a given scene.
  44841. */
  44842. export class OctreeSceneComponent {
  44843. /**
  44844. * The component name help to identify the component in the list of scene components.
  44845. */
  44846. readonly name: string;
  44847. /**
  44848. * The scene the component belongs to.
  44849. */
  44850. scene: Scene;
  44851. /**
  44852. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44853. */
  44854. readonly checksIsEnabled: boolean;
  44855. /**
  44856. * Creates a new instance of the component for the given scene
  44857. * @param scene Defines the scene to register the component in
  44858. */
  44859. constructor(scene: Scene);
  44860. /**
  44861. * Registers the component in a given scene
  44862. */
  44863. register(): void;
  44864. /**
  44865. * Return the list of active meshes
  44866. * @returns the list of active meshes
  44867. */
  44868. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44869. /**
  44870. * Return the list of active sub meshes
  44871. * @param mesh The mesh to get the candidates sub meshes from
  44872. * @returns the list of active sub meshes
  44873. */
  44874. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44875. private _tempRay;
  44876. /**
  44877. * Return the list of sub meshes intersecting with a given local ray
  44878. * @param mesh defines the mesh to find the submesh for
  44879. * @param localRay defines the ray in local space
  44880. * @returns the list of intersecting sub meshes
  44881. */
  44882. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44883. /**
  44884. * Return the list of sub meshes colliding with a collider
  44885. * @param mesh defines the mesh to find the submesh for
  44886. * @param collider defines the collider to evaluate the collision against
  44887. * @returns the list of colliding sub meshes
  44888. */
  44889. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44890. /**
  44891. * Rebuilds the elements related to this component in case of
  44892. * context lost for instance.
  44893. */
  44894. rebuild(): void;
  44895. /**
  44896. * Disposes the component and the associated ressources.
  44897. */
  44898. dispose(): void;
  44899. }
  44900. }
  44901. declare module BABYLON {
  44902. /**
  44903. * Renders a layer on top of an existing scene
  44904. */
  44905. export class UtilityLayerRenderer implements IDisposable {
  44906. /** the original scene that will be rendered on top of */
  44907. originalScene: Scene;
  44908. private _pointerCaptures;
  44909. private _lastPointerEvents;
  44910. private static _DefaultUtilityLayer;
  44911. private static _DefaultKeepDepthUtilityLayer;
  44912. private _sharedGizmoLight;
  44913. private _renderCamera;
  44914. /**
  44915. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44916. * @returns the camera that is used when rendering the utility layer
  44917. */
  44918. getRenderCamera(): Nullable<Camera>;
  44919. /**
  44920. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44921. * @param cam the camera that should be used when rendering the utility layer
  44922. */
  44923. setRenderCamera(cam: Nullable<Camera>): void;
  44924. /**
  44925. * @hidden
  44926. * Light which used by gizmos to get light shading
  44927. */
  44928. _getSharedGizmoLight(): HemisphericLight;
  44929. /**
  44930. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44931. */
  44932. pickUtilitySceneFirst: boolean;
  44933. /**
  44934. * 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)
  44935. */
  44936. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44937. /**
  44938. * 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)
  44939. */
  44940. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44941. /**
  44942. * The scene that is rendered on top of the original scene
  44943. */
  44944. utilityLayerScene: Scene;
  44945. /**
  44946. * If the utility layer should automatically be rendered on top of existing scene
  44947. */
  44948. shouldRender: boolean;
  44949. /**
  44950. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44951. */
  44952. onlyCheckPointerDownEvents: boolean;
  44953. /**
  44954. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44955. */
  44956. processAllEvents: boolean;
  44957. /**
  44958. * Observable raised when the pointer move from the utility layer scene to the main scene
  44959. */
  44960. onPointerOutObservable: Observable<number>;
  44961. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44962. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44963. private _afterRenderObserver;
  44964. private _sceneDisposeObserver;
  44965. private _originalPointerObserver;
  44966. /**
  44967. * Instantiates a UtilityLayerRenderer
  44968. * @param originalScene the original scene that will be rendered on top of
  44969. * @param handleEvents boolean indicating if the utility layer should handle events
  44970. */
  44971. constructor(
  44972. /** the original scene that will be rendered on top of */
  44973. originalScene: Scene, handleEvents?: boolean);
  44974. private _notifyObservers;
  44975. /**
  44976. * Renders the utility layers scene on top of the original scene
  44977. */
  44978. render(): void;
  44979. /**
  44980. * Disposes of the renderer
  44981. */
  44982. dispose(): void;
  44983. private _updateCamera;
  44984. }
  44985. }
  44986. declare module BABYLON {
  44987. /**
  44988. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44989. */
  44990. export class Gizmo implements IDisposable {
  44991. /** The utility layer the gizmo will be added to */
  44992. gizmoLayer: UtilityLayerRenderer;
  44993. /**
  44994. * The root mesh of the gizmo
  44995. */
  44996. _rootMesh: Mesh;
  44997. private _attachedMesh;
  44998. /**
  44999. * Ratio for the scale of the gizmo (Default: 1)
  45000. */
  45001. scaleRatio: number;
  45002. /**
  45003. * If a custom mesh has been set (Default: false)
  45004. */
  45005. protected _customMeshSet: boolean;
  45006. /**
  45007. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45008. * * When set, interactions will be enabled
  45009. */
  45010. get attachedMesh(): Nullable<AbstractMesh>;
  45011. set attachedMesh(value: Nullable<AbstractMesh>);
  45012. /**
  45013. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45014. * @param mesh The mesh to replace the default mesh of the gizmo
  45015. */
  45016. setCustomMesh(mesh: Mesh): void;
  45017. /**
  45018. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45019. */
  45020. updateGizmoRotationToMatchAttachedMesh: boolean;
  45021. /**
  45022. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45023. */
  45024. updateGizmoPositionToMatchAttachedMesh: boolean;
  45025. /**
  45026. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45027. */
  45028. updateScale: boolean;
  45029. protected _interactionsEnabled: boolean;
  45030. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45031. private _beforeRenderObserver;
  45032. private _tempVector;
  45033. /**
  45034. * Creates a gizmo
  45035. * @param gizmoLayer The utility layer the gizmo will be added to
  45036. */
  45037. constructor(
  45038. /** The utility layer the gizmo will be added to */
  45039. gizmoLayer?: UtilityLayerRenderer);
  45040. /**
  45041. * Updates the gizmo to match the attached mesh's position/rotation
  45042. */
  45043. protected _update(): void;
  45044. /**
  45045. * Disposes of the gizmo
  45046. */
  45047. dispose(): void;
  45048. }
  45049. }
  45050. declare module BABYLON {
  45051. /**
  45052. * Single plane drag gizmo
  45053. */
  45054. export class PlaneDragGizmo extends Gizmo {
  45055. /**
  45056. * Drag behavior responsible for the gizmos dragging interactions
  45057. */
  45058. dragBehavior: PointerDragBehavior;
  45059. private _pointerObserver;
  45060. /**
  45061. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45062. */
  45063. snapDistance: number;
  45064. /**
  45065. * Event that fires each time the gizmo snaps to a new location.
  45066. * * snapDistance is the the change in distance
  45067. */
  45068. onSnapObservable: Observable<{
  45069. snapDistance: number;
  45070. }>;
  45071. private _plane;
  45072. private _coloredMaterial;
  45073. private _hoverMaterial;
  45074. private _isEnabled;
  45075. private _parent;
  45076. /** @hidden */
  45077. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45078. /** @hidden */
  45079. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45080. /**
  45081. * Creates a PlaneDragGizmo
  45082. * @param gizmoLayer The utility layer the gizmo will be added to
  45083. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45084. * @param color The color of the gizmo
  45085. */
  45086. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45087. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45088. /**
  45089. * If the gizmo is enabled
  45090. */
  45091. set isEnabled(value: boolean);
  45092. get isEnabled(): boolean;
  45093. /**
  45094. * Disposes of the gizmo
  45095. */
  45096. dispose(): void;
  45097. }
  45098. }
  45099. declare module BABYLON {
  45100. /**
  45101. * Gizmo that enables dragging a mesh along 3 axis
  45102. */
  45103. export class PositionGizmo extends Gizmo {
  45104. /**
  45105. * Internal gizmo used for interactions on the x axis
  45106. */
  45107. xGizmo: AxisDragGizmo;
  45108. /**
  45109. * Internal gizmo used for interactions on the y axis
  45110. */
  45111. yGizmo: AxisDragGizmo;
  45112. /**
  45113. * Internal gizmo used for interactions on the z axis
  45114. */
  45115. zGizmo: AxisDragGizmo;
  45116. /**
  45117. * Internal gizmo used for interactions on the yz plane
  45118. */
  45119. xPlaneGizmo: PlaneDragGizmo;
  45120. /**
  45121. * Internal gizmo used for interactions on the xz plane
  45122. */
  45123. yPlaneGizmo: PlaneDragGizmo;
  45124. /**
  45125. * Internal gizmo used for interactions on the xy plane
  45126. */
  45127. zPlaneGizmo: PlaneDragGizmo;
  45128. /**
  45129. * private variables
  45130. */
  45131. private _meshAttached;
  45132. private _updateGizmoRotationToMatchAttachedMesh;
  45133. private _snapDistance;
  45134. private _scaleRatio;
  45135. /** Fires an event when any of it's sub gizmos are dragged */
  45136. onDragStartObservable: Observable<unknown>;
  45137. /** Fires an event when any of it's sub gizmos are released from dragging */
  45138. onDragEndObservable: Observable<unknown>;
  45139. /**
  45140. * If set to true, planar drag is enabled
  45141. */
  45142. private _planarGizmoEnabled;
  45143. get attachedMesh(): Nullable<AbstractMesh>;
  45144. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45145. /**
  45146. * Creates a PositionGizmo
  45147. * @param gizmoLayer The utility layer the gizmo will be added to
  45148. */
  45149. constructor(gizmoLayer?: UtilityLayerRenderer);
  45150. /**
  45151. * If the planar drag gizmo is enabled
  45152. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45153. */
  45154. set planarGizmoEnabled(value: boolean);
  45155. get planarGizmoEnabled(): boolean;
  45156. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45157. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45158. /**
  45159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45160. */
  45161. set snapDistance(value: number);
  45162. get snapDistance(): number;
  45163. /**
  45164. * Ratio for the scale of the gizmo (Default: 1)
  45165. */
  45166. set scaleRatio(value: number);
  45167. get scaleRatio(): number;
  45168. /**
  45169. * Disposes of the gizmo
  45170. */
  45171. dispose(): void;
  45172. /**
  45173. * CustomMeshes are not supported by this gizmo
  45174. * @param mesh The mesh to replace the default mesh of the gizmo
  45175. */
  45176. setCustomMesh(mesh: Mesh): void;
  45177. }
  45178. }
  45179. declare module BABYLON {
  45180. /**
  45181. * Single axis drag gizmo
  45182. */
  45183. export class AxisDragGizmo extends Gizmo {
  45184. /**
  45185. * Drag behavior responsible for the gizmos dragging interactions
  45186. */
  45187. dragBehavior: PointerDragBehavior;
  45188. private _pointerObserver;
  45189. /**
  45190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45191. */
  45192. snapDistance: number;
  45193. /**
  45194. * Event that fires each time the gizmo snaps to a new location.
  45195. * * snapDistance is the the change in distance
  45196. */
  45197. onSnapObservable: Observable<{
  45198. snapDistance: number;
  45199. }>;
  45200. private _isEnabled;
  45201. private _parent;
  45202. private _arrow;
  45203. private _coloredMaterial;
  45204. private _hoverMaterial;
  45205. /** @hidden */
  45206. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45207. /** @hidden */
  45208. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45209. /**
  45210. * Creates an AxisDragGizmo
  45211. * @param gizmoLayer The utility layer the gizmo will be added to
  45212. * @param dragAxis The axis which the gizmo will be able to drag on
  45213. * @param color The color of the gizmo
  45214. */
  45215. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45216. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45217. /**
  45218. * If the gizmo is enabled
  45219. */
  45220. set isEnabled(value: boolean);
  45221. get isEnabled(): boolean;
  45222. /**
  45223. * Disposes of the gizmo
  45224. */
  45225. dispose(): void;
  45226. }
  45227. }
  45228. declare module BABYLON.Debug {
  45229. /**
  45230. * The Axes viewer will show 3 axes in a specific point in space
  45231. */
  45232. export class AxesViewer {
  45233. private _xAxis;
  45234. private _yAxis;
  45235. private _zAxis;
  45236. private _scaleLinesFactor;
  45237. private _instanced;
  45238. /**
  45239. * Gets the hosting scene
  45240. */
  45241. scene: Scene;
  45242. /**
  45243. * Gets or sets a number used to scale line length
  45244. */
  45245. scaleLines: number;
  45246. /** Gets the node hierarchy used to render x-axis */
  45247. get xAxis(): TransformNode;
  45248. /** Gets the node hierarchy used to render y-axis */
  45249. get yAxis(): TransformNode;
  45250. /** Gets the node hierarchy used to render z-axis */
  45251. get zAxis(): TransformNode;
  45252. /**
  45253. * Creates a new AxesViewer
  45254. * @param scene defines the hosting scene
  45255. * @param scaleLines defines a number used to scale line length (1 by default)
  45256. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45257. * @param xAxis defines the node hierarchy used to render the x-axis
  45258. * @param yAxis defines the node hierarchy used to render the y-axis
  45259. * @param zAxis defines the node hierarchy used to render the z-axis
  45260. */
  45261. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45262. /**
  45263. * Force the viewer to update
  45264. * @param position defines the position of the viewer
  45265. * @param xaxis defines the x axis of the viewer
  45266. * @param yaxis defines the y axis of the viewer
  45267. * @param zaxis defines the z axis of the viewer
  45268. */
  45269. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45270. /**
  45271. * Creates an instance of this axes viewer.
  45272. * @returns a new axes viewer with instanced meshes
  45273. */
  45274. createInstance(): AxesViewer;
  45275. /** Releases resources */
  45276. dispose(): void;
  45277. private static _SetRenderingGroupId;
  45278. }
  45279. }
  45280. declare module BABYLON.Debug {
  45281. /**
  45282. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45283. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45284. */
  45285. export class BoneAxesViewer extends AxesViewer {
  45286. /**
  45287. * Gets or sets the target mesh where to display the axes viewer
  45288. */
  45289. mesh: Nullable<Mesh>;
  45290. /**
  45291. * Gets or sets the target bone where to display the axes viewer
  45292. */
  45293. bone: Nullable<Bone>;
  45294. /** Gets current position */
  45295. pos: Vector3;
  45296. /** Gets direction of X axis */
  45297. xaxis: Vector3;
  45298. /** Gets direction of Y axis */
  45299. yaxis: Vector3;
  45300. /** Gets direction of Z axis */
  45301. zaxis: Vector3;
  45302. /**
  45303. * Creates a new BoneAxesViewer
  45304. * @param scene defines the hosting scene
  45305. * @param bone defines the target bone
  45306. * @param mesh defines the target mesh
  45307. * @param scaleLines defines a scaling factor for line length (1 by default)
  45308. */
  45309. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45310. /**
  45311. * Force the viewer to update
  45312. */
  45313. update(): void;
  45314. /** Releases resources */
  45315. dispose(): void;
  45316. }
  45317. }
  45318. declare module BABYLON {
  45319. /**
  45320. * Interface used to define scene explorer extensibility option
  45321. */
  45322. export interface IExplorerExtensibilityOption {
  45323. /**
  45324. * Define the option label
  45325. */
  45326. label: string;
  45327. /**
  45328. * Defines the action to execute on click
  45329. */
  45330. action: (entity: any) => void;
  45331. }
  45332. /**
  45333. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45334. */
  45335. export interface IExplorerExtensibilityGroup {
  45336. /**
  45337. * Defines a predicate to test if a given type mut be extended
  45338. */
  45339. predicate: (entity: any) => boolean;
  45340. /**
  45341. * Gets the list of options added to a type
  45342. */
  45343. entries: IExplorerExtensibilityOption[];
  45344. }
  45345. /**
  45346. * Interface used to define the options to use to create the Inspector
  45347. */
  45348. export interface IInspectorOptions {
  45349. /**
  45350. * Display in overlay mode (default: false)
  45351. */
  45352. overlay?: boolean;
  45353. /**
  45354. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45355. */
  45356. globalRoot?: HTMLElement;
  45357. /**
  45358. * Display the Scene explorer
  45359. */
  45360. showExplorer?: boolean;
  45361. /**
  45362. * Display the property inspector
  45363. */
  45364. showInspector?: boolean;
  45365. /**
  45366. * Display in embed mode (both panes on the right)
  45367. */
  45368. embedMode?: boolean;
  45369. /**
  45370. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45371. */
  45372. handleResize?: boolean;
  45373. /**
  45374. * Allow the panes to popup (default: true)
  45375. */
  45376. enablePopup?: boolean;
  45377. /**
  45378. * Allow the panes to be closed by users (default: true)
  45379. */
  45380. enableClose?: boolean;
  45381. /**
  45382. * Optional list of extensibility entries
  45383. */
  45384. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45385. /**
  45386. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45387. */
  45388. inspectorURL?: string;
  45389. /**
  45390. * Optional initial tab (default to DebugLayerTab.Properties)
  45391. */
  45392. initialTab?: DebugLayerTab;
  45393. }
  45394. interface Scene {
  45395. /**
  45396. * @hidden
  45397. * Backing field
  45398. */
  45399. _debugLayer: DebugLayer;
  45400. /**
  45401. * Gets the debug layer (aka Inspector) associated with the scene
  45402. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45403. */
  45404. debugLayer: DebugLayer;
  45405. }
  45406. /**
  45407. * Enum of inspector action tab
  45408. */
  45409. export enum DebugLayerTab {
  45410. /**
  45411. * Properties tag (default)
  45412. */
  45413. Properties = 0,
  45414. /**
  45415. * Debug tab
  45416. */
  45417. Debug = 1,
  45418. /**
  45419. * Statistics tab
  45420. */
  45421. Statistics = 2,
  45422. /**
  45423. * Tools tab
  45424. */
  45425. Tools = 3,
  45426. /**
  45427. * Settings tab
  45428. */
  45429. Settings = 4
  45430. }
  45431. /**
  45432. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45433. * what is happening in your scene
  45434. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45435. */
  45436. export class DebugLayer {
  45437. /**
  45438. * Define the url to get the inspector script from.
  45439. * By default it uses the babylonjs CDN.
  45440. * @ignoreNaming
  45441. */
  45442. static InspectorURL: string;
  45443. private _scene;
  45444. private BJSINSPECTOR;
  45445. private _onPropertyChangedObservable?;
  45446. /**
  45447. * Observable triggered when a property is changed through the inspector.
  45448. */
  45449. get onPropertyChangedObservable(): any;
  45450. /**
  45451. * Instantiates a new debug layer.
  45452. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45453. * what is happening in your scene
  45454. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45455. * @param scene Defines the scene to inspect
  45456. */
  45457. constructor(scene: Scene);
  45458. /** Creates the inspector window. */
  45459. private _createInspector;
  45460. /**
  45461. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45462. * @param entity defines the entity to select
  45463. * @param lineContainerTitle defines the specific block to highlight
  45464. */
  45465. select(entity: any, lineContainerTitle?: string): void;
  45466. /** Get the inspector from bundle or global */
  45467. private _getGlobalInspector;
  45468. /**
  45469. * Get if the inspector is visible or not.
  45470. * @returns true if visible otherwise, false
  45471. */
  45472. isVisible(): boolean;
  45473. /**
  45474. * Hide the inspector and close its window.
  45475. */
  45476. hide(): void;
  45477. /**
  45478. * Launch the debugLayer.
  45479. * @param config Define the configuration of the inspector
  45480. * @return a promise fulfilled when the debug layer is visible
  45481. */
  45482. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45483. }
  45484. }
  45485. declare module BABYLON {
  45486. /**
  45487. * Class containing static functions to help procedurally build meshes
  45488. */
  45489. export class BoxBuilder {
  45490. /**
  45491. * Creates a box mesh
  45492. * * The parameter `size` sets the size (float) of each box side (default 1)
  45493. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45494. * * 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)
  45495. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45497. * * 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
  45498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45500. * @param name defines the name of the mesh
  45501. * @param options defines the options used to create the mesh
  45502. * @param scene defines the hosting scene
  45503. * @returns the box mesh
  45504. */
  45505. static CreateBox(name: string, options: {
  45506. size?: number;
  45507. width?: number;
  45508. height?: number;
  45509. depth?: number;
  45510. faceUV?: Vector4[];
  45511. faceColors?: Color4[];
  45512. sideOrientation?: number;
  45513. frontUVs?: Vector4;
  45514. backUVs?: Vector4;
  45515. wrap?: boolean;
  45516. topBaseAt?: number;
  45517. bottomBaseAt?: number;
  45518. updatable?: boolean;
  45519. }, scene?: Nullable<Scene>): Mesh;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * Class containing static functions to help procedurally build meshes
  45525. */
  45526. export class SphereBuilder {
  45527. /**
  45528. * Creates a sphere mesh
  45529. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45530. * * 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`)
  45531. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45532. * * 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
  45533. * * 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)
  45534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45535. * * 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
  45536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45537. * @param name defines the name of the mesh
  45538. * @param options defines the options used to create the mesh
  45539. * @param scene defines the hosting scene
  45540. * @returns the sphere mesh
  45541. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45542. */
  45543. static CreateSphere(name: string, options: {
  45544. segments?: number;
  45545. diameter?: number;
  45546. diameterX?: number;
  45547. diameterY?: number;
  45548. diameterZ?: number;
  45549. arc?: number;
  45550. slice?: number;
  45551. sideOrientation?: number;
  45552. frontUVs?: Vector4;
  45553. backUVs?: Vector4;
  45554. updatable?: boolean;
  45555. }, scene?: Nullable<Scene>): Mesh;
  45556. }
  45557. }
  45558. declare module BABYLON.Debug {
  45559. /**
  45560. * Used to show the physics impostor around the specific mesh
  45561. */
  45562. export class PhysicsViewer {
  45563. /** @hidden */
  45564. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45565. /** @hidden */
  45566. protected _meshes: Array<Nullable<AbstractMesh>>;
  45567. /** @hidden */
  45568. protected _scene: Nullable<Scene>;
  45569. /** @hidden */
  45570. protected _numMeshes: number;
  45571. /** @hidden */
  45572. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45573. private _renderFunction;
  45574. private _utilityLayer;
  45575. private _debugBoxMesh;
  45576. private _debugSphereMesh;
  45577. private _debugCylinderMesh;
  45578. private _debugMaterial;
  45579. private _debugMeshMeshes;
  45580. /**
  45581. * Creates a new PhysicsViewer
  45582. * @param scene defines the hosting scene
  45583. */
  45584. constructor(scene: Scene);
  45585. /** @hidden */
  45586. protected _updateDebugMeshes(): void;
  45587. /**
  45588. * Renders a specified physic impostor
  45589. * @param impostor defines the impostor to render
  45590. * @param targetMesh defines the mesh represented by the impostor
  45591. * @returns the new debug mesh used to render the impostor
  45592. */
  45593. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45594. /**
  45595. * Hides a specified physic impostor
  45596. * @param impostor defines the impostor to hide
  45597. */
  45598. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45599. private _getDebugMaterial;
  45600. private _getDebugBoxMesh;
  45601. private _getDebugSphereMesh;
  45602. private _getDebugCylinderMesh;
  45603. private _getDebugMeshMesh;
  45604. private _getDebugMesh;
  45605. /** Releases all resources */
  45606. dispose(): void;
  45607. }
  45608. }
  45609. declare module BABYLON {
  45610. /**
  45611. * Class containing static functions to help procedurally build meshes
  45612. */
  45613. export class LinesBuilder {
  45614. /**
  45615. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45616. * * 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
  45617. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45618. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45619. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45620. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45621. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45622. * * 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
  45623. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45626. * @param name defines the name of the new line system
  45627. * @param options defines the options used to create the line system
  45628. * @param scene defines the hosting scene
  45629. * @returns a new line system mesh
  45630. */
  45631. static CreateLineSystem(name: string, options: {
  45632. lines: Vector3[][];
  45633. updatable?: boolean;
  45634. instance?: Nullable<LinesMesh>;
  45635. colors?: Nullable<Color4[][]>;
  45636. useVertexAlpha?: boolean;
  45637. }, scene: Nullable<Scene>): LinesMesh;
  45638. /**
  45639. * Creates a line mesh
  45640. * 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
  45641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45642. * * The parameter `points` is an array successive Vector3
  45643. * * 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
  45644. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45645. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45646. * * When updating an instance, remember that only point positions can change, not the number of points
  45647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45649. * @param name defines the name of the new line system
  45650. * @param options defines the options used to create the line system
  45651. * @param scene defines the hosting scene
  45652. * @returns a new line mesh
  45653. */
  45654. static CreateLines(name: string, options: {
  45655. points: Vector3[];
  45656. updatable?: boolean;
  45657. instance?: Nullable<LinesMesh>;
  45658. colors?: Color4[];
  45659. useVertexAlpha?: boolean;
  45660. }, scene?: Nullable<Scene>): LinesMesh;
  45661. /**
  45662. * Creates a dashed line mesh
  45663. * * 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
  45664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45665. * * The parameter `points` is an array successive Vector3
  45666. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45667. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45668. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45669. * * 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
  45670. * * When updating an instance, remember that only point positions can change, not the number of points
  45671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45672. * @param name defines the name of the mesh
  45673. * @param options defines the options used to create the mesh
  45674. * @param scene defines the hosting scene
  45675. * @returns the dashed line mesh
  45676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45677. */
  45678. static CreateDashedLines(name: string, options: {
  45679. points: Vector3[];
  45680. dashSize?: number;
  45681. gapSize?: number;
  45682. dashNb?: number;
  45683. updatable?: boolean;
  45684. instance?: LinesMesh;
  45685. }, scene?: Nullable<Scene>): LinesMesh;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. /**
  45690. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45691. * in order to better appreciate the issue one might have.
  45692. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45693. */
  45694. export class RayHelper {
  45695. /**
  45696. * Defines the ray we are currently tryin to visualize.
  45697. */
  45698. ray: Nullable<Ray>;
  45699. private _renderPoints;
  45700. private _renderLine;
  45701. private _renderFunction;
  45702. private _scene;
  45703. private _updateToMeshFunction;
  45704. private _attachedToMesh;
  45705. private _meshSpaceDirection;
  45706. private _meshSpaceOrigin;
  45707. /**
  45708. * Helper function to create a colored helper in a scene in one line.
  45709. * @param ray Defines the ray we are currently tryin to visualize
  45710. * @param scene Defines the scene the ray is used in
  45711. * @param color Defines the color we want to see the ray in
  45712. * @returns The newly created ray helper.
  45713. */
  45714. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45715. /**
  45716. * Instantiate a new ray helper.
  45717. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45718. * in order to better appreciate the issue one might have.
  45719. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45720. * @param ray Defines the ray we are currently tryin to visualize
  45721. */
  45722. constructor(ray: Ray);
  45723. /**
  45724. * Shows the ray we are willing to debug.
  45725. * @param scene Defines the scene the ray needs to be rendered in
  45726. * @param color Defines the color the ray needs to be rendered in
  45727. */
  45728. show(scene: Scene, color?: Color3): void;
  45729. /**
  45730. * Hides the ray we are debugging.
  45731. */
  45732. hide(): void;
  45733. private _render;
  45734. /**
  45735. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45736. * @param mesh Defines the mesh we want the helper attached to
  45737. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45738. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45739. * @param length Defines the length of the ray
  45740. */
  45741. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45742. /**
  45743. * Detach the ray helper from the mesh it has previously been attached to.
  45744. */
  45745. detachFromMesh(): void;
  45746. private _updateToMesh;
  45747. /**
  45748. * Dispose the helper and release its associated resources.
  45749. */
  45750. dispose(): void;
  45751. }
  45752. }
  45753. declare module BABYLON.Debug {
  45754. /**
  45755. * Class used to render a debug view of a given skeleton
  45756. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45757. */
  45758. export class SkeletonViewer {
  45759. /** defines the skeleton to render */
  45760. skeleton: Skeleton;
  45761. /** defines the mesh attached to the skeleton */
  45762. mesh: AbstractMesh;
  45763. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45764. autoUpdateBonesMatrices: boolean;
  45765. /** defines the rendering group id to use with the viewer */
  45766. renderingGroupId: number;
  45767. /** Gets or sets the color used to render the skeleton */
  45768. color: Color3;
  45769. private _scene;
  45770. private _debugLines;
  45771. private _debugMesh;
  45772. private _isEnabled;
  45773. private _renderFunction;
  45774. private _utilityLayer;
  45775. /**
  45776. * Returns the mesh used to render the bones
  45777. */
  45778. get debugMesh(): Nullable<LinesMesh>;
  45779. /**
  45780. * Creates a new SkeletonViewer
  45781. * @param skeleton defines the skeleton to render
  45782. * @param mesh defines the mesh attached to the skeleton
  45783. * @param scene defines the hosting scene
  45784. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45785. * @param renderingGroupId defines the rendering group id to use with the viewer
  45786. */
  45787. constructor(
  45788. /** defines the skeleton to render */
  45789. skeleton: Skeleton,
  45790. /** defines the mesh attached to the skeleton */
  45791. mesh: AbstractMesh, scene: Scene,
  45792. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45793. autoUpdateBonesMatrices?: boolean,
  45794. /** defines the rendering group id to use with the viewer */
  45795. renderingGroupId?: number);
  45796. /** Gets or sets a boolean indicating if the viewer is enabled */
  45797. set isEnabled(value: boolean);
  45798. get isEnabled(): boolean;
  45799. private _getBonePosition;
  45800. private _getLinesForBonesWithLength;
  45801. private _getLinesForBonesNoLength;
  45802. /** Update the viewer to sync with current skeleton state */
  45803. update(): void;
  45804. /** Release associated resources */
  45805. dispose(): void;
  45806. }
  45807. }
  45808. declare module BABYLON {
  45809. /**
  45810. * Options to create the null engine
  45811. */
  45812. export class NullEngineOptions {
  45813. /**
  45814. * Render width (Default: 512)
  45815. */
  45816. renderWidth: number;
  45817. /**
  45818. * Render height (Default: 256)
  45819. */
  45820. renderHeight: number;
  45821. /**
  45822. * Texture size (Default: 512)
  45823. */
  45824. textureSize: number;
  45825. /**
  45826. * If delta time between frames should be constant
  45827. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45828. */
  45829. deterministicLockstep: boolean;
  45830. /**
  45831. * Maximum about of steps between frames (Default: 4)
  45832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45833. */
  45834. lockstepMaxSteps: number;
  45835. }
  45836. /**
  45837. * The null engine class provides support for headless version of babylon.js.
  45838. * This can be used in server side scenario or for testing purposes
  45839. */
  45840. export class NullEngine extends Engine {
  45841. private _options;
  45842. /**
  45843. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45844. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45845. * @returns true if engine is in deterministic lock step mode
  45846. */
  45847. isDeterministicLockStep(): boolean;
  45848. /**
  45849. * Gets the max steps when engine is running in deterministic lock step
  45850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45851. * @returns the max steps
  45852. */
  45853. getLockstepMaxSteps(): number;
  45854. /**
  45855. * Gets the current hardware scaling level.
  45856. * By default the hardware scaling level is computed from the window device ratio.
  45857. * 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.
  45858. * @returns a number indicating the current hardware scaling level
  45859. */
  45860. getHardwareScalingLevel(): number;
  45861. constructor(options?: NullEngineOptions);
  45862. /**
  45863. * Creates a vertex buffer
  45864. * @param vertices the data for the vertex buffer
  45865. * @returns the new WebGL static buffer
  45866. */
  45867. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45868. /**
  45869. * Creates a new index buffer
  45870. * @param indices defines the content of the index buffer
  45871. * @param updatable defines if the index buffer must be updatable
  45872. * @returns a new webGL buffer
  45873. */
  45874. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45875. /**
  45876. * Clear the current render buffer or the current render target (if any is set up)
  45877. * @param color defines the color to use
  45878. * @param backBuffer defines if the back buffer must be cleared
  45879. * @param depth defines if the depth buffer must be cleared
  45880. * @param stencil defines if the stencil buffer must be cleared
  45881. */
  45882. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45883. /**
  45884. * Gets the current render width
  45885. * @param useScreen defines if screen size must be used (or the current render target if any)
  45886. * @returns a number defining the current render width
  45887. */
  45888. getRenderWidth(useScreen?: boolean): number;
  45889. /**
  45890. * Gets the current render height
  45891. * @param useScreen defines if screen size must be used (or the current render target if any)
  45892. * @returns a number defining the current render height
  45893. */
  45894. getRenderHeight(useScreen?: boolean): number;
  45895. /**
  45896. * Set the WebGL's viewport
  45897. * @param viewport defines the viewport element to be used
  45898. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45899. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45900. */
  45901. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45902. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45903. /**
  45904. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45905. * @param pipelineContext defines the pipeline context to use
  45906. * @param uniformsNames defines the list of uniform names
  45907. * @returns an array of webGL uniform locations
  45908. */
  45909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45910. /**
  45911. * Gets the lsit of active attributes for a given webGL program
  45912. * @param pipelineContext defines the pipeline context to use
  45913. * @param attributesNames defines the list of attribute names to get
  45914. * @returns an array of indices indicating the offset of each attribute
  45915. */
  45916. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45917. /**
  45918. * Binds an effect to the webGL context
  45919. * @param effect defines the effect to bind
  45920. */
  45921. bindSamplers(effect: Effect): void;
  45922. /**
  45923. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45924. * @param effect defines the effect to activate
  45925. */
  45926. enableEffect(effect: Effect): void;
  45927. /**
  45928. * Set various states to the webGL context
  45929. * @param culling defines backface culling state
  45930. * @param zOffset defines the value to apply to zOffset (0 by default)
  45931. * @param force defines if states must be applied even if cache is up to date
  45932. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45933. */
  45934. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45935. /**
  45936. * Set the value of an uniform to an array of int32
  45937. * @param uniform defines the webGL uniform location where to store the value
  45938. * @param array defines the array of int32 to store
  45939. */
  45940. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45941. /**
  45942. * Set the value of an uniform to an array of int32 (stored as vec2)
  45943. * @param uniform defines the webGL uniform location where to store the value
  45944. * @param array defines the array of int32 to store
  45945. */
  45946. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45947. /**
  45948. * Set the value of an uniform to an array of int32 (stored as vec3)
  45949. * @param uniform defines the webGL uniform location where to store the value
  45950. * @param array defines the array of int32 to store
  45951. */
  45952. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45953. /**
  45954. * Set the value of an uniform to an array of int32 (stored as vec4)
  45955. * @param uniform defines the webGL uniform location where to store the value
  45956. * @param array defines the array of int32 to store
  45957. */
  45958. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45959. /**
  45960. * Set the value of an uniform to an array of float32
  45961. * @param uniform defines the webGL uniform location where to store the value
  45962. * @param array defines the array of float32 to store
  45963. */
  45964. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45965. /**
  45966. * Set the value of an uniform to an array of float32 (stored as vec2)
  45967. * @param uniform defines the webGL uniform location where to store the value
  45968. * @param array defines the array of float32 to store
  45969. */
  45970. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45971. /**
  45972. * Set the value of an uniform to an array of float32 (stored as vec3)
  45973. * @param uniform defines the webGL uniform location where to store the value
  45974. * @param array defines the array of float32 to store
  45975. */
  45976. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45977. /**
  45978. * Set the value of an uniform to an array of float32 (stored as vec4)
  45979. * @param uniform defines the webGL uniform location where to store the value
  45980. * @param array defines the array of float32 to store
  45981. */
  45982. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45983. /**
  45984. * Set the value of an uniform to an array of number
  45985. * @param uniform defines the webGL uniform location where to store the value
  45986. * @param array defines the array of number to store
  45987. */
  45988. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45989. /**
  45990. * Set the value of an uniform to an array of number (stored as vec2)
  45991. * @param uniform defines the webGL uniform location where to store the value
  45992. * @param array defines the array of number to store
  45993. */
  45994. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45995. /**
  45996. * Set the value of an uniform to an array of number (stored as vec3)
  45997. * @param uniform defines the webGL uniform location where to store the value
  45998. * @param array defines the array of number to store
  45999. */
  46000. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46001. /**
  46002. * Set the value of an uniform to an array of number (stored as vec4)
  46003. * @param uniform defines the webGL uniform location where to store the value
  46004. * @param array defines the array of number to store
  46005. */
  46006. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46007. /**
  46008. * Set the value of an uniform to an array of float32 (stored as matrices)
  46009. * @param uniform defines the webGL uniform location where to store the value
  46010. * @param matrices defines the array of float32 to store
  46011. */
  46012. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46013. /**
  46014. * Set the value of an uniform to a matrix (3x3)
  46015. * @param uniform defines the webGL uniform location where to store the value
  46016. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46017. */
  46018. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46019. /**
  46020. * Set the value of an uniform to a matrix (2x2)
  46021. * @param uniform defines the webGL uniform location where to store the value
  46022. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46023. */
  46024. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46025. /**
  46026. * Set the value of an uniform to a number (float)
  46027. * @param uniform defines the webGL uniform location where to store the value
  46028. * @param value defines the float number to store
  46029. */
  46030. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46031. /**
  46032. * Set the value of an uniform to a vec2
  46033. * @param uniform defines the webGL uniform location where to store the value
  46034. * @param x defines the 1st component of the value
  46035. * @param y defines the 2nd component of the value
  46036. */
  46037. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46038. /**
  46039. * Set the value of an uniform to a vec3
  46040. * @param uniform defines the webGL uniform location where to store the value
  46041. * @param x defines the 1st component of the value
  46042. * @param y defines the 2nd component of the value
  46043. * @param z defines the 3rd component of the value
  46044. */
  46045. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46046. /**
  46047. * Set the value of an uniform to a boolean
  46048. * @param uniform defines the webGL uniform location where to store the value
  46049. * @param bool defines the boolean to store
  46050. */
  46051. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46052. /**
  46053. * Set the value of an uniform to a vec4
  46054. * @param uniform defines the webGL uniform location where to store the value
  46055. * @param x defines the 1st component of the value
  46056. * @param y defines the 2nd component of the value
  46057. * @param z defines the 3rd component of the value
  46058. * @param w defines the 4th component of the value
  46059. */
  46060. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46061. /**
  46062. * Sets the current alpha mode
  46063. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46064. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46065. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46066. */
  46067. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46068. /**
  46069. * Bind webGl buffers directly to the webGL context
  46070. * @param vertexBuffers defines the vertex buffer to bind
  46071. * @param indexBuffer defines the index buffer to bind
  46072. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46073. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46074. * @param effect defines the effect associated with the vertex buffer
  46075. */
  46076. bindBuffers(vertexBuffers: {
  46077. [key: string]: VertexBuffer;
  46078. }, indexBuffer: DataBuffer, effect: Effect): void;
  46079. /**
  46080. * Force the entire cache to be cleared
  46081. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46082. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46083. */
  46084. wipeCaches(bruteForce?: boolean): void;
  46085. /**
  46086. * Send a draw order
  46087. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46088. * @param indexStart defines the starting index
  46089. * @param indexCount defines the number of index to draw
  46090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46091. */
  46092. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46093. /**
  46094. * Draw a list of indexed primitives
  46095. * @param fillMode defines the primitive to use
  46096. * @param indexStart defines the starting index
  46097. * @param indexCount defines the number of index to draw
  46098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46099. */
  46100. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46101. /**
  46102. * Draw a list of unindexed primitives
  46103. * @param fillMode defines the primitive to use
  46104. * @param verticesStart defines the index of first vertex to draw
  46105. * @param verticesCount defines the count of vertices to draw
  46106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46107. */
  46108. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46109. /** @hidden */
  46110. _createTexture(): WebGLTexture;
  46111. /** @hidden */
  46112. _releaseTexture(texture: InternalTexture): void;
  46113. /**
  46114. * Usually called from Texture.ts.
  46115. * Passed information to create a WebGLTexture
  46116. * @param urlArg defines a value which contains one of the following:
  46117. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46118. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46119. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46120. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46121. * @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)
  46122. * @param scene needed for loading to the correct scene
  46123. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46124. * @param onLoad optional callback to be called upon successful completion
  46125. * @param onError optional callback to be called upon failure
  46126. * @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
  46127. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46128. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46129. * @param forcedExtension defines the extension to use to pick the right loader
  46130. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46131. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46132. */
  46133. 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;
  46134. /**
  46135. * Creates a new render target texture
  46136. * @param size defines the size of the texture
  46137. * @param options defines the options used to create the texture
  46138. * @returns a new render target texture stored in an InternalTexture
  46139. */
  46140. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46141. /**
  46142. * Update the sampling mode of a given texture
  46143. * @param samplingMode defines the required sampling mode
  46144. * @param texture defines the texture to update
  46145. */
  46146. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46147. /**
  46148. * Binds the frame buffer to the specified texture.
  46149. * @param texture The texture to render to or null for the default canvas
  46150. * @param faceIndex The face of the texture to render to in case of cube texture
  46151. * @param requiredWidth The width of the target to render to
  46152. * @param requiredHeight The height of the target to render to
  46153. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46154. * @param depthStencilTexture The depth stencil texture to use to render
  46155. * @param lodLevel defines le lod level to bind to the frame buffer
  46156. */
  46157. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46158. /**
  46159. * Unbind the current render target texture from the webGL context
  46160. * @param texture defines the render target texture to unbind
  46161. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46162. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46163. */
  46164. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46165. /**
  46166. * Creates a dynamic vertex buffer
  46167. * @param vertices the data for the dynamic vertex buffer
  46168. * @returns the new WebGL dynamic buffer
  46169. */
  46170. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46171. /**
  46172. * Update the content of a dynamic texture
  46173. * @param texture defines the texture to update
  46174. * @param canvas defines the canvas containing the source
  46175. * @param invertY defines if data must be stored with Y axis inverted
  46176. * @param premulAlpha defines if alpha is stored as premultiplied
  46177. * @param format defines the format of the data
  46178. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46179. */
  46180. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46181. /**
  46182. * Gets a boolean indicating if all created effects are ready
  46183. * @returns true if all effects are ready
  46184. */
  46185. areAllEffectsReady(): boolean;
  46186. /**
  46187. * @hidden
  46188. * Get the current error code of the webGL context
  46189. * @returns the error code
  46190. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46191. */
  46192. getError(): number;
  46193. /** @hidden */
  46194. _getUnpackAlignement(): number;
  46195. /** @hidden */
  46196. _unpackFlipY(value: boolean): void;
  46197. /**
  46198. * Update a dynamic index buffer
  46199. * @param indexBuffer defines the target index buffer
  46200. * @param indices defines the data to update
  46201. * @param offset defines the offset in the target index buffer where update should start
  46202. */
  46203. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46204. /**
  46205. * Updates a dynamic vertex buffer.
  46206. * @param vertexBuffer the vertex buffer to update
  46207. * @param vertices the data used to update the vertex buffer
  46208. * @param byteOffset the byte offset of the data (optional)
  46209. * @param byteLength the byte length of the data (optional)
  46210. */
  46211. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46212. /** @hidden */
  46213. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46214. /** @hidden */
  46215. _bindTexture(channel: number, texture: InternalTexture): void;
  46216. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46217. /**
  46218. * 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
  46219. */
  46220. releaseEffects(): void;
  46221. displayLoadingUI(): void;
  46222. hideLoadingUI(): void;
  46223. /** @hidden */
  46224. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46225. /** @hidden */
  46226. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46227. /** @hidden */
  46228. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46229. /** @hidden */
  46230. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46231. }
  46232. }
  46233. declare module BABYLON {
  46234. /** @hidden */
  46235. export class _OcclusionDataStorage {
  46236. /** @hidden */
  46237. occlusionInternalRetryCounter: number;
  46238. /** @hidden */
  46239. isOcclusionQueryInProgress: boolean;
  46240. /** @hidden */
  46241. isOccluded: boolean;
  46242. /** @hidden */
  46243. occlusionRetryCount: number;
  46244. /** @hidden */
  46245. occlusionType: number;
  46246. /** @hidden */
  46247. occlusionQueryAlgorithmType: number;
  46248. }
  46249. interface Engine {
  46250. /**
  46251. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46252. * @return the new query
  46253. */
  46254. createQuery(): WebGLQuery;
  46255. /**
  46256. * Delete and release a webGL query
  46257. * @param query defines the query to delete
  46258. * @return the current engine
  46259. */
  46260. deleteQuery(query: WebGLQuery): Engine;
  46261. /**
  46262. * Check if a given query has resolved and got its value
  46263. * @param query defines the query to check
  46264. * @returns true if the query got its value
  46265. */
  46266. isQueryResultAvailable(query: WebGLQuery): boolean;
  46267. /**
  46268. * Gets the value of a given query
  46269. * @param query defines the query to check
  46270. * @returns the value of the query
  46271. */
  46272. getQueryResult(query: WebGLQuery): number;
  46273. /**
  46274. * Initiates an occlusion query
  46275. * @param algorithmType defines the algorithm to use
  46276. * @param query defines the query to use
  46277. * @returns the current engine
  46278. * @see http://doc.babylonjs.com/features/occlusionquery
  46279. */
  46280. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46281. /**
  46282. * Ends an occlusion query
  46283. * @see http://doc.babylonjs.com/features/occlusionquery
  46284. * @param algorithmType defines the algorithm to use
  46285. * @returns the current engine
  46286. */
  46287. endOcclusionQuery(algorithmType: number): Engine;
  46288. /**
  46289. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46290. * Please note that only one query can be issued at a time
  46291. * @returns a time token used to track the time span
  46292. */
  46293. startTimeQuery(): Nullable<_TimeToken>;
  46294. /**
  46295. * Ends a time query
  46296. * @param token defines the token used to measure the time span
  46297. * @returns the time spent (in ns)
  46298. */
  46299. endTimeQuery(token: _TimeToken): int;
  46300. /** @hidden */
  46301. _currentNonTimestampToken: Nullable<_TimeToken>;
  46302. /** @hidden */
  46303. _createTimeQuery(): WebGLQuery;
  46304. /** @hidden */
  46305. _deleteTimeQuery(query: WebGLQuery): void;
  46306. /** @hidden */
  46307. _getGlAlgorithmType(algorithmType: number): number;
  46308. /** @hidden */
  46309. _getTimeQueryResult(query: WebGLQuery): any;
  46310. /** @hidden */
  46311. _getTimeQueryAvailability(query: WebGLQuery): any;
  46312. }
  46313. interface AbstractMesh {
  46314. /**
  46315. * Backing filed
  46316. * @hidden
  46317. */
  46318. __occlusionDataStorage: _OcclusionDataStorage;
  46319. /**
  46320. * Access property
  46321. * @hidden
  46322. */
  46323. _occlusionDataStorage: _OcclusionDataStorage;
  46324. /**
  46325. * 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.
  46326. * The default value is -1 which means don't break the query and wait till the result
  46327. * @see http://doc.babylonjs.com/features/occlusionquery
  46328. */
  46329. occlusionRetryCount: number;
  46330. /**
  46331. * 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:
  46332. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46333. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46334. * * 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.
  46335. * @see http://doc.babylonjs.com/features/occlusionquery
  46336. */
  46337. occlusionType: number;
  46338. /**
  46339. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46340. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46341. * * 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.
  46342. * @see http://doc.babylonjs.com/features/occlusionquery
  46343. */
  46344. occlusionQueryAlgorithmType: number;
  46345. /**
  46346. * 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
  46347. * @see http://doc.babylonjs.com/features/occlusionquery
  46348. */
  46349. isOccluded: boolean;
  46350. /**
  46351. * Flag to check the progress status of the query
  46352. * @see http://doc.babylonjs.com/features/occlusionquery
  46353. */
  46354. isOcclusionQueryInProgress: boolean;
  46355. }
  46356. }
  46357. declare module BABYLON {
  46358. /** @hidden */
  46359. export var _forceTransformFeedbackToBundle: boolean;
  46360. interface Engine {
  46361. /**
  46362. * Creates a webGL transform feedback object
  46363. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46364. * @returns the webGL transform feedback object
  46365. */
  46366. createTransformFeedback(): WebGLTransformFeedback;
  46367. /**
  46368. * Delete a webGL transform feedback object
  46369. * @param value defines the webGL transform feedback object to delete
  46370. */
  46371. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46372. /**
  46373. * Bind a webGL transform feedback object to the webgl context
  46374. * @param value defines the webGL transform feedback object to bind
  46375. */
  46376. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46377. /**
  46378. * Begins a transform feedback operation
  46379. * @param usePoints defines if points or triangles must be used
  46380. */
  46381. beginTransformFeedback(usePoints: boolean): void;
  46382. /**
  46383. * Ends a transform feedback operation
  46384. */
  46385. endTransformFeedback(): void;
  46386. /**
  46387. * Specify the varyings to use with transform feedback
  46388. * @param program defines the associated webGL program
  46389. * @param value defines the list of strings representing the varying names
  46390. */
  46391. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46392. /**
  46393. * Bind a webGL buffer for a transform feedback operation
  46394. * @param value defines the webGL buffer to bind
  46395. */
  46396. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46397. }
  46398. }
  46399. declare module BABYLON {
  46400. /**
  46401. * Creation options of the multi render target texture.
  46402. */
  46403. export interface IMultiRenderTargetOptions {
  46404. /**
  46405. * Define if the texture needs to create mip maps after render.
  46406. */
  46407. generateMipMaps?: boolean;
  46408. /**
  46409. * Define the types of all the draw buffers we want to create
  46410. */
  46411. types?: number[];
  46412. /**
  46413. * Define the sampling modes of all the draw buffers we want to create
  46414. */
  46415. samplingModes?: number[];
  46416. /**
  46417. * Define if a depth buffer is required
  46418. */
  46419. generateDepthBuffer?: boolean;
  46420. /**
  46421. * Define if a stencil buffer is required
  46422. */
  46423. generateStencilBuffer?: boolean;
  46424. /**
  46425. * Define if a depth texture is required instead of a depth buffer
  46426. */
  46427. generateDepthTexture?: boolean;
  46428. /**
  46429. * Define the number of desired draw buffers
  46430. */
  46431. textureCount?: number;
  46432. /**
  46433. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46434. */
  46435. doNotChangeAspectRatio?: boolean;
  46436. /**
  46437. * Define the default type of the buffers we are creating
  46438. */
  46439. defaultType?: number;
  46440. }
  46441. /**
  46442. * A multi render target, like a render target provides the ability to render to a texture.
  46443. * Unlike the render target, it can render to several draw buffers in one draw.
  46444. * This is specially interesting in deferred rendering or for any effects requiring more than
  46445. * just one color from a single pass.
  46446. */
  46447. export class MultiRenderTarget extends RenderTargetTexture {
  46448. private _internalTextures;
  46449. private _textures;
  46450. private _multiRenderTargetOptions;
  46451. /**
  46452. * Get if draw buffers are currently supported by the used hardware and browser.
  46453. */
  46454. get isSupported(): boolean;
  46455. /**
  46456. * Get the list of textures generated by the multi render target.
  46457. */
  46458. get textures(): Texture[];
  46459. /**
  46460. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46461. */
  46462. get depthTexture(): Texture;
  46463. /**
  46464. * Set the wrapping mode on U of all the textures we are rendering to.
  46465. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46466. */
  46467. set wrapU(wrap: number);
  46468. /**
  46469. * Set the wrapping mode on V of all the textures we are rendering to.
  46470. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46471. */
  46472. set wrapV(wrap: number);
  46473. /**
  46474. * Instantiate a new multi render target texture.
  46475. * A multi render target, like a render target provides the ability to render to a texture.
  46476. * Unlike the render target, it can render to several draw buffers in one draw.
  46477. * This is specially interesting in deferred rendering or for any effects requiring more than
  46478. * just one color from a single pass.
  46479. * @param name Define the name of the texture
  46480. * @param size Define the size of the buffers to render to
  46481. * @param count Define the number of target we are rendering into
  46482. * @param scene Define the scene the texture belongs to
  46483. * @param options Define the options used to create the multi render target
  46484. */
  46485. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46486. /** @hidden */
  46487. _rebuild(): void;
  46488. private _createInternalTextures;
  46489. private _createTextures;
  46490. /**
  46491. * Define the number of samples used if MSAA is enabled.
  46492. */
  46493. get samples(): number;
  46494. set samples(value: number);
  46495. /**
  46496. * Resize all the textures in the multi render target.
  46497. * Be carrefull as it will recreate all the data in the new texture.
  46498. * @param size Define the new size
  46499. */
  46500. resize(size: any): void;
  46501. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46502. /**
  46503. * Dispose the render targets and their associated resources
  46504. */
  46505. dispose(): void;
  46506. /**
  46507. * Release all the underlying texture used as draw buffers.
  46508. */
  46509. releaseInternalTextures(): void;
  46510. }
  46511. }
  46512. declare module BABYLON {
  46513. interface ThinEngine {
  46514. /**
  46515. * Unbind a list of render target textures from the webGL context
  46516. * This is used only when drawBuffer extension or webGL2 are active
  46517. * @param textures defines the render target textures to unbind
  46518. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46519. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46520. */
  46521. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46522. /**
  46523. * Create a multi render target texture
  46524. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46525. * @param size defines the size of the texture
  46526. * @param options defines the creation options
  46527. * @returns the cube texture as an InternalTexture
  46528. */
  46529. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46530. /**
  46531. * Update the sample count for a given multiple render target texture
  46532. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46533. * @param textures defines the textures to update
  46534. * @param samples defines the sample count to set
  46535. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46536. */
  46537. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46538. }
  46539. }
  46540. declare module BABYLON {
  46541. /**
  46542. * Class used to define an additional view for the engine
  46543. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46544. */
  46545. export class EngineView {
  46546. /** Defines the canvas where to render the view */
  46547. target: HTMLCanvasElement;
  46548. /** Defines an optional camera used to render the view (will use active camera else) */
  46549. camera?: Camera;
  46550. }
  46551. interface Engine {
  46552. /**
  46553. * Gets or sets the HTML element to use for attaching events
  46554. */
  46555. inputElement: Nullable<HTMLElement>;
  46556. /**
  46557. * Gets the current engine view
  46558. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46559. */
  46560. activeView: Nullable<EngineView>;
  46561. /** Gets or sets the list of views */
  46562. views: EngineView[];
  46563. /**
  46564. * Register a new child canvas
  46565. * @param canvas defines the canvas to register
  46566. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46567. * @returns the associated view
  46568. */
  46569. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46570. /**
  46571. * Remove a registered child canvas
  46572. * @param canvas defines the canvas to remove
  46573. * @returns the current engine
  46574. */
  46575. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46576. }
  46577. }
  46578. declare module BABYLON {
  46579. /**
  46580. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46581. */
  46582. export interface CubeMapInfo {
  46583. /**
  46584. * The pixel array for the front face.
  46585. * This is stored in format, left to right, up to down format.
  46586. */
  46587. front: Nullable<ArrayBufferView>;
  46588. /**
  46589. * The pixel array for the back face.
  46590. * This is stored in format, left to right, up to down format.
  46591. */
  46592. back: Nullable<ArrayBufferView>;
  46593. /**
  46594. * The pixel array for the left face.
  46595. * This is stored in format, left to right, up to down format.
  46596. */
  46597. left: Nullable<ArrayBufferView>;
  46598. /**
  46599. * The pixel array for the right face.
  46600. * This is stored in format, left to right, up to down format.
  46601. */
  46602. right: Nullable<ArrayBufferView>;
  46603. /**
  46604. * The pixel array for the up face.
  46605. * This is stored in format, left to right, up to down format.
  46606. */
  46607. up: Nullable<ArrayBufferView>;
  46608. /**
  46609. * The pixel array for the down face.
  46610. * This is stored in format, left to right, up to down format.
  46611. */
  46612. down: Nullable<ArrayBufferView>;
  46613. /**
  46614. * The size of the cubemap stored.
  46615. *
  46616. * Each faces will be size * size pixels.
  46617. */
  46618. size: number;
  46619. /**
  46620. * The format of the texture.
  46621. *
  46622. * RGBA, RGB.
  46623. */
  46624. format: number;
  46625. /**
  46626. * The type of the texture data.
  46627. *
  46628. * UNSIGNED_INT, FLOAT.
  46629. */
  46630. type: number;
  46631. /**
  46632. * Specifies whether the texture is in gamma space.
  46633. */
  46634. gammaSpace: boolean;
  46635. }
  46636. /**
  46637. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46638. */
  46639. export class PanoramaToCubeMapTools {
  46640. private static FACE_FRONT;
  46641. private static FACE_BACK;
  46642. private static FACE_RIGHT;
  46643. private static FACE_LEFT;
  46644. private static FACE_DOWN;
  46645. private static FACE_UP;
  46646. /**
  46647. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46648. *
  46649. * @param float32Array The source data.
  46650. * @param inputWidth The width of the input panorama.
  46651. * @param inputHeight The height of the input panorama.
  46652. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46653. * @return The cubemap data
  46654. */
  46655. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46656. private static CreateCubemapTexture;
  46657. private static CalcProjectionSpherical;
  46658. }
  46659. }
  46660. declare module BABYLON {
  46661. /**
  46662. * Helper class dealing with the extraction of spherical polynomial dataArray
  46663. * from a cube map.
  46664. */
  46665. export class CubeMapToSphericalPolynomialTools {
  46666. private static FileFaces;
  46667. /**
  46668. * Converts a texture to the according Spherical Polynomial data.
  46669. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46670. *
  46671. * @param texture The texture to extract the information from.
  46672. * @return The Spherical Polynomial data.
  46673. */
  46674. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46675. /**
  46676. * Converts a cubemap to the according Spherical Polynomial data.
  46677. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46678. *
  46679. * @param cubeInfo The Cube map to extract the information from.
  46680. * @return The Spherical Polynomial data.
  46681. */
  46682. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46683. }
  46684. }
  46685. declare module BABYLON {
  46686. interface BaseTexture {
  46687. /**
  46688. * Get the polynomial representation of the texture data.
  46689. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46690. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46691. */
  46692. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46693. }
  46694. }
  46695. declare module BABYLON {
  46696. /** @hidden */
  46697. export var rgbdEncodePixelShader: {
  46698. name: string;
  46699. shader: string;
  46700. };
  46701. }
  46702. declare module BABYLON {
  46703. /** @hidden */
  46704. export var rgbdDecodePixelShader: {
  46705. name: string;
  46706. shader: string;
  46707. };
  46708. }
  46709. declare module BABYLON {
  46710. /**
  46711. * Raw texture data and descriptor sufficient for WebGL texture upload
  46712. */
  46713. export interface EnvironmentTextureInfo {
  46714. /**
  46715. * Version of the environment map
  46716. */
  46717. version: number;
  46718. /**
  46719. * Width of image
  46720. */
  46721. width: number;
  46722. /**
  46723. * Irradiance information stored in the file.
  46724. */
  46725. irradiance: any;
  46726. /**
  46727. * Specular information stored in the file.
  46728. */
  46729. specular: any;
  46730. }
  46731. /**
  46732. * Defines One Image in the file. It requires only the position in the file
  46733. * as well as the length.
  46734. */
  46735. interface BufferImageData {
  46736. /**
  46737. * Length of the image data.
  46738. */
  46739. length: number;
  46740. /**
  46741. * Position of the data from the null terminator delimiting the end of the JSON.
  46742. */
  46743. position: number;
  46744. }
  46745. /**
  46746. * Defines the specular data enclosed in the file.
  46747. * This corresponds to the version 1 of the data.
  46748. */
  46749. export interface EnvironmentTextureSpecularInfoV1 {
  46750. /**
  46751. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46752. */
  46753. specularDataPosition?: number;
  46754. /**
  46755. * This contains all the images data needed to reconstruct the cubemap.
  46756. */
  46757. mipmaps: Array<BufferImageData>;
  46758. /**
  46759. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46760. */
  46761. lodGenerationScale: number;
  46762. }
  46763. /**
  46764. * Sets of helpers addressing the serialization and deserialization of environment texture
  46765. * stored in a BabylonJS env file.
  46766. * Those files are usually stored as .env files.
  46767. */
  46768. export class EnvironmentTextureTools {
  46769. /**
  46770. * Magic number identifying the env file.
  46771. */
  46772. private static _MagicBytes;
  46773. /**
  46774. * Gets the environment info from an env file.
  46775. * @param data The array buffer containing the .env bytes.
  46776. * @returns the environment file info (the json header) if successfully parsed.
  46777. */
  46778. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46779. /**
  46780. * Creates an environment texture from a loaded cube texture.
  46781. * @param texture defines the cube texture to convert in env file
  46782. * @return a promise containing the environment data if succesfull.
  46783. */
  46784. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46785. /**
  46786. * Creates a JSON representation of the spherical data.
  46787. * @param texture defines the texture containing the polynomials
  46788. * @return the JSON representation of the spherical info
  46789. */
  46790. private static _CreateEnvTextureIrradiance;
  46791. /**
  46792. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46793. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46794. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46795. * @return the views described by info providing access to the underlying buffer
  46796. */
  46797. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46798. /**
  46799. * Uploads the texture info contained in the env file to the GPU.
  46800. * @param texture defines the internal texture to upload to
  46801. * @param arrayBuffer defines the buffer cotaining the data to load
  46802. * @param info defines the texture info retrieved through the GetEnvInfo method
  46803. * @returns a promise
  46804. */
  46805. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46806. private static _OnImageReadyAsync;
  46807. /**
  46808. * Uploads the levels of image data to the GPU.
  46809. * @param texture defines the internal texture to upload to
  46810. * @param imageData defines the array buffer views of image data [mipmap][face]
  46811. * @returns a promise
  46812. */
  46813. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46814. /**
  46815. * Uploads spherical polynomials information to the texture.
  46816. * @param texture defines the texture we are trying to upload the information to
  46817. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46818. */
  46819. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46820. /** @hidden */
  46821. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46822. }
  46823. }
  46824. declare module BABYLON {
  46825. /**
  46826. * Contains position and normal vectors for a vertex
  46827. */
  46828. export class PositionNormalVertex {
  46829. /** the position of the vertex (defaut: 0,0,0) */
  46830. position: Vector3;
  46831. /** the normal of the vertex (defaut: 0,1,0) */
  46832. normal: Vector3;
  46833. /**
  46834. * Creates a PositionNormalVertex
  46835. * @param position the position of the vertex (defaut: 0,0,0)
  46836. * @param normal the normal of the vertex (defaut: 0,1,0)
  46837. */
  46838. constructor(
  46839. /** the position of the vertex (defaut: 0,0,0) */
  46840. position?: Vector3,
  46841. /** the normal of the vertex (defaut: 0,1,0) */
  46842. normal?: Vector3);
  46843. /**
  46844. * Clones the PositionNormalVertex
  46845. * @returns the cloned PositionNormalVertex
  46846. */
  46847. clone(): PositionNormalVertex;
  46848. }
  46849. /**
  46850. * Contains position, normal and uv vectors for a vertex
  46851. */
  46852. export class PositionNormalTextureVertex {
  46853. /** the position of the vertex (defaut: 0,0,0) */
  46854. position: Vector3;
  46855. /** the normal of the vertex (defaut: 0,1,0) */
  46856. normal: Vector3;
  46857. /** the uv of the vertex (default: 0,0) */
  46858. uv: Vector2;
  46859. /**
  46860. * Creates a PositionNormalTextureVertex
  46861. * @param position the position of the vertex (defaut: 0,0,0)
  46862. * @param normal the normal of the vertex (defaut: 0,1,0)
  46863. * @param uv the uv of the vertex (default: 0,0)
  46864. */
  46865. constructor(
  46866. /** the position of the vertex (defaut: 0,0,0) */
  46867. position?: Vector3,
  46868. /** the normal of the vertex (defaut: 0,1,0) */
  46869. normal?: Vector3,
  46870. /** the uv of the vertex (default: 0,0) */
  46871. uv?: Vector2);
  46872. /**
  46873. * Clones the PositionNormalTextureVertex
  46874. * @returns the cloned PositionNormalTextureVertex
  46875. */
  46876. clone(): PositionNormalTextureVertex;
  46877. }
  46878. }
  46879. declare module BABYLON {
  46880. /** @hidden */
  46881. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46882. private _genericAttributeLocation;
  46883. private _varyingLocationCount;
  46884. private _varyingLocationMap;
  46885. private _replacements;
  46886. private _textureCount;
  46887. private _uniforms;
  46888. lineProcessor(line: string): string;
  46889. attributeProcessor(attribute: string): string;
  46890. varyingProcessor(varying: string, isFragment: boolean): string;
  46891. uniformProcessor(uniform: string): string;
  46892. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46893. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46894. }
  46895. }
  46896. declare module BABYLON {
  46897. /**
  46898. * Container for accessors for natively-stored mesh data buffers.
  46899. */
  46900. class NativeDataBuffer extends DataBuffer {
  46901. /**
  46902. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46903. */
  46904. nativeIndexBuffer?: any;
  46905. /**
  46906. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46907. */
  46908. nativeVertexBuffer?: any;
  46909. }
  46910. /** @hidden */
  46911. class NativeTexture extends InternalTexture {
  46912. getInternalTexture(): InternalTexture;
  46913. getViewCount(): number;
  46914. }
  46915. /** @hidden */
  46916. export class NativeEngine extends Engine {
  46917. private readonly _native;
  46918. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46919. private readonly INVALID_HANDLE;
  46920. getHardwareScalingLevel(): number;
  46921. constructor();
  46922. /**
  46923. * Can be used to override the current requestAnimationFrame requester.
  46924. * @hidden
  46925. */
  46926. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46927. /**
  46928. * Override default engine behavior.
  46929. * @param color
  46930. * @param backBuffer
  46931. * @param depth
  46932. * @param stencil
  46933. */
  46934. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46935. /**
  46936. * Gets host document
  46937. * @returns the host document object
  46938. */
  46939. getHostDocument(): Nullable<Document>;
  46940. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46941. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46942. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46943. recordVertexArrayObject(vertexBuffers: {
  46944. [key: string]: VertexBuffer;
  46945. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46946. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46947. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46948. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46949. /**
  46950. * Draw a list of indexed primitives
  46951. * @param fillMode defines the primitive to use
  46952. * @param indexStart defines the starting index
  46953. * @param indexCount defines the number of index to draw
  46954. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46955. */
  46956. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46957. /**
  46958. * Draw a list of unindexed primitives
  46959. * @param fillMode defines the primitive to use
  46960. * @param verticesStart defines the index of first vertex to draw
  46961. * @param verticesCount defines the count of vertices to draw
  46962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46963. */
  46964. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46965. createPipelineContext(): IPipelineContext;
  46966. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46967. /** @hidden */
  46968. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46969. /** @hidden */
  46970. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46971. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46972. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46973. protected _setProgram(program: WebGLProgram): void;
  46974. _releaseEffect(effect: Effect): void;
  46975. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46976. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46977. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46978. bindSamplers(effect: Effect): void;
  46979. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46980. getRenderWidth(useScreen?: boolean): number;
  46981. getRenderHeight(useScreen?: boolean): number;
  46982. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46984. /**
  46985. * Set the z offset to apply to current rendering
  46986. * @param value defines the offset to apply
  46987. */
  46988. setZOffset(value: number): void;
  46989. /**
  46990. * Gets the current value of the zOffset
  46991. * @returns the current zOffset state
  46992. */
  46993. getZOffset(): number;
  46994. /**
  46995. * Enable or disable depth buffering
  46996. * @param enable defines the state to set
  46997. */
  46998. setDepthBuffer(enable: boolean): void;
  46999. /**
  47000. * Gets a boolean indicating if depth writing is enabled
  47001. * @returns the current depth writing state
  47002. */
  47003. getDepthWrite(): boolean;
  47004. /**
  47005. * Enable or disable depth writing
  47006. * @param enable defines the state to set
  47007. */
  47008. setDepthWrite(enable: boolean): void;
  47009. /**
  47010. * Enable or disable color writing
  47011. * @param enable defines the state to set
  47012. */
  47013. setColorWrite(enable: boolean): void;
  47014. /**
  47015. * Gets a boolean indicating if color writing is enabled
  47016. * @returns the current color writing state
  47017. */
  47018. getColorWrite(): boolean;
  47019. /**
  47020. * Sets alpha constants used by some alpha blending modes
  47021. * @param r defines the red component
  47022. * @param g defines the green component
  47023. * @param b defines the blue component
  47024. * @param a defines the alpha component
  47025. */
  47026. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47027. /**
  47028. * Sets the current alpha mode
  47029. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47030. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47031. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47032. */
  47033. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47034. /**
  47035. * Gets the current alpha mode
  47036. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47037. * @returns the current alpha mode
  47038. */
  47039. getAlphaMode(): number;
  47040. setInt(uniform: WebGLUniformLocation, int: number): void;
  47041. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47042. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47043. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47044. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47045. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47046. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47047. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47048. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47049. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47050. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47051. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47052. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47053. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47054. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47055. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47056. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47057. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47058. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47059. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47060. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47061. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47062. wipeCaches(bruteForce?: boolean): void;
  47063. _createTexture(): WebGLTexture;
  47064. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47065. /**
  47066. * Usually called from BABYLON.Texture.ts.
  47067. * Passed information to create a WebGLTexture
  47068. * @param urlArg defines a value which contains one of the following:
  47069. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47070. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47071. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47072. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47073. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47074. * @param scene needed for loading to the correct scene
  47075. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47076. * @param onLoad optional callback to be called upon successful completion
  47077. * @param onError optional callback to be called upon failure
  47078. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47079. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47080. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47081. * @param forcedExtension defines the extension to use to pick the right loader
  47082. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47083. */
  47084. 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;
  47085. /**
  47086. * Creates a cube texture
  47087. * @param rootUrl defines the url where the files to load is located
  47088. * @param scene defines the current scene
  47089. * @param files defines the list of files to load (1 per face)
  47090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47091. * @param onLoad defines an optional callback raised when the texture is loaded
  47092. * @param onError defines an optional callback raised if there is an issue to load the texture
  47093. * @param format defines the format of the data
  47094. * @param forcedExtension defines the extension to use to pick the right loader
  47095. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47096. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47097. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47098. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47099. * @returns the cube texture as an InternalTexture
  47100. */
  47101. 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;
  47102. private _getSamplingFilter;
  47103. private static _GetNativeTextureFormat;
  47104. createRenderTargetTexture(size: number | {
  47105. width: number;
  47106. height: number;
  47107. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47108. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47109. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47110. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47111. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47112. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47113. /**
  47114. * Updates a dynamic vertex buffer.
  47115. * @param vertexBuffer the vertex buffer to update
  47116. * @param data the data used to update the vertex buffer
  47117. * @param byteOffset the byte offset of the data (optional)
  47118. * @param byteLength the byte length of the data (optional)
  47119. */
  47120. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47121. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47122. private _updateAnisotropicLevel;
  47123. private _getAddressMode;
  47124. /** @hidden */
  47125. _bindTexture(channel: number, texture: InternalTexture): void;
  47126. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47127. releaseEffects(): void;
  47128. /** @hidden */
  47129. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47130. /** @hidden */
  47131. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47132. /** @hidden */
  47133. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47134. /** @hidden */
  47135. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47136. }
  47137. }
  47138. declare module BABYLON {
  47139. /**
  47140. * Gather the list of clipboard event types as constants.
  47141. */
  47142. export class ClipboardEventTypes {
  47143. /**
  47144. * The clipboard event is fired when a copy command is active (pressed).
  47145. */
  47146. static readonly COPY: number;
  47147. /**
  47148. * The clipboard event is fired when a cut command is active (pressed).
  47149. */
  47150. static readonly CUT: number;
  47151. /**
  47152. * The clipboard event is fired when a paste command is active (pressed).
  47153. */
  47154. static readonly PASTE: number;
  47155. }
  47156. /**
  47157. * This class is used to store clipboard related info for the onClipboardObservable event.
  47158. */
  47159. export class ClipboardInfo {
  47160. /**
  47161. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47162. */
  47163. type: number;
  47164. /**
  47165. * Defines the related dom event
  47166. */
  47167. event: ClipboardEvent;
  47168. /**
  47169. *Creates an instance of ClipboardInfo.
  47170. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47171. * @param event Defines the related dom event
  47172. */
  47173. constructor(
  47174. /**
  47175. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47176. */
  47177. type: number,
  47178. /**
  47179. * Defines the related dom event
  47180. */
  47181. event: ClipboardEvent);
  47182. /**
  47183. * Get the clipboard event's type from the keycode.
  47184. * @param keyCode Defines the keyCode for the current keyboard event.
  47185. * @return {number}
  47186. */
  47187. static GetTypeFromCharacter(keyCode: number): number;
  47188. }
  47189. }
  47190. declare module BABYLON {
  47191. /**
  47192. * Google Daydream controller
  47193. */
  47194. export class DaydreamController extends WebVRController {
  47195. /**
  47196. * Base Url for the controller model.
  47197. */
  47198. static MODEL_BASE_URL: string;
  47199. /**
  47200. * File name for the controller model.
  47201. */
  47202. static MODEL_FILENAME: string;
  47203. /**
  47204. * Gamepad Id prefix used to identify Daydream Controller.
  47205. */
  47206. static readonly GAMEPAD_ID_PREFIX: string;
  47207. /**
  47208. * Creates a new DaydreamController from a gamepad
  47209. * @param vrGamepad the gamepad that the controller should be created from
  47210. */
  47211. constructor(vrGamepad: any);
  47212. /**
  47213. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47214. * @param scene scene in which to add meshes
  47215. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47216. */
  47217. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47218. /**
  47219. * Called once for each button that changed state since the last frame
  47220. * @param buttonIdx Which button index changed
  47221. * @param state New state of the button
  47222. * @param changes Which properties on the state changed since last frame
  47223. */
  47224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47225. }
  47226. }
  47227. declare module BABYLON {
  47228. /**
  47229. * Gear VR Controller
  47230. */
  47231. export class GearVRController extends WebVRController {
  47232. /**
  47233. * Base Url for the controller model.
  47234. */
  47235. static MODEL_BASE_URL: string;
  47236. /**
  47237. * File name for the controller model.
  47238. */
  47239. static MODEL_FILENAME: string;
  47240. /**
  47241. * Gamepad Id prefix used to identify this controller.
  47242. */
  47243. static readonly GAMEPAD_ID_PREFIX: string;
  47244. private readonly _buttonIndexToObservableNameMap;
  47245. /**
  47246. * Creates a new GearVRController from a gamepad
  47247. * @param vrGamepad the gamepad that the controller should be created from
  47248. */
  47249. constructor(vrGamepad: any);
  47250. /**
  47251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47252. * @param scene scene in which to add meshes
  47253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47254. */
  47255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47256. /**
  47257. * Called once for each button that changed state since the last frame
  47258. * @param buttonIdx Which button index changed
  47259. * @param state New state of the button
  47260. * @param changes Which properties on the state changed since last frame
  47261. */
  47262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47263. }
  47264. }
  47265. declare module BABYLON {
  47266. /**
  47267. * Class containing static functions to help procedurally build meshes
  47268. */
  47269. export class PolyhedronBuilder {
  47270. /**
  47271. * Creates a polyhedron mesh
  47272. * * 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
  47273. * * The parameter `size` (positive float, default 1) sets the polygon size
  47274. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47275. * * 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`
  47276. * * 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
  47277. * * 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)`)
  47278. * * 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
  47279. * * 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
  47280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47281. * * 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
  47282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47283. * @param name defines the name of the mesh
  47284. * @param options defines the options used to create the mesh
  47285. * @param scene defines the hosting scene
  47286. * @returns the polyhedron mesh
  47287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47288. */
  47289. static CreatePolyhedron(name: string, options: {
  47290. type?: number;
  47291. size?: number;
  47292. sizeX?: number;
  47293. sizeY?: number;
  47294. sizeZ?: number;
  47295. custom?: any;
  47296. faceUV?: Vector4[];
  47297. faceColors?: Color4[];
  47298. flat?: boolean;
  47299. updatable?: boolean;
  47300. sideOrientation?: number;
  47301. frontUVs?: Vector4;
  47302. backUVs?: Vector4;
  47303. }, scene?: Nullable<Scene>): Mesh;
  47304. }
  47305. }
  47306. declare module BABYLON {
  47307. /**
  47308. * Gizmo that enables scaling a mesh along 3 axis
  47309. */
  47310. export class ScaleGizmo extends Gizmo {
  47311. /**
  47312. * Internal gizmo used for interactions on the x axis
  47313. */
  47314. xGizmo: AxisScaleGizmo;
  47315. /**
  47316. * Internal gizmo used for interactions on the y axis
  47317. */
  47318. yGizmo: AxisScaleGizmo;
  47319. /**
  47320. * Internal gizmo used for interactions on the z axis
  47321. */
  47322. zGizmo: AxisScaleGizmo;
  47323. /**
  47324. * Internal gizmo used to scale all axis equally
  47325. */
  47326. uniformScaleGizmo: AxisScaleGizmo;
  47327. private _meshAttached;
  47328. private _updateGizmoRotationToMatchAttachedMesh;
  47329. private _snapDistance;
  47330. private _scaleRatio;
  47331. private _uniformScalingMesh;
  47332. private _octahedron;
  47333. private _sensitivity;
  47334. /** Fires an event when any of it's sub gizmos are dragged */
  47335. onDragStartObservable: Observable<unknown>;
  47336. /** Fires an event when any of it's sub gizmos are released from dragging */
  47337. onDragEndObservable: Observable<unknown>;
  47338. get attachedMesh(): Nullable<AbstractMesh>;
  47339. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47340. /**
  47341. * Creates a ScaleGizmo
  47342. * @param gizmoLayer The utility layer the gizmo will be added to
  47343. */
  47344. constructor(gizmoLayer?: UtilityLayerRenderer);
  47345. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47346. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47347. /**
  47348. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47349. */
  47350. set snapDistance(value: number);
  47351. get snapDistance(): number;
  47352. /**
  47353. * Ratio for the scale of the gizmo (Default: 1)
  47354. */
  47355. set scaleRatio(value: number);
  47356. get scaleRatio(): number;
  47357. /**
  47358. * Sensitivity factor for dragging (Default: 1)
  47359. */
  47360. set sensitivity(value: number);
  47361. get sensitivity(): number;
  47362. /**
  47363. * Disposes of the gizmo
  47364. */
  47365. dispose(): void;
  47366. }
  47367. }
  47368. declare module BABYLON {
  47369. /**
  47370. * Single axis scale gizmo
  47371. */
  47372. export class AxisScaleGizmo extends Gizmo {
  47373. /**
  47374. * Drag behavior responsible for the gizmos dragging interactions
  47375. */
  47376. dragBehavior: PointerDragBehavior;
  47377. private _pointerObserver;
  47378. /**
  47379. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47380. */
  47381. snapDistance: number;
  47382. /**
  47383. * Event that fires each time the gizmo snaps to a new location.
  47384. * * snapDistance is the the change in distance
  47385. */
  47386. onSnapObservable: Observable<{
  47387. snapDistance: number;
  47388. }>;
  47389. /**
  47390. * If the scaling operation should be done on all axis (default: false)
  47391. */
  47392. uniformScaling: boolean;
  47393. /**
  47394. * Custom sensitivity value for the drag strength
  47395. */
  47396. sensitivity: number;
  47397. private _isEnabled;
  47398. private _parent;
  47399. private _arrow;
  47400. private _coloredMaterial;
  47401. private _hoverMaterial;
  47402. /**
  47403. * Creates an AxisScaleGizmo
  47404. * @param gizmoLayer The utility layer the gizmo will be added to
  47405. * @param dragAxis The axis which the gizmo will be able to scale on
  47406. * @param color The color of the gizmo
  47407. */
  47408. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47409. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47410. /**
  47411. * If the gizmo is enabled
  47412. */
  47413. set isEnabled(value: boolean);
  47414. get isEnabled(): boolean;
  47415. /**
  47416. * Disposes of the gizmo
  47417. */
  47418. dispose(): void;
  47419. /**
  47420. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47421. * @param mesh The mesh to replace the default mesh of the gizmo
  47422. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47423. */
  47424. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47425. }
  47426. }
  47427. declare module BABYLON {
  47428. /**
  47429. * Bounding box gizmo
  47430. */
  47431. export class BoundingBoxGizmo extends Gizmo {
  47432. private _lineBoundingBox;
  47433. private _rotateSpheresParent;
  47434. private _scaleBoxesParent;
  47435. private _boundingDimensions;
  47436. private _renderObserver;
  47437. private _pointerObserver;
  47438. private _scaleDragSpeed;
  47439. private _tmpQuaternion;
  47440. private _tmpVector;
  47441. private _tmpRotationMatrix;
  47442. /**
  47443. * 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)
  47444. */
  47445. ignoreChildren: boolean;
  47446. /**
  47447. * 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)
  47448. */
  47449. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47450. /**
  47451. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47452. */
  47453. rotationSphereSize: number;
  47454. /**
  47455. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47456. */
  47457. scaleBoxSize: number;
  47458. /**
  47459. * 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)
  47460. */
  47461. fixedDragMeshScreenSize: boolean;
  47462. /**
  47463. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47464. */
  47465. fixedDragMeshScreenSizeDistanceFactor: number;
  47466. /**
  47467. * Fired when a rotation sphere or scale box is dragged
  47468. */
  47469. onDragStartObservable: Observable<{}>;
  47470. /**
  47471. * Fired when a scale box is dragged
  47472. */
  47473. onScaleBoxDragObservable: Observable<{}>;
  47474. /**
  47475. * Fired when a scale box drag is ended
  47476. */
  47477. onScaleBoxDragEndObservable: Observable<{}>;
  47478. /**
  47479. * Fired when a rotation sphere is dragged
  47480. */
  47481. onRotationSphereDragObservable: Observable<{}>;
  47482. /**
  47483. * Fired when a rotation sphere drag is ended
  47484. */
  47485. onRotationSphereDragEndObservable: Observable<{}>;
  47486. /**
  47487. * 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)
  47488. */
  47489. scalePivot: Nullable<Vector3>;
  47490. /**
  47491. * Mesh used as a pivot to rotate the attached mesh
  47492. */
  47493. private _anchorMesh;
  47494. private _existingMeshScale;
  47495. private _dragMesh;
  47496. private pointerDragBehavior;
  47497. private coloredMaterial;
  47498. private hoverColoredMaterial;
  47499. /**
  47500. * Sets the color of the bounding box gizmo
  47501. * @param color the color to set
  47502. */
  47503. setColor(color: Color3): void;
  47504. /**
  47505. * Creates an BoundingBoxGizmo
  47506. * @param gizmoLayer The utility layer the gizmo will be added to
  47507. * @param color The color of the gizmo
  47508. */
  47509. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47510. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47511. private _selectNode;
  47512. /**
  47513. * Updates the bounding box information for the Gizmo
  47514. */
  47515. updateBoundingBox(): void;
  47516. private _updateRotationSpheres;
  47517. private _updateScaleBoxes;
  47518. /**
  47519. * Enables rotation on the specified axis and disables rotation on the others
  47520. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47521. */
  47522. setEnabledRotationAxis(axis: string): void;
  47523. /**
  47524. * Enables/disables scaling
  47525. * @param enable if scaling should be enabled
  47526. */
  47527. setEnabledScaling(enable: boolean): void;
  47528. private _updateDummy;
  47529. /**
  47530. * Enables a pointer drag behavior on the bounding box of the gizmo
  47531. */
  47532. enableDragBehavior(): void;
  47533. /**
  47534. * Disposes of the gizmo
  47535. */
  47536. dispose(): void;
  47537. /**
  47538. * 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)
  47539. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47540. * @returns the bounding box mesh with the passed in mesh as a child
  47541. */
  47542. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47543. /**
  47544. * CustomMeshes are not supported by this gizmo
  47545. * @param mesh The mesh to replace the default mesh of the gizmo
  47546. */
  47547. setCustomMesh(mesh: Mesh): void;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Single plane rotation gizmo
  47553. */
  47554. export class PlaneRotationGizmo extends Gizmo {
  47555. /**
  47556. * Drag behavior responsible for the gizmos dragging interactions
  47557. */
  47558. dragBehavior: PointerDragBehavior;
  47559. private _pointerObserver;
  47560. /**
  47561. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47562. */
  47563. snapDistance: number;
  47564. /**
  47565. * Event that fires each time the gizmo snaps to a new location.
  47566. * * snapDistance is the the change in distance
  47567. */
  47568. onSnapObservable: Observable<{
  47569. snapDistance: number;
  47570. }>;
  47571. private _isEnabled;
  47572. private _parent;
  47573. /**
  47574. * Creates a PlaneRotationGizmo
  47575. * @param gizmoLayer The utility layer the gizmo will be added to
  47576. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47577. * @param color The color of the gizmo
  47578. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47579. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47580. */
  47581. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47583. /**
  47584. * If the gizmo is enabled
  47585. */
  47586. set isEnabled(value: boolean);
  47587. get isEnabled(): boolean;
  47588. /**
  47589. * Disposes of the gizmo
  47590. */
  47591. dispose(): void;
  47592. }
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Gizmo that enables rotating a mesh along 3 axis
  47597. */
  47598. export class RotationGizmo extends Gizmo {
  47599. /**
  47600. * Internal gizmo used for interactions on the x axis
  47601. */
  47602. xGizmo: PlaneRotationGizmo;
  47603. /**
  47604. * Internal gizmo used for interactions on the y axis
  47605. */
  47606. yGizmo: PlaneRotationGizmo;
  47607. /**
  47608. * Internal gizmo used for interactions on the z axis
  47609. */
  47610. zGizmo: PlaneRotationGizmo;
  47611. /** Fires an event when any of it's sub gizmos are dragged */
  47612. onDragStartObservable: Observable<unknown>;
  47613. /** Fires an event when any of it's sub gizmos are released from dragging */
  47614. onDragEndObservable: Observable<unknown>;
  47615. private _meshAttached;
  47616. get attachedMesh(): Nullable<AbstractMesh>;
  47617. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47618. /**
  47619. * Creates a RotationGizmo
  47620. * @param gizmoLayer The utility layer the gizmo will be added to
  47621. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47622. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47623. */
  47624. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47625. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47626. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47627. /**
  47628. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47629. */
  47630. set snapDistance(value: number);
  47631. get snapDistance(): number;
  47632. /**
  47633. * Ratio for the scale of the gizmo (Default: 1)
  47634. */
  47635. set scaleRatio(value: number);
  47636. get scaleRatio(): number;
  47637. /**
  47638. * Disposes of the gizmo
  47639. */
  47640. dispose(): void;
  47641. /**
  47642. * CustomMeshes are not supported by this gizmo
  47643. * @param mesh The mesh to replace the default mesh of the gizmo
  47644. */
  47645. setCustomMesh(mesh: Mesh): void;
  47646. }
  47647. }
  47648. declare module BABYLON {
  47649. /**
  47650. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47651. */
  47652. export class GizmoManager implements IDisposable {
  47653. private scene;
  47654. /**
  47655. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47656. */
  47657. gizmos: {
  47658. positionGizmo: Nullable<PositionGizmo>;
  47659. rotationGizmo: Nullable<RotationGizmo>;
  47660. scaleGizmo: Nullable<ScaleGizmo>;
  47661. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47662. };
  47663. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47664. clearGizmoOnEmptyPointerEvent: boolean;
  47665. /** Fires an event when the manager is attached to a mesh */
  47666. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47667. private _gizmosEnabled;
  47668. private _pointerObserver;
  47669. private _attachedMesh;
  47670. private _boundingBoxColor;
  47671. private _defaultUtilityLayer;
  47672. private _defaultKeepDepthUtilityLayer;
  47673. /**
  47674. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47675. */
  47676. boundingBoxDragBehavior: SixDofDragBehavior;
  47677. /**
  47678. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47679. */
  47680. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47681. /**
  47682. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47683. */
  47684. usePointerToAttachGizmos: boolean;
  47685. /**
  47686. * Utility layer that the bounding box gizmo belongs to
  47687. */
  47688. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47689. /**
  47690. * Utility layer that all gizmos besides bounding box belong to
  47691. */
  47692. get utilityLayer(): UtilityLayerRenderer;
  47693. /**
  47694. * Instatiates a gizmo manager
  47695. * @param scene the scene to overlay the gizmos on top of
  47696. */
  47697. constructor(scene: Scene);
  47698. /**
  47699. * Attaches a set of gizmos to the specified mesh
  47700. * @param mesh The mesh the gizmo's should be attached to
  47701. */
  47702. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47703. /**
  47704. * If the position gizmo is enabled
  47705. */
  47706. set positionGizmoEnabled(value: boolean);
  47707. get positionGizmoEnabled(): boolean;
  47708. /**
  47709. * If the rotation gizmo is enabled
  47710. */
  47711. set rotationGizmoEnabled(value: boolean);
  47712. get rotationGizmoEnabled(): boolean;
  47713. /**
  47714. * If the scale gizmo is enabled
  47715. */
  47716. set scaleGizmoEnabled(value: boolean);
  47717. get scaleGizmoEnabled(): boolean;
  47718. /**
  47719. * If the boundingBox gizmo is enabled
  47720. */
  47721. set boundingBoxGizmoEnabled(value: boolean);
  47722. get boundingBoxGizmoEnabled(): boolean;
  47723. /**
  47724. * Disposes of the gizmo manager
  47725. */
  47726. dispose(): void;
  47727. }
  47728. }
  47729. declare module BABYLON {
  47730. /**
  47731. * A directional light is defined by a direction (what a surprise!).
  47732. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47733. * 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.
  47734. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47735. */
  47736. export class DirectionalLight extends ShadowLight {
  47737. private _shadowFrustumSize;
  47738. /**
  47739. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47740. */
  47741. get shadowFrustumSize(): number;
  47742. /**
  47743. * Specifies a fix frustum size for the shadow generation.
  47744. */
  47745. set shadowFrustumSize(value: number);
  47746. private _shadowOrthoScale;
  47747. /**
  47748. * Gets the shadow projection scale against the optimal computed one.
  47749. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47750. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47751. */
  47752. get shadowOrthoScale(): number;
  47753. /**
  47754. * Sets the shadow projection scale against the optimal computed one.
  47755. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47756. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47757. */
  47758. set shadowOrthoScale(value: number);
  47759. /**
  47760. * Automatically compute the projection matrix to best fit (including all the casters)
  47761. * on each frame.
  47762. */
  47763. autoUpdateExtends: boolean;
  47764. /**
  47765. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  47766. * on each frame. autoUpdateExtends must be set to true for this to work
  47767. */
  47768. autoCalcShadowZBounds: boolean;
  47769. private _orthoLeft;
  47770. private _orthoRight;
  47771. private _orthoTop;
  47772. private _orthoBottom;
  47773. /**
  47774. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47775. * The directional light is emitted from everywhere in the given direction.
  47776. * It can cast shadows.
  47777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47778. * @param name The friendly name of the light
  47779. * @param direction The direction of the light
  47780. * @param scene The scene the light belongs to
  47781. */
  47782. constructor(name: string, direction: Vector3, scene: Scene);
  47783. /**
  47784. * Returns the string "DirectionalLight".
  47785. * @return The class name
  47786. */
  47787. getClassName(): string;
  47788. /**
  47789. * Returns the integer 1.
  47790. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47791. */
  47792. getTypeID(): number;
  47793. /**
  47794. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47795. * Returns the DirectionalLight Shadow projection matrix.
  47796. */
  47797. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47798. /**
  47799. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47800. * Returns the DirectionalLight Shadow projection matrix.
  47801. */
  47802. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47803. /**
  47804. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47805. * Returns the DirectionalLight Shadow projection matrix.
  47806. */
  47807. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47808. protected _buildUniformLayout(): void;
  47809. /**
  47810. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47811. * @param effect The effect to update
  47812. * @param lightIndex The index of the light in the effect to update
  47813. * @returns The directional light
  47814. */
  47815. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47816. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47817. /**
  47818. * Gets the minZ used for shadow according to both the scene and the light.
  47819. *
  47820. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47821. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47822. * @param activeCamera The camera we are returning the min for
  47823. * @returns the depth min z
  47824. */
  47825. getDepthMinZ(activeCamera: Camera): number;
  47826. /**
  47827. * Gets the maxZ used for shadow according to both the scene and the light.
  47828. *
  47829. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47830. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47831. * @param activeCamera The camera we are returning the max for
  47832. * @returns the depth max z
  47833. */
  47834. getDepthMaxZ(activeCamera: Camera): number;
  47835. /**
  47836. * Prepares the list of defines specific to the light type.
  47837. * @param defines the list of defines
  47838. * @param lightIndex defines the index of the light for the effect
  47839. */
  47840. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47841. }
  47842. }
  47843. declare module BABYLON {
  47844. /**
  47845. * Class containing static functions to help procedurally build meshes
  47846. */
  47847. export class HemisphereBuilder {
  47848. /**
  47849. * Creates a hemisphere mesh
  47850. * @param name defines the name of the mesh
  47851. * @param options defines the options used to create the mesh
  47852. * @param scene defines the hosting scene
  47853. * @returns the hemisphere mesh
  47854. */
  47855. static CreateHemisphere(name: string, options: {
  47856. segments?: number;
  47857. diameter?: number;
  47858. sideOrientation?: number;
  47859. }, scene: any): Mesh;
  47860. }
  47861. }
  47862. declare module BABYLON {
  47863. /**
  47864. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47865. * These values define a cone of light starting from the position, emitting toward the direction.
  47866. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47867. * and the exponent defines the speed of the decay of the light with distance (reach).
  47868. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47869. */
  47870. export class SpotLight extends ShadowLight {
  47871. private _angle;
  47872. private _innerAngle;
  47873. private _cosHalfAngle;
  47874. private _lightAngleScale;
  47875. private _lightAngleOffset;
  47876. /**
  47877. * Gets the cone angle of the spot light in Radians.
  47878. */
  47879. get angle(): number;
  47880. /**
  47881. * Sets the cone angle of the spot light in Radians.
  47882. */
  47883. set angle(value: number);
  47884. /**
  47885. * Only used in gltf falloff mode, this defines the angle where
  47886. * the directional falloff will start before cutting at angle which could be seen
  47887. * as outer angle.
  47888. */
  47889. get innerAngle(): number;
  47890. /**
  47891. * Only used in gltf falloff mode, this defines the angle where
  47892. * the directional falloff will start before cutting at angle which could be seen
  47893. * as outer angle.
  47894. */
  47895. set innerAngle(value: number);
  47896. private _shadowAngleScale;
  47897. /**
  47898. * Allows scaling the angle of the light for shadow generation only.
  47899. */
  47900. get shadowAngleScale(): number;
  47901. /**
  47902. * Allows scaling the angle of the light for shadow generation only.
  47903. */
  47904. set shadowAngleScale(value: number);
  47905. /**
  47906. * The light decay speed with the distance from the emission spot.
  47907. */
  47908. exponent: number;
  47909. private _projectionTextureMatrix;
  47910. /**
  47911. * Allows reading the projecton texture
  47912. */
  47913. get projectionTextureMatrix(): Matrix;
  47914. protected _projectionTextureLightNear: number;
  47915. /**
  47916. * Gets the near clip of the Spotlight for texture projection.
  47917. */
  47918. get projectionTextureLightNear(): number;
  47919. /**
  47920. * Sets the near clip of the Spotlight for texture projection.
  47921. */
  47922. set projectionTextureLightNear(value: number);
  47923. protected _projectionTextureLightFar: number;
  47924. /**
  47925. * Gets the far clip of the Spotlight for texture projection.
  47926. */
  47927. get projectionTextureLightFar(): number;
  47928. /**
  47929. * Sets the far clip of the Spotlight for texture projection.
  47930. */
  47931. set projectionTextureLightFar(value: number);
  47932. protected _projectionTextureUpDirection: Vector3;
  47933. /**
  47934. * Gets the Up vector of the Spotlight for texture projection.
  47935. */
  47936. get projectionTextureUpDirection(): Vector3;
  47937. /**
  47938. * Sets the Up vector of the Spotlight for texture projection.
  47939. */
  47940. set projectionTextureUpDirection(value: Vector3);
  47941. private _projectionTexture;
  47942. /**
  47943. * Gets the projection texture of the light.
  47944. */
  47945. get projectionTexture(): Nullable<BaseTexture>;
  47946. /**
  47947. * Sets the projection texture of the light.
  47948. */
  47949. set projectionTexture(value: Nullable<BaseTexture>);
  47950. private _projectionTextureViewLightDirty;
  47951. private _projectionTextureProjectionLightDirty;
  47952. private _projectionTextureDirty;
  47953. private _projectionTextureViewTargetVector;
  47954. private _projectionTextureViewLightMatrix;
  47955. private _projectionTextureProjectionLightMatrix;
  47956. private _projectionTextureScalingMatrix;
  47957. /**
  47958. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47959. * It can cast shadows.
  47960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47961. * @param name The light friendly name
  47962. * @param position The position of the spot light in the scene
  47963. * @param direction The direction of the light in the scene
  47964. * @param angle The cone angle of the light in Radians
  47965. * @param exponent The light decay speed with the distance from the emission spot
  47966. * @param scene The scene the lights belongs to
  47967. */
  47968. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47969. /**
  47970. * Returns the string "SpotLight".
  47971. * @returns the class name
  47972. */
  47973. getClassName(): string;
  47974. /**
  47975. * Returns the integer 2.
  47976. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47977. */
  47978. getTypeID(): number;
  47979. /**
  47980. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47981. */
  47982. protected _setDirection(value: Vector3): void;
  47983. /**
  47984. * Overrides the position setter to recompute the projection texture view light Matrix.
  47985. */
  47986. protected _setPosition(value: Vector3): void;
  47987. /**
  47988. * 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.
  47989. * Returns the SpotLight.
  47990. */
  47991. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47992. protected _computeProjectionTextureViewLightMatrix(): void;
  47993. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47994. /**
  47995. * Main function for light texture projection matrix computing.
  47996. */
  47997. protected _computeProjectionTextureMatrix(): void;
  47998. protected _buildUniformLayout(): void;
  47999. private _computeAngleValues;
  48000. /**
  48001. * Sets the passed Effect "effect" with the Light textures.
  48002. * @param effect The effect to update
  48003. * @param lightIndex The index of the light in the effect to update
  48004. * @returns The light
  48005. */
  48006. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48007. /**
  48008. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48009. * @param effect The effect to update
  48010. * @param lightIndex The index of the light in the effect to update
  48011. * @returns The spot light
  48012. */
  48013. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48014. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48015. /**
  48016. * Disposes the light and the associated resources.
  48017. */
  48018. dispose(): void;
  48019. /**
  48020. * Prepares the list of defines specific to the light type.
  48021. * @param defines the list of defines
  48022. * @param lightIndex defines the index of the light for the effect
  48023. */
  48024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48025. }
  48026. }
  48027. declare module BABYLON {
  48028. /**
  48029. * Gizmo that enables viewing a light
  48030. */
  48031. export class LightGizmo extends Gizmo {
  48032. private _lightMesh;
  48033. private _material;
  48034. private _cachedPosition;
  48035. private _cachedForward;
  48036. private _attachedMeshParent;
  48037. /**
  48038. * Creates a LightGizmo
  48039. * @param gizmoLayer The utility layer the gizmo will be added to
  48040. */
  48041. constructor(gizmoLayer?: UtilityLayerRenderer);
  48042. private _light;
  48043. /**
  48044. * The light that the gizmo is attached to
  48045. */
  48046. set light(light: Nullable<Light>);
  48047. get light(): Nullable<Light>;
  48048. /**
  48049. * Gets the material used to render the light gizmo
  48050. */
  48051. get material(): StandardMaterial;
  48052. /**
  48053. * @hidden
  48054. * Updates the gizmo to match the attached mesh's position/rotation
  48055. */
  48056. protected _update(): void;
  48057. private static _Scale;
  48058. /**
  48059. * Creates the lines for a light mesh
  48060. */
  48061. private static _CreateLightLines;
  48062. /**
  48063. * Disposes of the light gizmo
  48064. */
  48065. dispose(): void;
  48066. private static _CreateHemisphericLightMesh;
  48067. private static _CreatePointLightMesh;
  48068. private static _CreateSpotLightMesh;
  48069. private static _CreateDirectionalLightMesh;
  48070. }
  48071. }
  48072. declare module BABYLON {
  48073. /** @hidden */
  48074. export var backgroundFragmentDeclaration: {
  48075. name: string;
  48076. shader: string;
  48077. };
  48078. }
  48079. declare module BABYLON {
  48080. /** @hidden */
  48081. export var backgroundUboDeclaration: {
  48082. name: string;
  48083. shader: string;
  48084. };
  48085. }
  48086. declare module BABYLON {
  48087. /** @hidden */
  48088. export var backgroundPixelShader: {
  48089. name: string;
  48090. shader: string;
  48091. };
  48092. }
  48093. declare module BABYLON {
  48094. /** @hidden */
  48095. export var backgroundVertexDeclaration: {
  48096. name: string;
  48097. shader: string;
  48098. };
  48099. }
  48100. declare module BABYLON {
  48101. /** @hidden */
  48102. export var backgroundVertexShader: {
  48103. name: string;
  48104. shader: string;
  48105. };
  48106. }
  48107. declare module BABYLON {
  48108. /**
  48109. * Background material used to create an efficient environement around your scene.
  48110. */
  48111. export class BackgroundMaterial extends PushMaterial {
  48112. /**
  48113. * Standard reflectance value at parallel view angle.
  48114. */
  48115. static StandardReflectance0: number;
  48116. /**
  48117. * Standard reflectance value at grazing angle.
  48118. */
  48119. static StandardReflectance90: number;
  48120. protected _primaryColor: Color3;
  48121. /**
  48122. * Key light Color (multiply against the environement texture)
  48123. */
  48124. primaryColor: Color3;
  48125. protected __perceptualColor: Nullable<Color3>;
  48126. /**
  48127. * Experimental Internal Use Only.
  48128. *
  48129. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48130. * This acts as a helper to set the primary color to a more "human friendly" value.
  48131. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48132. * output color as close as possible from the chosen value.
  48133. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48134. * part of lighting setup.)
  48135. */
  48136. get _perceptualColor(): Nullable<Color3>;
  48137. set _perceptualColor(value: Nullable<Color3>);
  48138. protected _primaryColorShadowLevel: float;
  48139. /**
  48140. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48141. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48142. */
  48143. get primaryColorShadowLevel(): float;
  48144. set primaryColorShadowLevel(value: float);
  48145. protected _primaryColorHighlightLevel: float;
  48146. /**
  48147. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48148. * The primary color is used at the level chosen to define what the white area would look.
  48149. */
  48150. get primaryColorHighlightLevel(): float;
  48151. set primaryColorHighlightLevel(value: float);
  48152. protected _reflectionTexture: Nullable<BaseTexture>;
  48153. /**
  48154. * Reflection Texture used in the material.
  48155. * Should be author in a specific way for the best result (refer to the documentation).
  48156. */
  48157. reflectionTexture: Nullable<BaseTexture>;
  48158. protected _reflectionBlur: float;
  48159. /**
  48160. * Reflection Texture level of blur.
  48161. *
  48162. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48163. * texture twice.
  48164. */
  48165. reflectionBlur: float;
  48166. protected _diffuseTexture: Nullable<BaseTexture>;
  48167. /**
  48168. * Diffuse Texture used in the material.
  48169. * Should be author in a specific way for the best result (refer to the documentation).
  48170. */
  48171. diffuseTexture: Nullable<BaseTexture>;
  48172. protected _shadowLights: Nullable<IShadowLight[]>;
  48173. /**
  48174. * Specify the list of lights casting shadow on the material.
  48175. * All scene shadow lights will be included if null.
  48176. */
  48177. shadowLights: Nullable<IShadowLight[]>;
  48178. protected _shadowLevel: float;
  48179. /**
  48180. * Helps adjusting the shadow to a softer level if required.
  48181. * 0 means black shadows and 1 means no shadows.
  48182. */
  48183. shadowLevel: float;
  48184. protected _sceneCenter: Vector3;
  48185. /**
  48186. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48187. * It is usually zero but might be interesting to modify according to your setup.
  48188. */
  48189. sceneCenter: Vector3;
  48190. protected _opacityFresnel: boolean;
  48191. /**
  48192. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48193. * This helps ensuring a nice transition when the camera goes under the ground.
  48194. */
  48195. opacityFresnel: boolean;
  48196. protected _reflectionFresnel: boolean;
  48197. /**
  48198. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48199. * This helps adding a mirror texture on the ground.
  48200. */
  48201. reflectionFresnel: boolean;
  48202. protected _reflectionFalloffDistance: number;
  48203. /**
  48204. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48205. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48206. */
  48207. reflectionFalloffDistance: number;
  48208. protected _reflectionAmount: number;
  48209. /**
  48210. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48211. */
  48212. reflectionAmount: number;
  48213. protected _reflectionReflectance0: number;
  48214. /**
  48215. * This specifies the weight of the reflection at grazing angle.
  48216. */
  48217. reflectionReflectance0: number;
  48218. protected _reflectionReflectance90: number;
  48219. /**
  48220. * This specifies the weight of the reflection at a perpendicular point of view.
  48221. */
  48222. reflectionReflectance90: number;
  48223. /**
  48224. * Sets the reflection reflectance fresnel values according to the default standard
  48225. * empirically know to work well :-)
  48226. */
  48227. set reflectionStandardFresnelWeight(value: number);
  48228. protected _useRGBColor: boolean;
  48229. /**
  48230. * Helps to directly use the maps channels instead of their level.
  48231. */
  48232. useRGBColor: boolean;
  48233. protected _enableNoise: boolean;
  48234. /**
  48235. * This helps reducing the banding effect that could occur on the background.
  48236. */
  48237. enableNoise: boolean;
  48238. /**
  48239. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48240. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48241. * Recommended to be keep at 1.0 except for special cases.
  48242. */
  48243. get fovMultiplier(): number;
  48244. set fovMultiplier(value: number);
  48245. private _fovMultiplier;
  48246. /**
  48247. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48248. */
  48249. useEquirectangularFOV: boolean;
  48250. private _maxSimultaneousLights;
  48251. /**
  48252. * Number of Simultaneous lights allowed on the material.
  48253. */
  48254. maxSimultaneousLights: int;
  48255. /**
  48256. * Default configuration related to image processing available in the Background Material.
  48257. */
  48258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48259. /**
  48260. * Keep track of the image processing observer to allow dispose and replace.
  48261. */
  48262. private _imageProcessingObserver;
  48263. /**
  48264. * Attaches a new image processing configuration to the PBR Material.
  48265. * @param configuration (if null the scene configuration will be use)
  48266. */
  48267. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48268. /**
  48269. * Gets the image processing configuration used either in this material.
  48270. */
  48271. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48272. /**
  48273. * Sets the Default image processing configuration used either in the this material.
  48274. *
  48275. * If sets to null, the scene one is in use.
  48276. */
  48277. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48278. /**
  48279. * Gets wether the color curves effect is enabled.
  48280. */
  48281. get cameraColorCurvesEnabled(): boolean;
  48282. /**
  48283. * Sets wether the color curves effect is enabled.
  48284. */
  48285. set cameraColorCurvesEnabled(value: boolean);
  48286. /**
  48287. * Gets wether the color grading effect is enabled.
  48288. */
  48289. get cameraColorGradingEnabled(): boolean;
  48290. /**
  48291. * Gets wether the color grading effect is enabled.
  48292. */
  48293. set cameraColorGradingEnabled(value: boolean);
  48294. /**
  48295. * Gets wether tonemapping is enabled or not.
  48296. */
  48297. get cameraToneMappingEnabled(): boolean;
  48298. /**
  48299. * Sets wether tonemapping is enabled or not
  48300. */
  48301. set cameraToneMappingEnabled(value: boolean);
  48302. /**
  48303. * The camera exposure used on this material.
  48304. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48305. * This corresponds to a photographic exposure.
  48306. */
  48307. get cameraExposure(): float;
  48308. /**
  48309. * The camera exposure used on this material.
  48310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48311. * This corresponds to a photographic exposure.
  48312. */
  48313. set cameraExposure(value: float);
  48314. /**
  48315. * Gets The camera contrast used on this material.
  48316. */
  48317. get cameraContrast(): float;
  48318. /**
  48319. * Sets The camera contrast used on this material.
  48320. */
  48321. set cameraContrast(value: float);
  48322. /**
  48323. * Gets the Color Grading 2D Lookup Texture.
  48324. */
  48325. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48326. /**
  48327. * Sets the Color Grading 2D Lookup Texture.
  48328. */
  48329. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48330. /**
  48331. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48332. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48333. * 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;
  48334. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48335. */
  48336. get cameraColorCurves(): Nullable<ColorCurves>;
  48337. /**
  48338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48340. * 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;
  48341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48342. */
  48343. set cameraColorCurves(value: Nullable<ColorCurves>);
  48344. /**
  48345. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48346. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48347. */
  48348. switchToBGR: boolean;
  48349. private _renderTargets;
  48350. private _reflectionControls;
  48351. private _white;
  48352. private _primaryShadowColor;
  48353. private _primaryHighlightColor;
  48354. /**
  48355. * Instantiates a Background Material in the given scene
  48356. * @param name The friendly name of the material
  48357. * @param scene The scene to add the material to
  48358. */
  48359. constructor(name: string, scene: Scene);
  48360. /**
  48361. * Gets a boolean indicating that current material needs to register RTT
  48362. */
  48363. get hasRenderTargetTextures(): boolean;
  48364. /**
  48365. * The entire material has been created in order to prevent overdraw.
  48366. * @returns false
  48367. */
  48368. needAlphaTesting(): boolean;
  48369. /**
  48370. * The entire material has been created in order to prevent overdraw.
  48371. * @returns true if blending is enable
  48372. */
  48373. needAlphaBlending(): boolean;
  48374. /**
  48375. * Checks wether the material is ready to be rendered for a given mesh.
  48376. * @param mesh The mesh to render
  48377. * @param subMesh The submesh to check against
  48378. * @param useInstances Specify wether or not the material is used with instances
  48379. * @returns true if all the dependencies are ready (Textures, Effects...)
  48380. */
  48381. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48382. /**
  48383. * Compute the primary color according to the chosen perceptual color.
  48384. */
  48385. private _computePrimaryColorFromPerceptualColor;
  48386. /**
  48387. * Compute the highlights and shadow colors according to their chosen levels.
  48388. */
  48389. private _computePrimaryColors;
  48390. /**
  48391. * Build the uniform buffer used in the material.
  48392. */
  48393. buildUniformLayout(): void;
  48394. /**
  48395. * Unbind the material.
  48396. */
  48397. unbind(): void;
  48398. /**
  48399. * Bind only the world matrix to the material.
  48400. * @param world The world matrix to bind.
  48401. */
  48402. bindOnlyWorldMatrix(world: Matrix): void;
  48403. /**
  48404. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48405. * @param world The world matrix to bind.
  48406. * @param subMesh The submesh to bind for.
  48407. */
  48408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48409. /**
  48410. * Checks to see if a texture is used in the material.
  48411. * @param texture - Base texture to use.
  48412. * @returns - Boolean specifying if a texture is used in the material.
  48413. */
  48414. hasTexture(texture: BaseTexture): boolean;
  48415. /**
  48416. * Dispose the material.
  48417. * @param forceDisposeEffect Force disposal of the associated effect.
  48418. * @param forceDisposeTextures Force disposal of the associated textures.
  48419. */
  48420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48421. /**
  48422. * Clones the material.
  48423. * @param name The cloned name.
  48424. * @returns The cloned material.
  48425. */
  48426. clone(name: string): BackgroundMaterial;
  48427. /**
  48428. * Serializes the current material to its JSON representation.
  48429. * @returns The JSON representation.
  48430. */
  48431. serialize(): any;
  48432. /**
  48433. * Gets the class name of the material
  48434. * @returns "BackgroundMaterial"
  48435. */
  48436. getClassName(): string;
  48437. /**
  48438. * Parse a JSON input to create back a background material.
  48439. * @param source The JSON data to parse
  48440. * @param scene The scene to create the parsed material in
  48441. * @param rootUrl The root url of the assets the material depends upon
  48442. * @returns the instantiated BackgroundMaterial.
  48443. */
  48444. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Represents the different options available during the creation of
  48450. * a Environment helper.
  48451. *
  48452. * This can control the default ground, skybox and image processing setup of your scene.
  48453. */
  48454. export interface IEnvironmentHelperOptions {
  48455. /**
  48456. * Specifies wether or not to create a ground.
  48457. * True by default.
  48458. */
  48459. createGround: boolean;
  48460. /**
  48461. * Specifies the ground size.
  48462. * 15 by default.
  48463. */
  48464. groundSize: number;
  48465. /**
  48466. * The texture used on the ground for the main color.
  48467. * Comes from the BabylonJS CDN by default.
  48468. *
  48469. * Remarks: Can be either a texture or a url.
  48470. */
  48471. groundTexture: string | BaseTexture;
  48472. /**
  48473. * The color mixed in the ground texture by default.
  48474. * BabylonJS clearColor by default.
  48475. */
  48476. groundColor: Color3;
  48477. /**
  48478. * Specifies the ground opacity.
  48479. * 1 by default.
  48480. */
  48481. groundOpacity: number;
  48482. /**
  48483. * Enables the ground to receive shadows.
  48484. * True by default.
  48485. */
  48486. enableGroundShadow: boolean;
  48487. /**
  48488. * Helps preventing the shadow to be fully black on the ground.
  48489. * 0.5 by default.
  48490. */
  48491. groundShadowLevel: number;
  48492. /**
  48493. * Creates a mirror texture attach to the ground.
  48494. * false by default.
  48495. */
  48496. enableGroundMirror: boolean;
  48497. /**
  48498. * Specifies the ground mirror size ratio.
  48499. * 0.3 by default as the default kernel is 64.
  48500. */
  48501. groundMirrorSizeRatio: number;
  48502. /**
  48503. * Specifies the ground mirror blur kernel size.
  48504. * 64 by default.
  48505. */
  48506. groundMirrorBlurKernel: number;
  48507. /**
  48508. * Specifies the ground mirror visibility amount.
  48509. * 1 by default
  48510. */
  48511. groundMirrorAmount: number;
  48512. /**
  48513. * Specifies the ground mirror reflectance weight.
  48514. * This uses the standard weight of the background material to setup the fresnel effect
  48515. * of the mirror.
  48516. * 1 by default.
  48517. */
  48518. groundMirrorFresnelWeight: number;
  48519. /**
  48520. * Specifies the ground mirror Falloff distance.
  48521. * This can helps reducing the size of the reflection.
  48522. * 0 by Default.
  48523. */
  48524. groundMirrorFallOffDistance: number;
  48525. /**
  48526. * Specifies the ground mirror texture type.
  48527. * Unsigned Int by Default.
  48528. */
  48529. groundMirrorTextureType: number;
  48530. /**
  48531. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48532. * the shown objects.
  48533. */
  48534. groundYBias: number;
  48535. /**
  48536. * Specifies wether or not to create a skybox.
  48537. * True by default.
  48538. */
  48539. createSkybox: boolean;
  48540. /**
  48541. * Specifies the skybox size.
  48542. * 20 by default.
  48543. */
  48544. skyboxSize: number;
  48545. /**
  48546. * The texture used on the skybox for the main color.
  48547. * Comes from the BabylonJS CDN by default.
  48548. *
  48549. * Remarks: Can be either a texture or a url.
  48550. */
  48551. skyboxTexture: string | BaseTexture;
  48552. /**
  48553. * The color mixed in the skybox texture by default.
  48554. * BabylonJS clearColor by default.
  48555. */
  48556. skyboxColor: Color3;
  48557. /**
  48558. * The background rotation around the Y axis of the scene.
  48559. * This helps aligning the key lights of your scene with the background.
  48560. * 0 by default.
  48561. */
  48562. backgroundYRotation: number;
  48563. /**
  48564. * Compute automatically the size of the elements to best fit with the scene.
  48565. */
  48566. sizeAuto: boolean;
  48567. /**
  48568. * Default position of the rootMesh if autoSize is not true.
  48569. */
  48570. rootPosition: Vector3;
  48571. /**
  48572. * Sets up the image processing in the scene.
  48573. * true by default.
  48574. */
  48575. setupImageProcessing: boolean;
  48576. /**
  48577. * The texture used as your environment texture in the scene.
  48578. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48579. *
  48580. * Remarks: Can be either a texture or a url.
  48581. */
  48582. environmentTexture: string | BaseTexture;
  48583. /**
  48584. * The value of the exposure to apply to the scene.
  48585. * 0.6 by default if setupImageProcessing is true.
  48586. */
  48587. cameraExposure: number;
  48588. /**
  48589. * The value of the contrast to apply to the scene.
  48590. * 1.6 by default if setupImageProcessing is true.
  48591. */
  48592. cameraContrast: number;
  48593. /**
  48594. * Specifies wether or not tonemapping should be enabled in the scene.
  48595. * true by default if setupImageProcessing is true.
  48596. */
  48597. toneMappingEnabled: boolean;
  48598. }
  48599. /**
  48600. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48601. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48602. * It also helps with the default setup of your imageProcessing configuration.
  48603. */
  48604. export class EnvironmentHelper {
  48605. /**
  48606. * Default ground texture URL.
  48607. */
  48608. private static _groundTextureCDNUrl;
  48609. /**
  48610. * Default skybox texture URL.
  48611. */
  48612. private static _skyboxTextureCDNUrl;
  48613. /**
  48614. * Default environment texture URL.
  48615. */
  48616. private static _environmentTextureCDNUrl;
  48617. /**
  48618. * Creates the default options for the helper.
  48619. */
  48620. private static _getDefaultOptions;
  48621. private _rootMesh;
  48622. /**
  48623. * Gets the root mesh created by the helper.
  48624. */
  48625. get rootMesh(): Mesh;
  48626. private _skybox;
  48627. /**
  48628. * Gets the skybox created by the helper.
  48629. */
  48630. get skybox(): Nullable<Mesh>;
  48631. private _skyboxTexture;
  48632. /**
  48633. * Gets the skybox texture created by the helper.
  48634. */
  48635. get skyboxTexture(): Nullable<BaseTexture>;
  48636. private _skyboxMaterial;
  48637. /**
  48638. * Gets the skybox material created by the helper.
  48639. */
  48640. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48641. private _ground;
  48642. /**
  48643. * Gets the ground mesh created by the helper.
  48644. */
  48645. get ground(): Nullable<Mesh>;
  48646. private _groundTexture;
  48647. /**
  48648. * Gets the ground texture created by the helper.
  48649. */
  48650. get groundTexture(): Nullable<BaseTexture>;
  48651. private _groundMirror;
  48652. /**
  48653. * Gets the ground mirror created by the helper.
  48654. */
  48655. get groundMirror(): Nullable<MirrorTexture>;
  48656. /**
  48657. * Gets the ground mirror render list to helps pushing the meshes
  48658. * you wish in the ground reflection.
  48659. */
  48660. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48661. private _groundMaterial;
  48662. /**
  48663. * Gets the ground material created by the helper.
  48664. */
  48665. get groundMaterial(): Nullable<BackgroundMaterial>;
  48666. /**
  48667. * Stores the creation options.
  48668. */
  48669. private readonly _scene;
  48670. private _options;
  48671. /**
  48672. * This observable will be notified with any error during the creation of the environment,
  48673. * mainly texture creation errors.
  48674. */
  48675. onErrorObservable: Observable<{
  48676. message?: string;
  48677. exception?: any;
  48678. }>;
  48679. /**
  48680. * constructor
  48681. * @param options Defines the options we want to customize the helper
  48682. * @param scene The scene to add the material to
  48683. */
  48684. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48685. /**
  48686. * Updates the background according to the new options
  48687. * @param options
  48688. */
  48689. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48690. /**
  48691. * Sets the primary color of all the available elements.
  48692. * @param color the main color to affect to the ground and the background
  48693. */
  48694. setMainColor(color: Color3): void;
  48695. /**
  48696. * Setup the image processing according to the specified options.
  48697. */
  48698. private _setupImageProcessing;
  48699. /**
  48700. * Setup the environment texture according to the specified options.
  48701. */
  48702. private _setupEnvironmentTexture;
  48703. /**
  48704. * Setup the background according to the specified options.
  48705. */
  48706. private _setupBackground;
  48707. /**
  48708. * Get the scene sizes according to the setup.
  48709. */
  48710. private _getSceneSize;
  48711. /**
  48712. * Setup the ground according to the specified options.
  48713. */
  48714. private _setupGround;
  48715. /**
  48716. * Setup the ground material according to the specified options.
  48717. */
  48718. private _setupGroundMaterial;
  48719. /**
  48720. * Setup the ground diffuse texture according to the specified options.
  48721. */
  48722. private _setupGroundDiffuseTexture;
  48723. /**
  48724. * Setup the ground mirror texture according to the specified options.
  48725. */
  48726. private _setupGroundMirrorTexture;
  48727. /**
  48728. * Setup the ground to receive the mirror texture.
  48729. */
  48730. private _setupMirrorInGroundMaterial;
  48731. /**
  48732. * Setup the skybox according to the specified options.
  48733. */
  48734. private _setupSkybox;
  48735. /**
  48736. * Setup the skybox material according to the specified options.
  48737. */
  48738. private _setupSkyboxMaterial;
  48739. /**
  48740. * Setup the skybox reflection texture according to the specified options.
  48741. */
  48742. private _setupSkyboxReflectionTexture;
  48743. private _errorHandler;
  48744. /**
  48745. * Dispose all the elements created by the Helper.
  48746. */
  48747. dispose(): void;
  48748. }
  48749. }
  48750. declare module BABYLON {
  48751. /**
  48752. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48753. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48754. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48755. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48756. */
  48757. export class PhotoDome extends TransformNode {
  48758. /**
  48759. * Define the image as a Monoscopic panoramic 360 image.
  48760. */
  48761. static readonly MODE_MONOSCOPIC: number;
  48762. /**
  48763. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48764. */
  48765. static readonly MODE_TOPBOTTOM: number;
  48766. /**
  48767. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48768. */
  48769. static readonly MODE_SIDEBYSIDE: number;
  48770. private _useDirectMapping;
  48771. /**
  48772. * The texture being displayed on the sphere
  48773. */
  48774. protected _photoTexture: Texture;
  48775. /**
  48776. * Gets or sets the texture being displayed on the sphere
  48777. */
  48778. get photoTexture(): Texture;
  48779. set photoTexture(value: Texture);
  48780. /**
  48781. * Observable raised when an error occured while loading the 360 image
  48782. */
  48783. onLoadErrorObservable: Observable<string>;
  48784. /**
  48785. * The skybox material
  48786. */
  48787. protected _material: BackgroundMaterial;
  48788. /**
  48789. * The surface used for the skybox
  48790. */
  48791. protected _mesh: Mesh;
  48792. /**
  48793. * Gets the mesh used for the skybox.
  48794. */
  48795. get mesh(): Mesh;
  48796. /**
  48797. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48798. * Also see the options.resolution property.
  48799. */
  48800. get fovMultiplier(): number;
  48801. set fovMultiplier(value: number);
  48802. private _imageMode;
  48803. /**
  48804. * Gets or set the current video mode for the video. It can be:
  48805. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48806. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48807. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48808. */
  48809. get imageMode(): number;
  48810. set imageMode(value: number);
  48811. /**
  48812. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48813. * @param name Element's name, child elements will append suffixes for their own names.
  48814. * @param urlsOfPhoto defines the url of the photo to display
  48815. * @param options defines an object containing optional or exposed sub element properties
  48816. * @param onError defines a callback called when an error occured while loading the texture
  48817. */
  48818. constructor(name: string, urlOfPhoto: string, options: {
  48819. resolution?: number;
  48820. size?: number;
  48821. useDirectMapping?: boolean;
  48822. faceForward?: boolean;
  48823. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48824. private _onBeforeCameraRenderObserver;
  48825. private _changeImageMode;
  48826. /**
  48827. * Releases resources associated with this node.
  48828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48830. */
  48831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48832. }
  48833. }
  48834. declare module BABYLON {
  48835. /**
  48836. * Class used to host RGBD texture specific utilities
  48837. */
  48838. export class RGBDTextureTools {
  48839. /**
  48840. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48841. * @param texture the texture to expand.
  48842. */
  48843. static ExpandRGBDTexture(texture: Texture): void;
  48844. }
  48845. }
  48846. declare module BABYLON {
  48847. /**
  48848. * Class used to host texture specific utilities
  48849. */
  48850. export class BRDFTextureTools {
  48851. /**
  48852. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48853. * @param scene defines the hosting scene
  48854. * @returns the environment BRDF texture
  48855. */
  48856. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48857. private static _environmentBRDFBase64Texture;
  48858. }
  48859. }
  48860. declare module BABYLON {
  48861. /**
  48862. * @hidden
  48863. */
  48864. export interface IMaterialClearCoatDefines {
  48865. CLEARCOAT: boolean;
  48866. CLEARCOAT_DEFAULTIOR: boolean;
  48867. CLEARCOAT_TEXTURE: boolean;
  48868. CLEARCOAT_TEXTUREDIRECTUV: number;
  48869. CLEARCOAT_BUMP: boolean;
  48870. CLEARCOAT_BUMPDIRECTUV: number;
  48871. CLEARCOAT_TINT: boolean;
  48872. CLEARCOAT_TINT_TEXTURE: boolean;
  48873. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48874. /** @hidden */
  48875. _areTexturesDirty: boolean;
  48876. }
  48877. /**
  48878. * Define the code related to the clear coat parameters of the pbr material.
  48879. */
  48880. export class PBRClearCoatConfiguration {
  48881. /**
  48882. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48883. * The default fits with a polyurethane material.
  48884. */
  48885. private static readonly _DefaultIndexOfRefraction;
  48886. private _isEnabled;
  48887. /**
  48888. * Defines if the clear coat is enabled in the material.
  48889. */
  48890. isEnabled: boolean;
  48891. /**
  48892. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48893. */
  48894. intensity: number;
  48895. /**
  48896. * Defines the clear coat layer roughness.
  48897. */
  48898. roughness: number;
  48899. private _indexOfRefraction;
  48900. /**
  48901. * Defines the index of refraction of the clear coat.
  48902. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48903. * The default fits with a polyurethane material.
  48904. * Changing the default value is more performance intensive.
  48905. */
  48906. indexOfRefraction: number;
  48907. private _texture;
  48908. /**
  48909. * Stores the clear coat values in a texture.
  48910. */
  48911. texture: Nullable<BaseTexture>;
  48912. private _bumpTexture;
  48913. /**
  48914. * Define the clear coat specific bump texture.
  48915. */
  48916. bumpTexture: Nullable<BaseTexture>;
  48917. private _isTintEnabled;
  48918. /**
  48919. * Defines if the clear coat tint is enabled in the material.
  48920. */
  48921. isTintEnabled: boolean;
  48922. /**
  48923. * Defines the clear coat tint of the material.
  48924. * This is only use if tint is enabled
  48925. */
  48926. tintColor: Color3;
  48927. /**
  48928. * Defines the distance at which the tint color should be found in the
  48929. * clear coat media.
  48930. * This is only use if tint is enabled
  48931. */
  48932. tintColorAtDistance: number;
  48933. /**
  48934. * Defines the clear coat layer thickness.
  48935. * This is only use if tint is enabled
  48936. */
  48937. tintThickness: number;
  48938. private _tintTexture;
  48939. /**
  48940. * Stores the clear tint values in a texture.
  48941. * rgb is tint
  48942. * a is a thickness factor
  48943. */
  48944. tintTexture: Nullable<BaseTexture>;
  48945. /** @hidden */
  48946. private _internalMarkAllSubMeshesAsTexturesDirty;
  48947. /** @hidden */
  48948. _markAllSubMeshesAsTexturesDirty(): void;
  48949. /**
  48950. * Instantiate a new istance of clear coat configuration.
  48951. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48952. */
  48953. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48954. /**
  48955. * Gets wehter the submesh is ready to be used or not.
  48956. * @param defines the list of "defines" to update.
  48957. * @param scene defines the scene the material belongs to.
  48958. * @param engine defines the engine the material belongs to.
  48959. * @param disableBumpMap defines wether the material disables bump or not.
  48960. * @returns - boolean indicating that the submesh is ready or not.
  48961. */
  48962. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48963. /**
  48964. * Checks to see if a texture is used in the material.
  48965. * @param defines the list of "defines" to update.
  48966. * @param scene defines the scene to the material belongs to.
  48967. */
  48968. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48969. /**
  48970. * Binds the material data.
  48971. * @param uniformBuffer defines the Uniform buffer to fill in.
  48972. * @param scene defines the scene the material belongs to.
  48973. * @param engine defines the engine the material belongs to.
  48974. * @param disableBumpMap defines wether the material disables bump or not.
  48975. * @param isFrozen defines wether the material is frozen or not.
  48976. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48977. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48978. */
  48979. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48980. /**
  48981. * Checks to see if a texture is used in the material.
  48982. * @param texture - Base texture to use.
  48983. * @returns - Boolean specifying if a texture is used in the material.
  48984. */
  48985. hasTexture(texture: BaseTexture): boolean;
  48986. /**
  48987. * Returns an array of the actively used textures.
  48988. * @param activeTextures Array of BaseTextures
  48989. */
  48990. getActiveTextures(activeTextures: BaseTexture[]): void;
  48991. /**
  48992. * Returns the animatable textures.
  48993. * @param animatables Array of animatable textures.
  48994. */
  48995. getAnimatables(animatables: IAnimatable[]): void;
  48996. /**
  48997. * Disposes the resources of the material.
  48998. * @param forceDisposeTextures - Forces the disposal of all textures.
  48999. */
  49000. dispose(forceDisposeTextures?: boolean): void;
  49001. /**
  49002. * Get the current class name of the texture useful for serialization or dynamic coding.
  49003. * @returns "PBRClearCoatConfiguration"
  49004. */
  49005. getClassName(): string;
  49006. /**
  49007. * Add fallbacks to the effect fallbacks list.
  49008. * @param defines defines the Base texture to use.
  49009. * @param fallbacks defines the current fallback list.
  49010. * @param currentRank defines the current fallback rank.
  49011. * @returns the new fallback rank.
  49012. */
  49013. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49014. /**
  49015. * Add the required uniforms to the current list.
  49016. * @param uniforms defines the current uniform list.
  49017. */
  49018. static AddUniforms(uniforms: string[]): void;
  49019. /**
  49020. * Add the required samplers to the current list.
  49021. * @param samplers defines the current sampler list.
  49022. */
  49023. static AddSamplers(samplers: string[]): void;
  49024. /**
  49025. * Add the required uniforms to the current buffer.
  49026. * @param uniformBuffer defines the current uniform buffer.
  49027. */
  49028. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49029. /**
  49030. * Makes a duplicate of the current configuration into another one.
  49031. * @param clearCoatConfiguration define the config where to copy the info
  49032. */
  49033. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49034. /**
  49035. * Serializes this clear coat configuration.
  49036. * @returns - An object with the serialized config.
  49037. */
  49038. serialize(): any;
  49039. /**
  49040. * Parses a anisotropy Configuration from a serialized object.
  49041. * @param source - Serialized object.
  49042. * @param scene Defines the scene we are parsing for
  49043. * @param rootUrl Defines the rootUrl to load from
  49044. */
  49045. parse(source: any, scene: Scene, rootUrl: string): void;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /**
  49050. * @hidden
  49051. */
  49052. export interface IMaterialAnisotropicDefines {
  49053. ANISOTROPIC: boolean;
  49054. ANISOTROPIC_TEXTURE: boolean;
  49055. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49056. MAINUV1: boolean;
  49057. _areTexturesDirty: boolean;
  49058. _needUVs: boolean;
  49059. }
  49060. /**
  49061. * Define the code related to the anisotropic parameters of the pbr material.
  49062. */
  49063. export class PBRAnisotropicConfiguration {
  49064. private _isEnabled;
  49065. /**
  49066. * Defines if the anisotropy is enabled in the material.
  49067. */
  49068. isEnabled: boolean;
  49069. /**
  49070. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49071. */
  49072. intensity: number;
  49073. /**
  49074. * Defines if the effect is along the tangents, bitangents or in between.
  49075. * By default, the effect is "strectching" the highlights along the tangents.
  49076. */
  49077. direction: Vector2;
  49078. private _texture;
  49079. /**
  49080. * Stores the anisotropy values in a texture.
  49081. * rg is direction (like normal from -1 to 1)
  49082. * b is a intensity
  49083. */
  49084. texture: Nullable<BaseTexture>;
  49085. /** @hidden */
  49086. private _internalMarkAllSubMeshesAsTexturesDirty;
  49087. /** @hidden */
  49088. _markAllSubMeshesAsTexturesDirty(): void;
  49089. /**
  49090. * Instantiate a new istance of anisotropy configuration.
  49091. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49092. */
  49093. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49094. /**
  49095. * Specifies that the submesh is ready to be used.
  49096. * @param defines the list of "defines" to update.
  49097. * @param scene defines the scene the material belongs to.
  49098. * @returns - boolean indicating that the submesh is ready or not.
  49099. */
  49100. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49101. /**
  49102. * Checks to see if a texture is used in the material.
  49103. * @param defines the list of "defines" to update.
  49104. * @param mesh the mesh we are preparing the defines for.
  49105. * @param scene defines the scene the material belongs to.
  49106. */
  49107. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49108. /**
  49109. * Binds the material data.
  49110. * @param uniformBuffer defines the Uniform buffer to fill in.
  49111. * @param scene defines the scene the material belongs to.
  49112. * @param isFrozen defines wether the material is frozen or not.
  49113. */
  49114. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49115. /**
  49116. * Checks to see if a texture is used in the material.
  49117. * @param texture - Base texture to use.
  49118. * @returns - Boolean specifying if a texture is used in the material.
  49119. */
  49120. hasTexture(texture: BaseTexture): boolean;
  49121. /**
  49122. * Returns an array of the actively used textures.
  49123. * @param activeTextures Array of BaseTextures
  49124. */
  49125. getActiveTextures(activeTextures: BaseTexture[]): void;
  49126. /**
  49127. * Returns the animatable textures.
  49128. * @param animatables Array of animatable textures.
  49129. */
  49130. getAnimatables(animatables: IAnimatable[]): void;
  49131. /**
  49132. * Disposes the resources of the material.
  49133. * @param forceDisposeTextures - Forces the disposal of all textures.
  49134. */
  49135. dispose(forceDisposeTextures?: boolean): void;
  49136. /**
  49137. * Get the current class name of the texture useful for serialization or dynamic coding.
  49138. * @returns "PBRAnisotropicConfiguration"
  49139. */
  49140. getClassName(): string;
  49141. /**
  49142. * Add fallbacks to the effect fallbacks list.
  49143. * @param defines defines the Base texture to use.
  49144. * @param fallbacks defines the current fallback list.
  49145. * @param currentRank defines the current fallback rank.
  49146. * @returns the new fallback rank.
  49147. */
  49148. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49149. /**
  49150. * Add the required uniforms to the current list.
  49151. * @param uniforms defines the current uniform list.
  49152. */
  49153. static AddUniforms(uniforms: string[]): void;
  49154. /**
  49155. * Add the required uniforms to the current buffer.
  49156. * @param uniformBuffer defines the current uniform buffer.
  49157. */
  49158. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49159. /**
  49160. * Add the required samplers to the current list.
  49161. * @param samplers defines the current sampler list.
  49162. */
  49163. static AddSamplers(samplers: string[]): void;
  49164. /**
  49165. * Makes a duplicate of the current configuration into another one.
  49166. * @param anisotropicConfiguration define the config where to copy the info
  49167. */
  49168. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49169. /**
  49170. * Serializes this anisotropy configuration.
  49171. * @returns - An object with the serialized config.
  49172. */
  49173. serialize(): any;
  49174. /**
  49175. * Parses a anisotropy Configuration from a serialized object.
  49176. * @param source - Serialized object.
  49177. * @param scene Defines the scene we are parsing for
  49178. * @param rootUrl Defines the rootUrl to load from
  49179. */
  49180. parse(source: any, scene: Scene, rootUrl: string): void;
  49181. }
  49182. }
  49183. declare module BABYLON {
  49184. /**
  49185. * @hidden
  49186. */
  49187. export interface IMaterialBRDFDefines {
  49188. BRDF_V_HEIGHT_CORRELATED: boolean;
  49189. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49190. SPHERICAL_HARMONICS: boolean;
  49191. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49192. /** @hidden */
  49193. _areMiscDirty: boolean;
  49194. }
  49195. /**
  49196. * Define the code related to the BRDF parameters of the pbr material.
  49197. */
  49198. export class PBRBRDFConfiguration {
  49199. /**
  49200. * Default value used for the energy conservation.
  49201. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49202. */
  49203. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49204. /**
  49205. * Default value used for the Smith Visibility Height Correlated mode.
  49206. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49207. */
  49208. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49209. /**
  49210. * Default value used for the IBL diffuse part.
  49211. * This can help switching back to the polynomials mode globally which is a tiny bit
  49212. * less GPU intensive at the drawback of a lower quality.
  49213. */
  49214. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49215. /**
  49216. * Default value used for activating energy conservation for the specular workflow.
  49217. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49218. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49219. */
  49220. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49221. private _useEnergyConservation;
  49222. /**
  49223. * Defines if the material uses energy conservation.
  49224. */
  49225. useEnergyConservation: boolean;
  49226. private _useSmithVisibilityHeightCorrelated;
  49227. /**
  49228. * LEGACY Mode set to false
  49229. * Defines if the material uses height smith correlated visibility term.
  49230. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49231. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49232. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49233. * Not relying on height correlated will also disable energy conservation.
  49234. */
  49235. useSmithVisibilityHeightCorrelated: boolean;
  49236. private _useSphericalHarmonics;
  49237. /**
  49238. * LEGACY Mode set to false
  49239. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49240. * diffuse part of the IBL.
  49241. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49242. * to the ground truth.
  49243. */
  49244. useSphericalHarmonics: boolean;
  49245. private _useSpecularGlossinessInputEnergyConservation;
  49246. /**
  49247. * Defines if the material uses energy conservation, when the specular workflow is active.
  49248. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49249. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49250. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49251. */
  49252. useSpecularGlossinessInputEnergyConservation: boolean;
  49253. /** @hidden */
  49254. private _internalMarkAllSubMeshesAsMiscDirty;
  49255. /** @hidden */
  49256. _markAllSubMeshesAsMiscDirty(): void;
  49257. /**
  49258. * Instantiate a new istance of clear coat configuration.
  49259. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49260. */
  49261. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49262. /**
  49263. * Checks to see if a texture is used in the material.
  49264. * @param defines the list of "defines" to update.
  49265. */
  49266. prepareDefines(defines: IMaterialBRDFDefines): void;
  49267. /**
  49268. * Get the current class name of the texture useful for serialization or dynamic coding.
  49269. * @returns "PBRClearCoatConfiguration"
  49270. */
  49271. getClassName(): string;
  49272. /**
  49273. * Makes a duplicate of the current configuration into another one.
  49274. * @param brdfConfiguration define the config where to copy the info
  49275. */
  49276. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49277. /**
  49278. * Serializes this BRDF configuration.
  49279. * @returns - An object with the serialized config.
  49280. */
  49281. serialize(): any;
  49282. /**
  49283. * Parses a anisotropy Configuration from a serialized object.
  49284. * @param source - Serialized object.
  49285. * @param scene Defines the scene we are parsing for
  49286. * @param rootUrl Defines the rootUrl to load from
  49287. */
  49288. parse(source: any, scene: Scene, rootUrl: string): void;
  49289. }
  49290. }
  49291. declare module BABYLON {
  49292. /**
  49293. * @hidden
  49294. */
  49295. export interface IMaterialSheenDefines {
  49296. SHEEN: boolean;
  49297. SHEEN_TEXTURE: boolean;
  49298. SHEEN_TEXTUREDIRECTUV: number;
  49299. SHEEN_LINKWITHALBEDO: boolean;
  49300. /** @hidden */
  49301. _areTexturesDirty: boolean;
  49302. }
  49303. /**
  49304. * Define the code related to the Sheen parameters of the pbr material.
  49305. */
  49306. export class PBRSheenConfiguration {
  49307. private _isEnabled;
  49308. /**
  49309. * Defines if the material uses sheen.
  49310. */
  49311. isEnabled: boolean;
  49312. private _linkSheenWithAlbedo;
  49313. /**
  49314. * Defines if the sheen is linked to the sheen color.
  49315. */
  49316. linkSheenWithAlbedo: boolean;
  49317. /**
  49318. * Defines the sheen intensity.
  49319. */
  49320. intensity: number;
  49321. /**
  49322. * Defines the sheen color.
  49323. */
  49324. color: Color3;
  49325. private _texture;
  49326. /**
  49327. * Stores the sheen tint values in a texture.
  49328. * rgb is tint
  49329. * a is a intensity
  49330. */
  49331. texture: Nullable<BaseTexture>;
  49332. /** @hidden */
  49333. private _internalMarkAllSubMeshesAsTexturesDirty;
  49334. /** @hidden */
  49335. _markAllSubMeshesAsTexturesDirty(): void;
  49336. /**
  49337. * Instantiate a new istance of clear coat configuration.
  49338. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49339. */
  49340. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49341. /**
  49342. * Specifies that the submesh is ready to be used.
  49343. * @param defines the list of "defines" to update.
  49344. * @param scene defines the scene the material belongs to.
  49345. * @returns - boolean indicating that the submesh is ready or not.
  49346. */
  49347. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49348. /**
  49349. * Checks to see if a texture is used in the material.
  49350. * @param defines the list of "defines" to update.
  49351. * @param scene defines the scene the material belongs to.
  49352. */
  49353. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49354. /**
  49355. * Binds the material data.
  49356. * @param uniformBuffer defines the Uniform buffer to fill in.
  49357. * @param scene defines the scene the material belongs to.
  49358. * @param isFrozen defines wether the material is frozen or not.
  49359. */
  49360. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49361. /**
  49362. * Checks to see if a texture is used in the material.
  49363. * @param texture - Base texture to use.
  49364. * @returns - Boolean specifying if a texture is used in the material.
  49365. */
  49366. hasTexture(texture: BaseTexture): boolean;
  49367. /**
  49368. * Returns an array of the actively used textures.
  49369. * @param activeTextures Array of BaseTextures
  49370. */
  49371. getActiveTextures(activeTextures: BaseTexture[]): void;
  49372. /**
  49373. * Returns the animatable textures.
  49374. * @param animatables Array of animatable textures.
  49375. */
  49376. getAnimatables(animatables: IAnimatable[]): void;
  49377. /**
  49378. * Disposes the resources of the material.
  49379. * @param forceDisposeTextures - Forces the disposal of all textures.
  49380. */
  49381. dispose(forceDisposeTextures?: boolean): void;
  49382. /**
  49383. * Get the current class name of the texture useful for serialization or dynamic coding.
  49384. * @returns "PBRSheenConfiguration"
  49385. */
  49386. getClassName(): string;
  49387. /**
  49388. * Add fallbacks to the effect fallbacks list.
  49389. * @param defines defines the Base texture to use.
  49390. * @param fallbacks defines the current fallback list.
  49391. * @param currentRank defines the current fallback rank.
  49392. * @returns the new fallback rank.
  49393. */
  49394. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49395. /**
  49396. * Add the required uniforms to the current list.
  49397. * @param uniforms defines the current uniform list.
  49398. */
  49399. static AddUniforms(uniforms: string[]): void;
  49400. /**
  49401. * Add the required uniforms to the current buffer.
  49402. * @param uniformBuffer defines the current uniform buffer.
  49403. */
  49404. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49405. /**
  49406. * Add the required samplers to the current list.
  49407. * @param samplers defines the current sampler list.
  49408. */
  49409. static AddSamplers(samplers: string[]): void;
  49410. /**
  49411. * Makes a duplicate of the current configuration into another one.
  49412. * @param sheenConfiguration define the config where to copy the info
  49413. */
  49414. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49415. /**
  49416. * Serializes this BRDF configuration.
  49417. * @returns - An object with the serialized config.
  49418. */
  49419. serialize(): any;
  49420. /**
  49421. * Parses a anisotropy Configuration from a serialized object.
  49422. * @param source - Serialized object.
  49423. * @param scene Defines the scene we are parsing for
  49424. * @param rootUrl Defines the rootUrl to load from
  49425. */
  49426. parse(source: any, scene: Scene, rootUrl: string): void;
  49427. }
  49428. }
  49429. declare module BABYLON {
  49430. /**
  49431. * @hidden
  49432. */
  49433. export interface IMaterialSubSurfaceDefines {
  49434. SUBSURFACE: boolean;
  49435. SS_REFRACTION: boolean;
  49436. SS_TRANSLUCENCY: boolean;
  49437. SS_SCATERRING: boolean;
  49438. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49439. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49440. SS_REFRACTIONMAP_3D: boolean;
  49441. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49442. SS_LODINREFRACTIONALPHA: boolean;
  49443. SS_GAMMAREFRACTION: boolean;
  49444. SS_RGBDREFRACTION: boolean;
  49445. SS_LINEARSPECULARREFRACTION: boolean;
  49446. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49447. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49448. /** @hidden */
  49449. _areTexturesDirty: boolean;
  49450. }
  49451. /**
  49452. * Define the code related to the sub surface parameters of the pbr material.
  49453. */
  49454. export class PBRSubSurfaceConfiguration {
  49455. private _isRefractionEnabled;
  49456. /**
  49457. * Defines if the refraction is enabled in the material.
  49458. */
  49459. isRefractionEnabled: boolean;
  49460. private _isTranslucencyEnabled;
  49461. /**
  49462. * Defines if the translucency is enabled in the material.
  49463. */
  49464. isTranslucencyEnabled: boolean;
  49465. private _isScatteringEnabled;
  49466. /**
  49467. * Defines the refraction intensity of the material.
  49468. * The refraction when enabled replaces the Diffuse part of the material.
  49469. * The intensity helps transitionning between diffuse and refraction.
  49470. */
  49471. refractionIntensity: number;
  49472. /**
  49473. * Defines the translucency intensity of the material.
  49474. * When translucency has been enabled, this defines how much of the "translucency"
  49475. * is addded to the diffuse part of the material.
  49476. */
  49477. translucencyIntensity: number;
  49478. /**
  49479. * Defines the scattering intensity of the material.
  49480. * When scattering has been enabled, this defines how much of the "scattered light"
  49481. * is addded to the diffuse part of the material.
  49482. */
  49483. scatteringIntensity: number;
  49484. private _thicknessTexture;
  49485. /**
  49486. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49487. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49488. * 0 would mean minimumThickness
  49489. * 1 would mean maximumThickness
  49490. * The other channels might be use as a mask to vary the different effects intensity.
  49491. */
  49492. thicknessTexture: Nullable<BaseTexture>;
  49493. private _refractionTexture;
  49494. /**
  49495. * Defines the texture to use for refraction.
  49496. */
  49497. refractionTexture: Nullable<BaseTexture>;
  49498. private _indexOfRefraction;
  49499. /**
  49500. * Defines the index of refraction used in the material.
  49501. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49502. */
  49503. indexOfRefraction: number;
  49504. private _invertRefractionY;
  49505. /**
  49506. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49507. */
  49508. invertRefractionY: boolean;
  49509. private _linkRefractionWithTransparency;
  49510. /**
  49511. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49512. * Materials half opaque for instance using refraction could benefit from this control.
  49513. */
  49514. linkRefractionWithTransparency: boolean;
  49515. /**
  49516. * Defines the minimum thickness stored in the thickness map.
  49517. * If no thickness map is defined, this value will be used to simulate thickness.
  49518. */
  49519. minimumThickness: number;
  49520. /**
  49521. * Defines the maximum thickness stored in the thickness map.
  49522. */
  49523. maximumThickness: number;
  49524. /**
  49525. * Defines the volume tint of the material.
  49526. * This is used for both translucency and scattering.
  49527. */
  49528. tintColor: Color3;
  49529. /**
  49530. * Defines the distance at which the tint color should be found in the media.
  49531. * This is used for refraction only.
  49532. */
  49533. tintColorAtDistance: number;
  49534. /**
  49535. * Defines how far each channel transmit through the media.
  49536. * It is defined as a color to simplify it selection.
  49537. */
  49538. diffusionDistance: Color3;
  49539. private _useMaskFromThicknessTexture;
  49540. /**
  49541. * Stores the intensity of the different subsurface effects in the thickness texture.
  49542. * * the green channel is the translucency intensity.
  49543. * * the blue channel is the scattering intensity.
  49544. * * the alpha channel is the refraction intensity.
  49545. */
  49546. useMaskFromThicknessTexture: boolean;
  49547. /** @hidden */
  49548. private _internalMarkAllSubMeshesAsTexturesDirty;
  49549. /** @hidden */
  49550. _markAllSubMeshesAsTexturesDirty(): void;
  49551. /**
  49552. * Instantiate a new istance of sub surface configuration.
  49553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49554. */
  49555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49556. /**
  49557. * Gets wehter the submesh is ready to be used or not.
  49558. * @param defines the list of "defines" to update.
  49559. * @param scene defines the scene the material belongs to.
  49560. * @returns - boolean indicating that the submesh is ready or not.
  49561. */
  49562. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49563. /**
  49564. * Checks to see if a texture is used in the material.
  49565. * @param defines the list of "defines" to update.
  49566. * @param scene defines the scene to the material belongs to.
  49567. */
  49568. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49569. /**
  49570. * Binds the material data.
  49571. * @param uniformBuffer defines the Uniform buffer to fill in.
  49572. * @param scene defines the scene the material belongs to.
  49573. * @param engine defines the engine the material belongs to.
  49574. * @param isFrozen defines wether the material is frozen or not.
  49575. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49576. */
  49577. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49578. /**
  49579. * Unbinds the material from the mesh.
  49580. * @param activeEffect defines the effect that should be unbound from.
  49581. * @returns true if unbound, otherwise false
  49582. */
  49583. unbind(activeEffect: Effect): boolean;
  49584. /**
  49585. * Returns the texture used for refraction or null if none is used.
  49586. * @param scene defines the scene the material belongs to.
  49587. * @returns - Refraction texture if present. If no refraction texture and refraction
  49588. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49589. */
  49590. private _getRefractionTexture;
  49591. /**
  49592. * Returns true if alpha blending should be disabled.
  49593. */
  49594. get disableAlphaBlending(): boolean;
  49595. /**
  49596. * Fills the list of render target textures.
  49597. * @param renderTargets the list of render targets to update
  49598. */
  49599. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49600. /**
  49601. * Checks to see if a texture is used in the material.
  49602. * @param texture - Base texture to use.
  49603. * @returns - Boolean specifying if a texture is used in the material.
  49604. */
  49605. hasTexture(texture: BaseTexture): boolean;
  49606. /**
  49607. * Gets a boolean indicating that current material needs to register RTT
  49608. * @returns true if this uses a render target otherwise false.
  49609. */
  49610. hasRenderTargetTextures(): boolean;
  49611. /**
  49612. * Returns an array of the actively used textures.
  49613. * @param activeTextures Array of BaseTextures
  49614. */
  49615. getActiveTextures(activeTextures: BaseTexture[]): void;
  49616. /**
  49617. * Returns the animatable textures.
  49618. * @param animatables Array of animatable textures.
  49619. */
  49620. getAnimatables(animatables: IAnimatable[]): void;
  49621. /**
  49622. * Disposes the resources of the material.
  49623. * @param forceDisposeTextures - Forces the disposal of all textures.
  49624. */
  49625. dispose(forceDisposeTextures?: boolean): void;
  49626. /**
  49627. * Get the current class name of the texture useful for serialization or dynamic coding.
  49628. * @returns "PBRSubSurfaceConfiguration"
  49629. */
  49630. getClassName(): string;
  49631. /**
  49632. * Add fallbacks to the effect fallbacks list.
  49633. * @param defines defines the Base texture to use.
  49634. * @param fallbacks defines the current fallback list.
  49635. * @param currentRank defines the current fallback rank.
  49636. * @returns the new fallback rank.
  49637. */
  49638. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49639. /**
  49640. * Add the required uniforms to the current list.
  49641. * @param uniforms defines the current uniform list.
  49642. */
  49643. static AddUniforms(uniforms: string[]): void;
  49644. /**
  49645. * Add the required samplers to the current list.
  49646. * @param samplers defines the current sampler list.
  49647. */
  49648. static AddSamplers(samplers: string[]): void;
  49649. /**
  49650. * Add the required uniforms to the current buffer.
  49651. * @param uniformBuffer defines the current uniform buffer.
  49652. */
  49653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49654. /**
  49655. * Makes a duplicate of the current configuration into another one.
  49656. * @param configuration define the config where to copy the info
  49657. */
  49658. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49659. /**
  49660. * Serializes this Sub Surface configuration.
  49661. * @returns - An object with the serialized config.
  49662. */
  49663. serialize(): any;
  49664. /**
  49665. * Parses a anisotropy Configuration from a serialized object.
  49666. * @param source - Serialized object.
  49667. * @param scene Defines the scene we are parsing for
  49668. * @param rootUrl Defines the rootUrl to load from
  49669. */
  49670. parse(source: any, scene: Scene, rootUrl: string): void;
  49671. }
  49672. }
  49673. declare module BABYLON {
  49674. /** @hidden */
  49675. export var pbrFragmentDeclaration: {
  49676. name: string;
  49677. shader: string;
  49678. };
  49679. }
  49680. declare module BABYLON {
  49681. /** @hidden */
  49682. export var pbrUboDeclaration: {
  49683. name: string;
  49684. shader: string;
  49685. };
  49686. }
  49687. declare module BABYLON {
  49688. /** @hidden */
  49689. export var pbrFragmentExtraDeclaration: {
  49690. name: string;
  49691. shader: string;
  49692. };
  49693. }
  49694. declare module BABYLON {
  49695. /** @hidden */
  49696. export var pbrFragmentSamplersDeclaration: {
  49697. name: string;
  49698. shader: string;
  49699. };
  49700. }
  49701. declare module BABYLON {
  49702. /** @hidden */
  49703. export var pbrHelperFunctions: {
  49704. name: string;
  49705. shader: string;
  49706. };
  49707. }
  49708. declare module BABYLON {
  49709. /** @hidden */
  49710. export var harmonicsFunctions: {
  49711. name: string;
  49712. shader: string;
  49713. };
  49714. }
  49715. declare module BABYLON {
  49716. /** @hidden */
  49717. export var pbrDirectLightingSetupFunctions: {
  49718. name: string;
  49719. shader: string;
  49720. };
  49721. }
  49722. declare module BABYLON {
  49723. /** @hidden */
  49724. export var pbrDirectLightingFalloffFunctions: {
  49725. name: string;
  49726. shader: string;
  49727. };
  49728. }
  49729. declare module BABYLON {
  49730. /** @hidden */
  49731. export var pbrBRDFFunctions: {
  49732. name: string;
  49733. shader: string;
  49734. };
  49735. }
  49736. declare module BABYLON {
  49737. /** @hidden */
  49738. export var pbrDirectLightingFunctions: {
  49739. name: string;
  49740. shader: string;
  49741. };
  49742. }
  49743. declare module BABYLON {
  49744. /** @hidden */
  49745. export var pbrIBLFunctions: {
  49746. name: string;
  49747. shader: string;
  49748. };
  49749. }
  49750. declare module BABYLON {
  49751. /** @hidden */
  49752. export var pbrDebug: {
  49753. name: string;
  49754. shader: string;
  49755. };
  49756. }
  49757. declare module BABYLON {
  49758. /** @hidden */
  49759. export var pbrPixelShader: {
  49760. name: string;
  49761. shader: string;
  49762. };
  49763. }
  49764. declare module BABYLON {
  49765. /** @hidden */
  49766. export var pbrVertexDeclaration: {
  49767. name: string;
  49768. shader: string;
  49769. };
  49770. }
  49771. declare module BABYLON {
  49772. /** @hidden */
  49773. export var pbrVertexShader: {
  49774. name: string;
  49775. shader: string;
  49776. };
  49777. }
  49778. declare module BABYLON {
  49779. /**
  49780. * Manages the defines for the PBR Material.
  49781. * @hidden
  49782. */
  49783. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49784. PBR: boolean;
  49785. MAINUV1: boolean;
  49786. MAINUV2: boolean;
  49787. UV1: boolean;
  49788. UV2: boolean;
  49789. ALBEDO: boolean;
  49790. ALBEDODIRECTUV: number;
  49791. VERTEXCOLOR: boolean;
  49792. AMBIENT: boolean;
  49793. AMBIENTDIRECTUV: number;
  49794. AMBIENTINGRAYSCALE: boolean;
  49795. OPACITY: boolean;
  49796. VERTEXALPHA: boolean;
  49797. OPACITYDIRECTUV: number;
  49798. OPACITYRGB: boolean;
  49799. ALPHATEST: boolean;
  49800. DEPTHPREPASS: boolean;
  49801. ALPHABLEND: boolean;
  49802. ALPHAFROMALBEDO: boolean;
  49803. ALPHATESTVALUE: string;
  49804. SPECULAROVERALPHA: boolean;
  49805. RADIANCEOVERALPHA: boolean;
  49806. ALPHAFRESNEL: boolean;
  49807. LINEARALPHAFRESNEL: boolean;
  49808. PREMULTIPLYALPHA: boolean;
  49809. EMISSIVE: boolean;
  49810. EMISSIVEDIRECTUV: number;
  49811. REFLECTIVITY: boolean;
  49812. REFLECTIVITYDIRECTUV: number;
  49813. SPECULARTERM: boolean;
  49814. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49815. MICROSURFACEAUTOMATIC: boolean;
  49816. LODBASEDMICROSFURACE: boolean;
  49817. MICROSURFACEMAP: boolean;
  49818. MICROSURFACEMAPDIRECTUV: number;
  49819. METALLICWORKFLOW: boolean;
  49820. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49821. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49822. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49823. AOSTOREINMETALMAPRED: boolean;
  49824. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49825. ENVIRONMENTBRDF: boolean;
  49826. ENVIRONMENTBRDF_RGBD: boolean;
  49827. NORMAL: boolean;
  49828. TANGENT: boolean;
  49829. BUMP: boolean;
  49830. BUMPDIRECTUV: number;
  49831. OBJECTSPACE_NORMALMAP: boolean;
  49832. PARALLAX: boolean;
  49833. PARALLAXOCCLUSION: boolean;
  49834. NORMALXYSCALE: boolean;
  49835. LIGHTMAP: boolean;
  49836. LIGHTMAPDIRECTUV: number;
  49837. USELIGHTMAPASSHADOWMAP: boolean;
  49838. GAMMALIGHTMAP: boolean;
  49839. RGBDLIGHTMAP: boolean;
  49840. REFLECTION: boolean;
  49841. REFLECTIONMAP_3D: boolean;
  49842. REFLECTIONMAP_SPHERICAL: boolean;
  49843. REFLECTIONMAP_PLANAR: boolean;
  49844. REFLECTIONMAP_CUBIC: boolean;
  49845. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49846. REFLECTIONMAP_PROJECTION: boolean;
  49847. REFLECTIONMAP_SKYBOX: boolean;
  49848. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49849. REFLECTIONMAP_EXPLICIT: boolean;
  49850. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49851. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49852. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49853. INVERTCUBICMAP: boolean;
  49854. USESPHERICALFROMREFLECTIONMAP: boolean;
  49855. USEIRRADIANCEMAP: boolean;
  49856. SPHERICAL_HARMONICS: boolean;
  49857. USESPHERICALINVERTEX: boolean;
  49858. REFLECTIONMAP_OPPOSITEZ: boolean;
  49859. LODINREFLECTIONALPHA: boolean;
  49860. GAMMAREFLECTION: boolean;
  49861. RGBDREFLECTION: boolean;
  49862. LINEARSPECULARREFLECTION: boolean;
  49863. RADIANCEOCCLUSION: boolean;
  49864. HORIZONOCCLUSION: boolean;
  49865. INSTANCES: boolean;
  49866. NUM_BONE_INFLUENCERS: number;
  49867. BonesPerMesh: number;
  49868. BONETEXTURE: boolean;
  49869. NONUNIFORMSCALING: boolean;
  49870. MORPHTARGETS: boolean;
  49871. MORPHTARGETS_NORMAL: boolean;
  49872. MORPHTARGETS_TANGENT: boolean;
  49873. MORPHTARGETS_UV: boolean;
  49874. NUM_MORPH_INFLUENCERS: number;
  49875. IMAGEPROCESSING: boolean;
  49876. VIGNETTE: boolean;
  49877. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49878. VIGNETTEBLENDMODEOPAQUE: boolean;
  49879. TONEMAPPING: boolean;
  49880. TONEMAPPING_ACES: boolean;
  49881. CONTRAST: boolean;
  49882. COLORCURVES: boolean;
  49883. COLORGRADING: boolean;
  49884. COLORGRADING3D: boolean;
  49885. SAMPLER3DGREENDEPTH: boolean;
  49886. SAMPLER3DBGRMAP: boolean;
  49887. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49888. EXPOSURE: boolean;
  49889. MULTIVIEW: boolean;
  49890. USEPHYSICALLIGHTFALLOFF: boolean;
  49891. USEGLTFLIGHTFALLOFF: boolean;
  49892. TWOSIDEDLIGHTING: boolean;
  49893. SHADOWFLOAT: boolean;
  49894. CLIPPLANE: boolean;
  49895. CLIPPLANE2: boolean;
  49896. CLIPPLANE3: boolean;
  49897. CLIPPLANE4: boolean;
  49898. CLIPPLANE5: boolean;
  49899. CLIPPLANE6: boolean;
  49900. POINTSIZE: boolean;
  49901. FOG: boolean;
  49902. LOGARITHMICDEPTH: boolean;
  49903. FORCENORMALFORWARD: boolean;
  49904. SPECULARAA: boolean;
  49905. CLEARCOAT: boolean;
  49906. CLEARCOAT_DEFAULTIOR: boolean;
  49907. CLEARCOAT_TEXTURE: boolean;
  49908. CLEARCOAT_TEXTUREDIRECTUV: number;
  49909. CLEARCOAT_BUMP: boolean;
  49910. CLEARCOAT_BUMPDIRECTUV: number;
  49911. CLEARCOAT_TINT: boolean;
  49912. CLEARCOAT_TINT_TEXTURE: boolean;
  49913. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49914. ANISOTROPIC: boolean;
  49915. ANISOTROPIC_TEXTURE: boolean;
  49916. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49917. BRDF_V_HEIGHT_CORRELATED: boolean;
  49918. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49919. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49920. SHEEN: boolean;
  49921. SHEEN_TEXTURE: boolean;
  49922. SHEEN_TEXTUREDIRECTUV: number;
  49923. SHEEN_LINKWITHALBEDO: boolean;
  49924. SUBSURFACE: boolean;
  49925. SS_REFRACTION: boolean;
  49926. SS_TRANSLUCENCY: boolean;
  49927. SS_SCATERRING: boolean;
  49928. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49929. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49930. SS_REFRACTIONMAP_3D: boolean;
  49931. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49932. SS_LODINREFRACTIONALPHA: boolean;
  49933. SS_GAMMAREFRACTION: boolean;
  49934. SS_RGBDREFRACTION: boolean;
  49935. SS_LINEARSPECULARREFRACTION: boolean;
  49936. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49937. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49938. UNLIT: boolean;
  49939. DEBUGMODE: number;
  49940. /**
  49941. * Initializes the PBR Material defines.
  49942. */
  49943. constructor();
  49944. /**
  49945. * Resets the PBR Material defines.
  49946. */
  49947. reset(): void;
  49948. }
  49949. /**
  49950. * The Physically based material base class of BJS.
  49951. *
  49952. * This offers the main features of a standard PBR material.
  49953. * For more information, please refer to the documentation :
  49954. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49955. */
  49956. export abstract class PBRBaseMaterial extends PushMaterial {
  49957. /**
  49958. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49959. */
  49960. static readonly PBRMATERIAL_OPAQUE: number;
  49961. /**
  49962. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49963. */
  49964. static readonly PBRMATERIAL_ALPHATEST: number;
  49965. /**
  49966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49967. */
  49968. static readonly PBRMATERIAL_ALPHABLEND: number;
  49969. /**
  49970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49971. * They are also discarded below the alpha cutoff threshold to improve performances.
  49972. */
  49973. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49974. /**
  49975. * Defines the default value of how much AO map is occluding the analytical lights
  49976. * (point spot...).
  49977. */
  49978. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49979. /**
  49980. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49981. */
  49982. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49983. /**
  49984. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49985. * to enhance interoperability with other engines.
  49986. */
  49987. static readonly LIGHTFALLOFF_GLTF: number;
  49988. /**
  49989. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49990. * to enhance interoperability with other materials.
  49991. */
  49992. static readonly LIGHTFALLOFF_STANDARD: number;
  49993. /**
  49994. * Intensity of the direct lights e.g. the four lights available in your scene.
  49995. * This impacts both the direct diffuse and specular highlights.
  49996. */
  49997. protected _directIntensity: number;
  49998. /**
  49999. * Intensity of the emissive part of the material.
  50000. * This helps controlling the emissive effect without modifying the emissive color.
  50001. */
  50002. protected _emissiveIntensity: number;
  50003. /**
  50004. * Intensity of the environment e.g. how much the environment will light the object
  50005. * either through harmonics for rough material or through the refelction for shiny ones.
  50006. */
  50007. protected _environmentIntensity: number;
  50008. /**
  50009. * This is a special control allowing the reduction of the specular highlights coming from the
  50010. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50011. */
  50012. protected _specularIntensity: number;
  50013. /**
  50014. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50015. */
  50016. private _lightingInfos;
  50017. /**
  50018. * Debug Control allowing disabling the bump map on this material.
  50019. */
  50020. protected _disableBumpMap: boolean;
  50021. /**
  50022. * AKA Diffuse Texture in standard nomenclature.
  50023. */
  50024. protected _albedoTexture: Nullable<BaseTexture>;
  50025. /**
  50026. * AKA Occlusion Texture in other nomenclature.
  50027. */
  50028. protected _ambientTexture: Nullable<BaseTexture>;
  50029. /**
  50030. * AKA Occlusion Texture Intensity in other nomenclature.
  50031. */
  50032. protected _ambientTextureStrength: number;
  50033. /**
  50034. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50035. * 1 means it completely occludes it
  50036. * 0 mean it has no impact
  50037. */
  50038. protected _ambientTextureImpactOnAnalyticalLights: number;
  50039. /**
  50040. * Stores the alpha values in a texture.
  50041. */
  50042. protected _opacityTexture: Nullable<BaseTexture>;
  50043. /**
  50044. * Stores the reflection values in a texture.
  50045. */
  50046. protected _reflectionTexture: Nullable<BaseTexture>;
  50047. /**
  50048. * Stores the emissive values in a texture.
  50049. */
  50050. protected _emissiveTexture: Nullable<BaseTexture>;
  50051. /**
  50052. * AKA Specular texture in other nomenclature.
  50053. */
  50054. protected _reflectivityTexture: Nullable<BaseTexture>;
  50055. /**
  50056. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50057. */
  50058. protected _metallicTexture: Nullable<BaseTexture>;
  50059. /**
  50060. * Specifies the metallic scalar of the metallic/roughness workflow.
  50061. * Can also be used to scale the metalness values of the metallic texture.
  50062. */
  50063. protected _metallic: Nullable<number>;
  50064. /**
  50065. * Specifies the roughness scalar of the metallic/roughness workflow.
  50066. * Can also be used to scale the roughness values of the metallic texture.
  50067. */
  50068. protected _roughness: Nullable<number>;
  50069. /**
  50070. * Specifies the an F0 factor to help configuring the material F0.
  50071. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50072. * to 0.5 the previously hard coded value stays the same.
  50073. * Can also be used to scale the F0 values of the metallic texture.
  50074. */
  50075. protected _metallicF0Factor: number;
  50076. /**
  50077. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50078. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50079. * your expectation as it multiplies with the texture data.
  50080. */
  50081. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50082. /**
  50083. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50084. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50085. */
  50086. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50087. /**
  50088. * Stores surface normal data used to displace a mesh in a texture.
  50089. */
  50090. protected _bumpTexture: Nullable<BaseTexture>;
  50091. /**
  50092. * Stores the pre-calculated light information of a mesh in a texture.
  50093. */
  50094. protected _lightmapTexture: Nullable<BaseTexture>;
  50095. /**
  50096. * The color of a material in ambient lighting.
  50097. */
  50098. protected _ambientColor: Color3;
  50099. /**
  50100. * AKA Diffuse Color in other nomenclature.
  50101. */
  50102. protected _albedoColor: Color3;
  50103. /**
  50104. * AKA Specular Color in other nomenclature.
  50105. */
  50106. protected _reflectivityColor: Color3;
  50107. /**
  50108. * The color applied when light is reflected from a material.
  50109. */
  50110. protected _reflectionColor: Color3;
  50111. /**
  50112. * The color applied when light is emitted from a material.
  50113. */
  50114. protected _emissiveColor: Color3;
  50115. /**
  50116. * AKA Glossiness in other nomenclature.
  50117. */
  50118. protected _microSurface: number;
  50119. /**
  50120. * Specifies that the material will use the light map as a show map.
  50121. */
  50122. protected _useLightmapAsShadowmap: boolean;
  50123. /**
  50124. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50125. * makes the reflect vector face the model (under horizon).
  50126. */
  50127. protected _useHorizonOcclusion: boolean;
  50128. /**
  50129. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50130. * too much the area relying on ambient texture to define their ambient occlusion.
  50131. */
  50132. protected _useRadianceOcclusion: boolean;
  50133. /**
  50134. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50135. */
  50136. protected _useAlphaFromAlbedoTexture: boolean;
  50137. /**
  50138. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50139. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50140. */
  50141. protected _useSpecularOverAlpha: boolean;
  50142. /**
  50143. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50144. */
  50145. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50146. /**
  50147. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50148. */
  50149. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50150. /**
  50151. * Specifies if the metallic texture contains the roughness information in its green channel.
  50152. */
  50153. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50154. /**
  50155. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50156. */
  50157. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50158. /**
  50159. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50160. */
  50161. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50162. /**
  50163. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50164. */
  50165. protected _useAmbientInGrayScale: boolean;
  50166. /**
  50167. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50168. * The material will try to infer what glossiness each pixel should be.
  50169. */
  50170. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50171. /**
  50172. * Defines the falloff type used in this material.
  50173. * It by default is Physical.
  50174. */
  50175. protected _lightFalloff: number;
  50176. /**
  50177. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50178. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50179. */
  50180. protected _useRadianceOverAlpha: boolean;
  50181. /**
  50182. * Allows using an object space normal map (instead of tangent space).
  50183. */
  50184. protected _useObjectSpaceNormalMap: boolean;
  50185. /**
  50186. * Allows using the bump map in parallax mode.
  50187. */
  50188. protected _useParallax: boolean;
  50189. /**
  50190. * Allows using the bump map in parallax occlusion mode.
  50191. */
  50192. protected _useParallaxOcclusion: boolean;
  50193. /**
  50194. * Controls the scale bias of the parallax mode.
  50195. */
  50196. protected _parallaxScaleBias: number;
  50197. /**
  50198. * If sets to true, disables all the lights affecting the material.
  50199. */
  50200. protected _disableLighting: boolean;
  50201. /**
  50202. * Number of Simultaneous lights allowed on the material.
  50203. */
  50204. protected _maxSimultaneousLights: number;
  50205. /**
  50206. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50207. */
  50208. protected _invertNormalMapX: boolean;
  50209. /**
  50210. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50211. */
  50212. protected _invertNormalMapY: boolean;
  50213. /**
  50214. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50215. */
  50216. protected _twoSidedLighting: boolean;
  50217. /**
  50218. * Defines the alpha limits in alpha test mode.
  50219. */
  50220. protected _alphaCutOff: number;
  50221. /**
  50222. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50223. */
  50224. protected _forceAlphaTest: boolean;
  50225. /**
  50226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50227. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50228. */
  50229. protected _useAlphaFresnel: boolean;
  50230. /**
  50231. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50232. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50233. */
  50234. protected _useLinearAlphaFresnel: boolean;
  50235. /**
  50236. * The transparency mode of the material.
  50237. */
  50238. protected _transparencyMode: Nullable<number>;
  50239. /**
  50240. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50241. * from cos thetav and roughness:
  50242. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50243. */
  50244. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50245. /**
  50246. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50247. */
  50248. protected _forceIrradianceInFragment: boolean;
  50249. /**
  50250. * Force normal to face away from face.
  50251. */
  50252. protected _forceNormalForward: boolean;
  50253. /**
  50254. * Enables specular anti aliasing in the PBR shader.
  50255. * It will both interacts on the Geometry for analytical and IBL lighting.
  50256. * It also prefilter the roughness map based on the bump values.
  50257. */
  50258. protected _enableSpecularAntiAliasing: boolean;
  50259. /**
  50260. * Default configuration related to image processing available in the PBR Material.
  50261. */
  50262. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50263. /**
  50264. * Keep track of the image processing observer to allow dispose and replace.
  50265. */
  50266. private _imageProcessingObserver;
  50267. /**
  50268. * Attaches a new image processing configuration to the PBR Material.
  50269. * @param configuration
  50270. */
  50271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50272. /**
  50273. * Stores the available render targets.
  50274. */
  50275. private _renderTargets;
  50276. /**
  50277. * Sets the global ambient color for the material used in lighting calculations.
  50278. */
  50279. private _globalAmbientColor;
  50280. /**
  50281. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50282. */
  50283. private _useLogarithmicDepth;
  50284. /**
  50285. * If set to true, no lighting calculations will be applied.
  50286. */
  50287. private _unlit;
  50288. private _debugMode;
  50289. /**
  50290. * @hidden
  50291. * This is reserved for the inspector.
  50292. * Defines the material debug mode.
  50293. * It helps seeing only some components of the material while troubleshooting.
  50294. */
  50295. debugMode: number;
  50296. /**
  50297. * @hidden
  50298. * This is reserved for the inspector.
  50299. * Specify from where on screen the debug mode should start.
  50300. * The value goes from -1 (full screen) to 1 (not visible)
  50301. * It helps with side by side comparison against the final render
  50302. * This defaults to -1
  50303. */
  50304. private debugLimit;
  50305. /**
  50306. * @hidden
  50307. * This is reserved for the inspector.
  50308. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50309. * You can use the factor to better multiply the final value.
  50310. */
  50311. private debugFactor;
  50312. /**
  50313. * Defines the clear coat layer parameters for the material.
  50314. */
  50315. readonly clearCoat: PBRClearCoatConfiguration;
  50316. /**
  50317. * Defines the anisotropic parameters for the material.
  50318. */
  50319. readonly anisotropy: PBRAnisotropicConfiguration;
  50320. /**
  50321. * Defines the BRDF parameters for the material.
  50322. */
  50323. readonly brdf: PBRBRDFConfiguration;
  50324. /**
  50325. * Defines the Sheen parameters for the material.
  50326. */
  50327. readonly sheen: PBRSheenConfiguration;
  50328. /**
  50329. * Defines the SubSurface parameters for the material.
  50330. */
  50331. readonly subSurface: PBRSubSurfaceConfiguration;
  50332. /**
  50333. * Custom callback helping to override the default shader used in the material.
  50334. */
  50335. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50336. protected _rebuildInParallel: boolean;
  50337. /**
  50338. * Instantiates a new PBRMaterial instance.
  50339. *
  50340. * @param name The material name
  50341. * @param scene The scene the material will be use in.
  50342. */
  50343. constructor(name: string, scene: Scene);
  50344. /**
  50345. * Gets a boolean indicating that current material needs to register RTT
  50346. */
  50347. get hasRenderTargetTextures(): boolean;
  50348. /**
  50349. * Gets the name of the material class.
  50350. */
  50351. getClassName(): string;
  50352. /**
  50353. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50354. */
  50355. get useLogarithmicDepth(): boolean;
  50356. /**
  50357. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50358. */
  50359. set useLogarithmicDepth(value: boolean);
  50360. /**
  50361. * Gets the current transparency mode.
  50362. */
  50363. get transparencyMode(): Nullable<number>;
  50364. /**
  50365. * Sets the transparency mode of the material.
  50366. *
  50367. * | Value | Type | Description |
  50368. * | ----- | ----------------------------------- | ----------- |
  50369. * | 0 | OPAQUE | |
  50370. * | 1 | ALPHATEST | |
  50371. * | 2 | ALPHABLEND | |
  50372. * | 3 | ALPHATESTANDBLEND | |
  50373. *
  50374. */
  50375. set transparencyMode(value: Nullable<number>);
  50376. /**
  50377. * Returns true if alpha blending should be disabled.
  50378. */
  50379. private get _disableAlphaBlending();
  50380. /**
  50381. * Specifies whether or not this material should be rendered in alpha blend mode.
  50382. */
  50383. needAlphaBlending(): boolean;
  50384. /**
  50385. * Specifies if the mesh will require alpha blending.
  50386. * @param mesh - BJS mesh.
  50387. */
  50388. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50389. /**
  50390. * Specifies whether or not this material should be rendered in alpha test mode.
  50391. */
  50392. needAlphaTesting(): boolean;
  50393. /**
  50394. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50395. */
  50396. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50397. /**
  50398. * Gets the texture used for the alpha test.
  50399. */
  50400. getAlphaTestTexture(): Nullable<BaseTexture>;
  50401. /**
  50402. * Specifies that the submesh is ready to be used.
  50403. * @param mesh - BJS mesh.
  50404. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50405. * @param useInstances - Specifies that instances should be used.
  50406. * @returns - boolean indicating that the submesh is ready or not.
  50407. */
  50408. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50409. /**
  50410. * Specifies if the material uses metallic roughness workflow.
  50411. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50412. */
  50413. isMetallicWorkflow(): boolean;
  50414. private _prepareEffect;
  50415. private _prepareDefines;
  50416. /**
  50417. * Force shader compilation
  50418. */
  50419. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50420. /**
  50421. * Initializes the uniform buffer layout for the shader.
  50422. */
  50423. buildUniformLayout(): void;
  50424. /**
  50425. * Unbinds the material from the mesh
  50426. */
  50427. unbind(): void;
  50428. /**
  50429. * Binds the submesh data.
  50430. * @param world - The world matrix.
  50431. * @param mesh - The BJS mesh.
  50432. * @param subMesh - A submesh of the BJS mesh.
  50433. */
  50434. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50435. /**
  50436. * Returns the animatable textures.
  50437. * @returns - Array of animatable textures.
  50438. */
  50439. getAnimatables(): IAnimatable[];
  50440. /**
  50441. * Returns the texture used for reflections.
  50442. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50443. */
  50444. private _getReflectionTexture;
  50445. /**
  50446. * Returns an array of the actively used textures.
  50447. * @returns - Array of BaseTextures
  50448. */
  50449. getActiveTextures(): BaseTexture[];
  50450. /**
  50451. * Checks to see if a texture is used in the material.
  50452. * @param texture - Base texture to use.
  50453. * @returns - Boolean specifying if a texture is used in the material.
  50454. */
  50455. hasTexture(texture: BaseTexture): boolean;
  50456. /**
  50457. * Disposes the resources of the material.
  50458. * @param forceDisposeEffect - Forces the disposal of effects.
  50459. * @param forceDisposeTextures - Forces the disposal of all textures.
  50460. */
  50461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50462. }
  50463. }
  50464. declare module BABYLON {
  50465. /**
  50466. * The Physically based material of BJS.
  50467. *
  50468. * This offers the main features of a standard PBR material.
  50469. * For more information, please refer to the documentation :
  50470. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50471. */
  50472. export class PBRMaterial extends PBRBaseMaterial {
  50473. /**
  50474. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50475. */
  50476. static readonly PBRMATERIAL_OPAQUE: number;
  50477. /**
  50478. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50479. */
  50480. static readonly PBRMATERIAL_ALPHATEST: number;
  50481. /**
  50482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50483. */
  50484. static readonly PBRMATERIAL_ALPHABLEND: number;
  50485. /**
  50486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50487. * They are also discarded below the alpha cutoff threshold to improve performances.
  50488. */
  50489. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50490. /**
  50491. * Defines the default value of how much AO map is occluding the analytical lights
  50492. * (point spot...).
  50493. */
  50494. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50495. /**
  50496. * Intensity of the direct lights e.g. the four lights available in your scene.
  50497. * This impacts both the direct diffuse and specular highlights.
  50498. */
  50499. directIntensity: number;
  50500. /**
  50501. * Intensity of the emissive part of the material.
  50502. * This helps controlling the emissive effect without modifying the emissive color.
  50503. */
  50504. emissiveIntensity: number;
  50505. /**
  50506. * Intensity of the environment e.g. how much the environment will light the object
  50507. * either through harmonics for rough material or through the refelction for shiny ones.
  50508. */
  50509. environmentIntensity: number;
  50510. /**
  50511. * This is a special control allowing the reduction of the specular highlights coming from the
  50512. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50513. */
  50514. specularIntensity: number;
  50515. /**
  50516. * Debug Control allowing disabling the bump map on this material.
  50517. */
  50518. disableBumpMap: boolean;
  50519. /**
  50520. * AKA Diffuse Texture in standard nomenclature.
  50521. */
  50522. albedoTexture: BaseTexture;
  50523. /**
  50524. * AKA Occlusion Texture in other nomenclature.
  50525. */
  50526. ambientTexture: BaseTexture;
  50527. /**
  50528. * AKA Occlusion Texture Intensity in other nomenclature.
  50529. */
  50530. ambientTextureStrength: number;
  50531. /**
  50532. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50533. * 1 means it completely occludes it
  50534. * 0 mean it has no impact
  50535. */
  50536. ambientTextureImpactOnAnalyticalLights: number;
  50537. /**
  50538. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50539. */
  50540. opacityTexture: BaseTexture;
  50541. /**
  50542. * Stores the reflection values in a texture.
  50543. */
  50544. reflectionTexture: Nullable<BaseTexture>;
  50545. /**
  50546. * Stores the emissive values in a texture.
  50547. */
  50548. emissiveTexture: BaseTexture;
  50549. /**
  50550. * AKA Specular texture in other nomenclature.
  50551. */
  50552. reflectivityTexture: BaseTexture;
  50553. /**
  50554. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50555. */
  50556. metallicTexture: BaseTexture;
  50557. /**
  50558. * Specifies the metallic scalar of the metallic/roughness workflow.
  50559. * Can also be used to scale the metalness values of the metallic texture.
  50560. */
  50561. metallic: Nullable<number>;
  50562. /**
  50563. * Specifies the roughness scalar of the metallic/roughness workflow.
  50564. * Can also be used to scale the roughness values of the metallic texture.
  50565. */
  50566. roughness: Nullable<number>;
  50567. /**
  50568. * Specifies the an F0 factor to help configuring the material F0.
  50569. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50570. * to 0.5 the previously hard coded value stays the same.
  50571. * Can also be used to scale the F0 values of the metallic texture.
  50572. */
  50573. metallicF0Factor: number;
  50574. /**
  50575. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50576. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50577. * your expectation as it multiplies with the texture data.
  50578. */
  50579. useMetallicF0FactorFromMetallicTexture: boolean;
  50580. /**
  50581. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50582. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50583. */
  50584. microSurfaceTexture: BaseTexture;
  50585. /**
  50586. * Stores surface normal data used to displace a mesh in a texture.
  50587. */
  50588. bumpTexture: BaseTexture;
  50589. /**
  50590. * Stores the pre-calculated light information of a mesh in a texture.
  50591. */
  50592. lightmapTexture: BaseTexture;
  50593. /**
  50594. * Stores the refracted light information in a texture.
  50595. */
  50596. get refractionTexture(): Nullable<BaseTexture>;
  50597. set refractionTexture(value: Nullable<BaseTexture>);
  50598. /**
  50599. * The color of a material in ambient lighting.
  50600. */
  50601. ambientColor: Color3;
  50602. /**
  50603. * AKA Diffuse Color in other nomenclature.
  50604. */
  50605. albedoColor: Color3;
  50606. /**
  50607. * AKA Specular Color in other nomenclature.
  50608. */
  50609. reflectivityColor: Color3;
  50610. /**
  50611. * The color reflected from the material.
  50612. */
  50613. reflectionColor: Color3;
  50614. /**
  50615. * The color emitted from the material.
  50616. */
  50617. emissiveColor: Color3;
  50618. /**
  50619. * AKA Glossiness in other nomenclature.
  50620. */
  50621. microSurface: number;
  50622. /**
  50623. * source material index of refraction (IOR)' / 'destination material IOR.
  50624. */
  50625. get indexOfRefraction(): number;
  50626. set indexOfRefraction(value: number);
  50627. /**
  50628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50629. */
  50630. get invertRefractionY(): boolean;
  50631. set invertRefractionY(value: boolean);
  50632. /**
  50633. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50634. * Materials half opaque for instance using refraction could benefit from this control.
  50635. */
  50636. get linkRefractionWithTransparency(): boolean;
  50637. set linkRefractionWithTransparency(value: boolean);
  50638. /**
  50639. * If true, the light map contains occlusion information instead of lighting info.
  50640. */
  50641. useLightmapAsShadowmap: boolean;
  50642. /**
  50643. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50644. */
  50645. useAlphaFromAlbedoTexture: boolean;
  50646. /**
  50647. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50648. */
  50649. forceAlphaTest: boolean;
  50650. /**
  50651. * Defines the alpha limits in alpha test mode.
  50652. */
  50653. alphaCutOff: number;
  50654. /**
  50655. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50657. */
  50658. useSpecularOverAlpha: boolean;
  50659. /**
  50660. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50661. */
  50662. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50663. /**
  50664. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50665. */
  50666. useRoughnessFromMetallicTextureAlpha: boolean;
  50667. /**
  50668. * Specifies if the metallic texture contains the roughness information in its green channel.
  50669. */
  50670. useRoughnessFromMetallicTextureGreen: boolean;
  50671. /**
  50672. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50673. */
  50674. useMetallnessFromMetallicTextureBlue: boolean;
  50675. /**
  50676. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50677. */
  50678. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50679. /**
  50680. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50681. */
  50682. useAmbientInGrayScale: boolean;
  50683. /**
  50684. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50685. * The material will try to infer what glossiness each pixel should be.
  50686. */
  50687. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50688. /**
  50689. * BJS is using an harcoded light falloff based on a manually sets up range.
  50690. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50691. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50692. */
  50693. get usePhysicalLightFalloff(): boolean;
  50694. /**
  50695. * BJS is using an harcoded light falloff based on a manually sets up range.
  50696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50698. */
  50699. set usePhysicalLightFalloff(value: boolean);
  50700. /**
  50701. * In order to support the falloff compatibility with gltf, a special mode has been added
  50702. * to reproduce the gltf light falloff.
  50703. */
  50704. get useGLTFLightFalloff(): boolean;
  50705. /**
  50706. * In order to support the falloff compatibility with gltf, a special mode has been added
  50707. * to reproduce the gltf light falloff.
  50708. */
  50709. set useGLTFLightFalloff(value: boolean);
  50710. /**
  50711. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50712. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50713. */
  50714. useRadianceOverAlpha: boolean;
  50715. /**
  50716. * Allows using an object space normal map (instead of tangent space).
  50717. */
  50718. useObjectSpaceNormalMap: boolean;
  50719. /**
  50720. * Allows using the bump map in parallax mode.
  50721. */
  50722. useParallax: boolean;
  50723. /**
  50724. * Allows using the bump map in parallax occlusion mode.
  50725. */
  50726. useParallaxOcclusion: boolean;
  50727. /**
  50728. * Controls the scale bias of the parallax mode.
  50729. */
  50730. parallaxScaleBias: number;
  50731. /**
  50732. * If sets to true, disables all the lights affecting the material.
  50733. */
  50734. disableLighting: boolean;
  50735. /**
  50736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50737. */
  50738. forceIrradianceInFragment: boolean;
  50739. /**
  50740. * Number of Simultaneous lights allowed on the material.
  50741. */
  50742. maxSimultaneousLights: number;
  50743. /**
  50744. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50745. */
  50746. invertNormalMapX: boolean;
  50747. /**
  50748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50749. */
  50750. invertNormalMapY: boolean;
  50751. /**
  50752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50753. */
  50754. twoSidedLighting: boolean;
  50755. /**
  50756. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50757. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50758. */
  50759. useAlphaFresnel: boolean;
  50760. /**
  50761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50762. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50763. */
  50764. useLinearAlphaFresnel: boolean;
  50765. /**
  50766. * Let user defines the brdf lookup texture used for IBL.
  50767. * A default 8bit version is embedded but you could point at :
  50768. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50769. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50770. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50771. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50772. */
  50773. environmentBRDFTexture: Nullable<BaseTexture>;
  50774. /**
  50775. * Force normal to face away from face.
  50776. */
  50777. forceNormalForward: boolean;
  50778. /**
  50779. * Enables specular anti aliasing in the PBR shader.
  50780. * It will both interacts on the Geometry for analytical and IBL lighting.
  50781. * It also prefilter the roughness map based on the bump values.
  50782. */
  50783. enableSpecularAntiAliasing: boolean;
  50784. /**
  50785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50786. * makes the reflect vector face the model (under horizon).
  50787. */
  50788. useHorizonOcclusion: boolean;
  50789. /**
  50790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50791. * too much the area relying on ambient texture to define their ambient occlusion.
  50792. */
  50793. useRadianceOcclusion: boolean;
  50794. /**
  50795. * If set to true, no lighting calculations will be applied.
  50796. */
  50797. unlit: boolean;
  50798. /**
  50799. * Gets the image processing configuration used either in this material.
  50800. */
  50801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50802. /**
  50803. * Sets the Default image processing configuration used either in the this material.
  50804. *
  50805. * If sets to null, the scene one is in use.
  50806. */
  50807. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50808. /**
  50809. * Gets wether the color curves effect is enabled.
  50810. */
  50811. get cameraColorCurvesEnabled(): boolean;
  50812. /**
  50813. * Sets wether the color curves effect is enabled.
  50814. */
  50815. set cameraColorCurvesEnabled(value: boolean);
  50816. /**
  50817. * Gets wether the color grading effect is enabled.
  50818. */
  50819. get cameraColorGradingEnabled(): boolean;
  50820. /**
  50821. * Gets wether the color grading effect is enabled.
  50822. */
  50823. set cameraColorGradingEnabled(value: boolean);
  50824. /**
  50825. * Gets wether tonemapping is enabled or not.
  50826. */
  50827. get cameraToneMappingEnabled(): boolean;
  50828. /**
  50829. * Sets wether tonemapping is enabled or not
  50830. */
  50831. set cameraToneMappingEnabled(value: boolean);
  50832. /**
  50833. * The camera exposure used on this material.
  50834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50835. * This corresponds to a photographic exposure.
  50836. */
  50837. get cameraExposure(): number;
  50838. /**
  50839. * The camera exposure used on this material.
  50840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50841. * This corresponds to a photographic exposure.
  50842. */
  50843. set cameraExposure(value: number);
  50844. /**
  50845. * Gets The camera contrast used on this material.
  50846. */
  50847. get cameraContrast(): number;
  50848. /**
  50849. * Sets The camera contrast used on this material.
  50850. */
  50851. set cameraContrast(value: number);
  50852. /**
  50853. * Gets the Color Grading 2D Lookup Texture.
  50854. */
  50855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50856. /**
  50857. * Sets the Color Grading 2D Lookup Texture.
  50858. */
  50859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50860. /**
  50861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50863. * 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;
  50864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50865. */
  50866. get cameraColorCurves(): Nullable<ColorCurves>;
  50867. /**
  50868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50870. * 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;
  50871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50872. */
  50873. set cameraColorCurves(value: Nullable<ColorCurves>);
  50874. /**
  50875. * Instantiates a new PBRMaterial instance.
  50876. *
  50877. * @param name The material name
  50878. * @param scene The scene the material will be use in.
  50879. */
  50880. constructor(name: string, scene: Scene);
  50881. /**
  50882. * Returns the name of this material class.
  50883. */
  50884. getClassName(): string;
  50885. /**
  50886. * Makes a duplicate of the current material.
  50887. * @param name - name to use for the new material.
  50888. */
  50889. clone(name: string): PBRMaterial;
  50890. /**
  50891. * Serializes this PBR Material.
  50892. * @returns - An object with the serialized material.
  50893. */
  50894. serialize(): any;
  50895. /**
  50896. * Parses a PBR Material from a serialized object.
  50897. * @param source - Serialized object.
  50898. * @param scene - BJS scene instance.
  50899. * @param rootUrl - url for the scene object
  50900. * @returns - PBRMaterial
  50901. */
  50902. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50903. }
  50904. }
  50905. declare module BABYLON {
  50906. /**
  50907. * Direct draw surface info
  50908. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50909. */
  50910. export interface DDSInfo {
  50911. /**
  50912. * Width of the texture
  50913. */
  50914. width: number;
  50915. /**
  50916. * Width of the texture
  50917. */
  50918. height: number;
  50919. /**
  50920. * Number of Mipmaps for the texture
  50921. * @see https://en.wikipedia.org/wiki/Mipmap
  50922. */
  50923. mipmapCount: number;
  50924. /**
  50925. * If the textures format is a known fourCC format
  50926. * @see https://www.fourcc.org/
  50927. */
  50928. isFourCC: boolean;
  50929. /**
  50930. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50931. */
  50932. isRGB: boolean;
  50933. /**
  50934. * If the texture is a lumincance format
  50935. */
  50936. isLuminance: boolean;
  50937. /**
  50938. * If this is a cube texture
  50939. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50940. */
  50941. isCube: boolean;
  50942. /**
  50943. * If the texture is a compressed format eg. FOURCC_DXT1
  50944. */
  50945. isCompressed: boolean;
  50946. /**
  50947. * The dxgiFormat of the texture
  50948. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50949. */
  50950. dxgiFormat: number;
  50951. /**
  50952. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50953. */
  50954. textureType: number;
  50955. /**
  50956. * Sphericle polynomial created for the dds texture
  50957. */
  50958. sphericalPolynomial?: SphericalPolynomial;
  50959. }
  50960. /**
  50961. * Class used to provide DDS decompression tools
  50962. */
  50963. export class DDSTools {
  50964. /**
  50965. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50966. */
  50967. static StoreLODInAlphaChannel: boolean;
  50968. /**
  50969. * Gets DDS information from an array buffer
  50970. * @param arrayBuffer defines the array buffer to read data from
  50971. * @returns the DDS information
  50972. */
  50973. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50974. private static _FloatView;
  50975. private static _Int32View;
  50976. private static _ToHalfFloat;
  50977. private static _FromHalfFloat;
  50978. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50979. private static _GetHalfFloatRGBAArrayBuffer;
  50980. private static _GetFloatRGBAArrayBuffer;
  50981. private static _GetFloatAsUIntRGBAArrayBuffer;
  50982. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50983. private static _GetRGBAArrayBuffer;
  50984. private static _ExtractLongWordOrder;
  50985. private static _GetRGBArrayBuffer;
  50986. private static _GetLuminanceArrayBuffer;
  50987. /**
  50988. * Uploads DDS Levels to a Babylon Texture
  50989. * @hidden
  50990. */
  50991. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50992. }
  50993. interface ThinEngine {
  50994. /**
  50995. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50996. * @param rootUrl defines the url where the file to load is located
  50997. * @param scene defines the current scene
  50998. * @param lodScale defines scale to apply to the mip map selection
  50999. * @param lodOffset defines offset to apply to the mip map selection
  51000. * @param onLoad defines an optional callback raised when the texture is loaded
  51001. * @param onError defines an optional callback raised if there is an issue to load the texture
  51002. * @param format defines the format of the data
  51003. * @param forcedExtension defines the extension to use to pick the right loader
  51004. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51005. * @returns the cube texture as an InternalTexture
  51006. */
  51007. 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;
  51008. }
  51009. }
  51010. declare module BABYLON {
  51011. /**
  51012. * Implementation of the DDS Texture Loader.
  51013. * @hidden
  51014. */
  51015. export class _DDSTextureLoader implements IInternalTextureLoader {
  51016. /**
  51017. * Defines wether the loader supports cascade loading the different faces.
  51018. */
  51019. readonly supportCascades: boolean;
  51020. /**
  51021. * This returns if the loader support the current file information.
  51022. * @param extension defines the file extension of the file being loaded
  51023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51024. * @param fallback defines the fallback internal texture if any
  51025. * @param isBase64 defines whether the texture is encoded as a base64
  51026. * @param isBuffer defines whether the texture data are stored as a buffer
  51027. * @returns true if the loader can load the specified file
  51028. */
  51029. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51030. /**
  51031. * Transform the url before loading if required.
  51032. * @param rootUrl the url of the texture
  51033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51034. * @returns the transformed texture
  51035. */
  51036. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51037. /**
  51038. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51039. * @param rootUrl the url of the texture
  51040. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51041. * @returns the fallback texture
  51042. */
  51043. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51044. /**
  51045. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51046. * @param data contains the texture data
  51047. * @param texture defines the BabylonJS internal texture
  51048. * @param createPolynomials will be true if polynomials have been requested
  51049. * @param onLoad defines the callback to trigger once the texture is ready
  51050. * @param onError defines the callback to trigger in case of error
  51051. */
  51052. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51053. /**
  51054. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51055. * @param data contains the texture data
  51056. * @param texture defines the BabylonJS internal texture
  51057. * @param callback defines the method to call once ready to upload
  51058. */
  51059. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51060. }
  51061. }
  51062. declare module BABYLON {
  51063. /**
  51064. * Implementation of the ENV Texture Loader.
  51065. * @hidden
  51066. */
  51067. export class _ENVTextureLoader implements IInternalTextureLoader {
  51068. /**
  51069. * Defines wether the loader supports cascade loading the different faces.
  51070. */
  51071. readonly supportCascades: boolean;
  51072. /**
  51073. * This returns if the loader support the current file information.
  51074. * @param extension defines the file extension of the file being loaded
  51075. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51076. * @param fallback defines the fallback internal texture if any
  51077. * @param isBase64 defines whether the texture is encoded as a base64
  51078. * @param isBuffer defines whether the texture data are stored as a buffer
  51079. * @returns true if the loader can load the specified file
  51080. */
  51081. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51082. /**
  51083. * Transform the url before loading if required.
  51084. * @param rootUrl the url of the texture
  51085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51086. * @returns the transformed texture
  51087. */
  51088. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51089. /**
  51090. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51091. * @param rootUrl the url of the texture
  51092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51093. * @returns the fallback texture
  51094. */
  51095. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51096. /**
  51097. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51098. * @param data contains the texture data
  51099. * @param texture defines the BabylonJS internal texture
  51100. * @param createPolynomials will be true if polynomials have been requested
  51101. * @param onLoad defines the callback to trigger once the texture is ready
  51102. * @param onError defines the callback to trigger in case of error
  51103. */
  51104. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51105. /**
  51106. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51107. * @param data contains the texture data
  51108. * @param texture defines the BabylonJS internal texture
  51109. * @param callback defines the method to call once ready to upload
  51110. */
  51111. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51112. }
  51113. }
  51114. declare module BABYLON {
  51115. /**
  51116. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51117. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51118. */
  51119. export class KhronosTextureContainer {
  51120. /** contents of the KTX container file */
  51121. arrayBuffer: any;
  51122. private static HEADER_LEN;
  51123. private static COMPRESSED_2D;
  51124. private static COMPRESSED_3D;
  51125. private static TEX_2D;
  51126. private static TEX_3D;
  51127. /**
  51128. * Gets the openGL type
  51129. */
  51130. glType: number;
  51131. /**
  51132. * Gets the openGL type size
  51133. */
  51134. glTypeSize: number;
  51135. /**
  51136. * Gets the openGL format
  51137. */
  51138. glFormat: number;
  51139. /**
  51140. * Gets the openGL internal format
  51141. */
  51142. glInternalFormat: number;
  51143. /**
  51144. * Gets the base internal format
  51145. */
  51146. glBaseInternalFormat: number;
  51147. /**
  51148. * Gets image width in pixel
  51149. */
  51150. pixelWidth: number;
  51151. /**
  51152. * Gets image height in pixel
  51153. */
  51154. pixelHeight: number;
  51155. /**
  51156. * Gets image depth in pixels
  51157. */
  51158. pixelDepth: number;
  51159. /**
  51160. * Gets the number of array elements
  51161. */
  51162. numberOfArrayElements: number;
  51163. /**
  51164. * Gets the number of faces
  51165. */
  51166. numberOfFaces: number;
  51167. /**
  51168. * Gets the number of mipmap levels
  51169. */
  51170. numberOfMipmapLevels: number;
  51171. /**
  51172. * Gets the bytes of key value data
  51173. */
  51174. bytesOfKeyValueData: number;
  51175. /**
  51176. * Gets the load type
  51177. */
  51178. loadType: number;
  51179. /**
  51180. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51181. */
  51182. isInvalid: boolean;
  51183. /**
  51184. * Creates a new KhronosTextureContainer
  51185. * @param arrayBuffer contents of the KTX container file
  51186. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51187. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51188. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51189. */
  51190. constructor(
  51191. /** contents of the KTX container file */
  51192. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51193. /**
  51194. * Uploads KTX content to a Babylon Texture.
  51195. * It is assumed that the texture has already been created & is currently bound
  51196. * @hidden
  51197. */
  51198. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51199. private _upload2DCompressedLevels;
  51200. }
  51201. }
  51202. declare module BABYLON {
  51203. /**
  51204. * Implementation of the KTX Texture Loader.
  51205. * @hidden
  51206. */
  51207. export class _KTXTextureLoader implements IInternalTextureLoader {
  51208. /**
  51209. * Defines wether the loader supports cascade loading the different faces.
  51210. */
  51211. readonly supportCascades: boolean;
  51212. /**
  51213. * This returns if the loader support the current file information.
  51214. * @param extension defines the file extension of the file being loaded
  51215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51216. * @param fallback defines the fallback internal texture if any
  51217. * @param isBase64 defines whether the texture is encoded as a base64
  51218. * @param isBuffer defines whether the texture data are stored as a buffer
  51219. * @returns true if the loader can load the specified file
  51220. */
  51221. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51222. /**
  51223. * Transform the url before loading if required.
  51224. * @param rootUrl the url of the texture
  51225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51226. * @returns the transformed texture
  51227. */
  51228. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51229. /**
  51230. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51231. * @param rootUrl the url of the texture
  51232. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51233. * @returns the fallback texture
  51234. */
  51235. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51236. /**
  51237. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51238. * @param data contains the texture data
  51239. * @param texture defines the BabylonJS internal texture
  51240. * @param createPolynomials will be true if polynomials have been requested
  51241. * @param onLoad defines the callback to trigger once the texture is ready
  51242. * @param onError defines the callback to trigger in case of error
  51243. */
  51244. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51245. /**
  51246. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51247. * @param data contains the texture data
  51248. * @param texture defines the BabylonJS internal texture
  51249. * @param callback defines the method to call once ready to upload
  51250. */
  51251. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51252. }
  51253. }
  51254. declare module BABYLON {
  51255. /** @hidden */
  51256. export var _forceSceneHelpersToBundle: boolean;
  51257. interface Scene {
  51258. /**
  51259. * Creates a default light for the scene.
  51260. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51261. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51262. */
  51263. createDefaultLight(replace?: boolean): void;
  51264. /**
  51265. * Creates a default camera for the scene.
  51266. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51267. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51268. * @param replace has default false, when true replaces the active camera in the scene
  51269. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51270. */
  51271. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51272. /**
  51273. * Creates a default camera and a default light.
  51274. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51275. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51276. * @param replace has the default false, when true replaces the active camera/light in the scene
  51277. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51278. */
  51279. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51280. /**
  51281. * Creates a new sky box
  51282. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51283. * @param environmentTexture defines the texture to use as environment texture
  51284. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51285. * @param scale defines the overall scale of the skybox
  51286. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51287. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51288. * @returns a new mesh holding the sky box
  51289. */
  51290. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51291. /**
  51292. * Creates a new environment
  51293. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51294. * @param options defines the options you can use to configure the environment
  51295. * @returns the new EnvironmentHelper
  51296. */
  51297. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51298. /**
  51299. * Creates a new VREXperienceHelper
  51300. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51301. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51302. * @returns a new VREXperienceHelper
  51303. */
  51304. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51305. /**
  51306. * Creates a new WebXRDefaultExperience
  51307. * @see http://doc.babylonjs.com/how_to/webxr
  51308. * @param options experience options
  51309. * @returns a promise for a new WebXRDefaultExperience
  51310. */
  51311. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51312. }
  51313. }
  51314. declare module BABYLON {
  51315. /**
  51316. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51317. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51318. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51319. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51320. */
  51321. export class VideoDome extends TransformNode {
  51322. /**
  51323. * Define the video source as a Monoscopic panoramic 360 video.
  51324. */
  51325. static readonly MODE_MONOSCOPIC: number;
  51326. /**
  51327. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51328. */
  51329. static readonly MODE_TOPBOTTOM: number;
  51330. /**
  51331. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51332. */
  51333. static readonly MODE_SIDEBYSIDE: number;
  51334. private _halfDome;
  51335. private _useDirectMapping;
  51336. /**
  51337. * The video texture being displayed on the sphere
  51338. */
  51339. protected _videoTexture: VideoTexture;
  51340. /**
  51341. * Gets the video texture being displayed on the sphere
  51342. */
  51343. get videoTexture(): VideoTexture;
  51344. /**
  51345. * The skybox material
  51346. */
  51347. protected _material: BackgroundMaterial;
  51348. /**
  51349. * The surface used for the skybox
  51350. */
  51351. protected _mesh: Mesh;
  51352. /**
  51353. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51354. */
  51355. private _halfDomeMask;
  51356. /**
  51357. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51358. * Also see the options.resolution property.
  51359. */
  51360. get fovMultiplier(): number;
  51361. set fovMultiplier(value: number);
  51362. private _videoMode;
  51363. /**
  51364. * Gets or set the current video mode for the video. It can be:
  51365. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51366. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51367. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51368. */
  51369. get videoMode(): number;
  51370. set videoMode(value: number);
  51371. /**
  51372. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51373. *
  51374. */
  51375. get halfDome(): boolean;
  51376. /**
  51377. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51378. */
  51379. set halfDome(enabled: boolean);
  51380. /**
  51381. * Oberserver used in Stereoscopic VR Mode.
  51382. */
  51383. private _onBeforeCameraRenderObserver;
  51384. /**
  51385. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51386. * @param name Element's name, child elements will append suffixes for their own names.
  51387. * @param urlsOrVideo defines the url(s) or the video element to use
  51388. * @param options An object containing optional or exposed sub element properties
  51389. */
  51390. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51391. resolution?: number;
  51392. clickToPlay?: boolean;
  51393. autoPlay?: boolean;
  51394. loop?: boolean;
  51395. size?: number;
  51396. poster?: string;
  51397. faceForward?: boolean;
  51398. useDirectMapping?: boolean;
  51399. halfDomeMode?: boolean;
  51400. }, scene: Scene);
  51401. private _changeVideoMode;
  51402. /**
  51403. * Releases resources associated with this node.
  51404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51406. */
  51407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51408. }
  51409. }
  51410. declare module BABYLON {
  51411. /**
  51412. * This class can be used to get instrumentation data from a Babylon engine
  51413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51414. */
  51415. export class EngineInstrumentation implements IDisposable {
  51416. /**
  51417. * Define the instrumented engine.
  51418. */
  51419. engine: Engine;
  51420. private _captureGPUFrameTime;
  51421. private _gpuFrameTimeToken;
  51422. private _gpuFrameTime;
  51423. private _captureShaderCompilationTime;
  51424. private _shaderCompilationTime;
  51425. private _onBeginFrameObserver;
  51426. private _onEndFrameObserver;
  51427. private _onBeforeShaderCompilationObserver;
  51428. private _onAfterShaderCompilationObserver;
  51429. /**
  51430. * Gets the perf counter used for GPU frame time
  51431. */
  51432. get gpuFrameTimeCounter(): PerfCounter;
  51433. /**
  51434. * Gets the GPU frame time capture status
  51435. */
  51436. get captureGPUFrameTime(): boolean;
  51437. /**
  51438. * Enable or disable the GPU frame time capture
  51439. */
  51440. set captureGPUFrameTime(value: boolean);
  51441. /**
  51442. * Gets the perf counter used for shader compilation time
  51443. */
  51444. get shaderCompilationTimeCounter(): PerfCounter;
  51445. /**
  51446. * Gets the shader compilation time capture status
  51447. */
  51448. get captureShaderCompilationTime(): boolean;
  51449. /**
  51450. * Enable or disable the shader compilation time capture
  51451. */
  51452. set captureShaderCompilationTime(value: boolean);
  51453. /**
  51454. * Instantiates a new engine instrumentation.
  51455. * This class can be used to get instrumentation data from a Babylon engine
  51456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51457. * @param engine Defines the engine to instrument
  51458. */
  51459. constructor(
  51460. /**
  51461. * Define the instrumented engine.
  51462. */
  51463. engine: Engine);
  51464. /**
  51465. * Dispose and release associated resources.
  51466. */
  51467. dispose(): void;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * This class can be used to get instrumentation data from a Babylon engine
  51473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51474. */
  51475. export class SceneInstrumentation implements IDisposable {
  51476. /**
  51477. * Defines the scene to instrument
  51478. */
  51479. scene: Scene;
  51480. private _captureActiveMeshesEvaluationTime;
  51481. private _activeMeshesEvaluationTime;
  51482. private _captureRenderTargetsRenderTime;
  51483. private _renderTargetsRenderTime;
  51484. private _captureFrameTime;
  51485. private _frameTime;
  51486. private _captureRenderTime;
  51487. private _renderTime;
  51488. private _captureInterFrameTime;
  51489. private _interFrameTime;
  51490. private _captureParticlesRenderTime;
  51491. private _particlesRenderTime;
  51492. private _captureSpritesRenderTime;
  51493. private _spritesRenderTime;
  51494. private _capturePhysicsTime;
  51495. private _physicsTime;
  51496. private _captureAnimationsTime;
  51497. private _animationsTime;
  51498. private _captureCameraRenderTime;
  51499. private _cameraRenderTime;
  51500. private _onBeforeActiveMeshesEvaluationObserver;
  51501. private _onAfterActiveMeshesEvaluationObserver;
  51502. private _onBeforeRenderTargetsRenderObserver;
  51503. private _onAfterRenderTargetsRenderObserver;
  51504. private _onAfterRenderObserver;
  51505. private _onBeforeDrawPhaseObserver;
  51506. private _onAfterDrawPhaseObserver;
  51507. private _onBeforeAnimationsObserver;
  51508. private _onBeforeParticlesRenderingObserver;
  51509. private _onAfterParticlesRenderingObserver;
  51510. private _onBeforeSpritesRenderingObserver;
  51511. private _onAfterSpritesRenderingObserver;
  51512. private _onBeforePhysicsObserver;
  51513. private _onAfterPhysicsObserver;
  51514. private _onAfterAnimationsObserver;
  51515. private _onBeforeCameraRenderObserver;
  51516. private _onAfterCameraRenderObserver;
  51517. /**
  51518. * Gets the perf counter used for active meshes evaluation time
  51519. */
  51520. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51521. /**
  51522. * Gets the active meshes evaluation time capture status
  51523. */
  51524. get captureActiveMeshesEvaluationTime(): boolean;
  51525. /**
  51526. * Enable or disable the active meshes evaluation time capture
  51527. */
  51528. set captureActiveMeshesEvaluationTime(value: boolean);
  51529. /**
  51530. * Gets the perf counter used for render targets render time
  51531. */
  51532. get renderTargetsRenderTimeCounter(): PerfCounter;
  51533. /**
  51534. * Gets the render targets render time capture status
  51535. */
  51536. get captureRenderTargetsRenderTime(): boolean;
  51537. /**
  51538. * Enable or disable the render targets render time capture
  51539. */
  51540. set captureRenderTargetsRenderTime(value: boolean);
  51541. /**
  51542. * Gets the perf counter used for particles render time
  51543. */
  51544. get particlesRenderTimeCounter(): PerfCounter;
  51545. /**
  51546. * Gets the particles render time capture status
  51547. */
  51548. get captureParticlesRenderTime(): boolean;
  51549. /**
  51550. * Enable or disable the particles render time capture
  51551. */
  51552. set captureParticlesRenderTime(value: boolean);
  51553. /**
  51554. * Gets the perf counter used for sprites render time
  51555. */
  51556. get spritesRenderTimeCounter(): PerfCounter;
  51557. /**
  51558. * Gets the sprites render time capture status
  51559. */
  51560. get captureSpritesRenderTime(): boolean;
  51561. /**
  51562. * Enable or disable the sprites render time capture
  51563. */
  51564. set captureSpritesRenderTime(value: boolean);
  51565. /**
  51566. * Gets the perf counter used for physics time
  51567. */
  51568. get physicsTimeCounter(): PerfCounter;
  51569. /**
  51570. * Gets the physics time capture status
  51571. */
  51572. get capturePhysicsTime(): boolean;
  51573. /**
  51574. * Enable or disable the physics time capture
  51575. */
  51576. set capturePhysicsTime(value: boolean);
  51577. /**
  51578. * Gets the perf counter used for animations time
  51579. */
  51580. get animationsTimeCounter(): PerfCounter;
  51581. /**
  51582. * Gets the animations time capture status
  51583. */
  51584. get captureAnimationsTime(): boolean;
  51585. /**
  51586. * Enable or disable the animations time capture
  51587. */
  51588. set captureAnimationsTime(value: boolean);
  51589. /**
  51590. * Gets the perf counter used for frame time capture
  51591. */
  51592. get frameTimeCounter(): PerfCounter;
  51593. /**
  51594. * Gets the frame time capture status
  51595. */
  51596. get captureFrameTime(): boolean;
  51597. /**
  51598. * Enable or disable the frame time capture
  51599. */
  51600. set captureFrameTime(value: boolean);
  51601. /**
  51602. * Gets the perf counter used for inter-frames time capture
  51603. */
  51604. get interFrameTimeCounter(): PerfCounter;
  51605. /**
  51606. * Gets the inter-frames time capture status
  51607. */
  51608. get captureInterFrameTime(): boolean;
  51609. /**
  51610. * Enable or disable the inter-frames time capture
  51611. */
  51612. set captureInterFrameTime(value: boolean);
  51613. /**
  51614. * Gets the perf counter used for render time capture
  51615. */
  51616. get renderTimeCounter(): PerfCounter;
  51617. /**
  51618. * Gets the render time capture status
  51619. */
  51620. get captureRenderTime(): boolean;
  51621. /**
  51622. * Enable or disable the render time capture
  51623. */
  51624. set captureRenderTime(value: boolean);
  51625. /**
  51626. * Gets the perf counter used for camera render time capture
  51627. */
  51628. get cameraRenderTimeCounter(): PerfCounter;
  51629. /**
  51630. * Gets the camera render time capture status
  51631. */
  51632. get captureCameraRenderTime(): boolean;
  51633. /**
  51634. * Enable or disable the camera render time capture
  51635. */
  51636. set captureCameraRenderTime(value: boolean);
  51637. /**
  51638. * Gets the perf counter used for draw calls
  51639. */
  51640. get drawCallsCounter(): PerfCounter;
  51641. /**
  51642. * Instantiates a new scene instrumentation.
  51643. * This class can be used to get instrumentation data from a Babylon engine
  51644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51645. * @param scene Defines the scene to instrument
  51646. */
  51647. constructor(
  51648. /**
  51649. * Defines the scene to instrument
  51650. */
  51651. scene: Scene);
  51652. /**
  51653. * Dispose and release associated resources.
  51654. */
  51655. dispose(): void;
  51656. }
  51657. }
  51658. declare module BABYLON {
  51659. /** @hidden */
  51660. export var glowMapGenerationPixelShader: {
  51661. name: string;
  51662. shader: string;
  51663. };
  51664. }
  51665. declare module BABYLON {
  51666. /** @hidden */
  51667. export var glowMapGenerationVertexShader: {
  51668. name: string;
  51669. shader: string;
  51670. };
  51671. }
  51672. declare module BABYLON {
  51673. /**
  51674. * Effect layer options. This helps customizing the behaviour
  51675. * of the effect layer.
  51676. */
  51677. export interface IEffectLayerOptions {
  51678. /**
  51679. * Multiplication factor apply to the canvas size to compute the render target size
  51680. * used to generated the objects (the smaller the faster).
  51681. */
  51682. mainTextureRatio: number;
  51683. /**
  51684. * Enforces a fixed size texture to ensure effect stability across devices.
  51685. */
  51686. mainTextureFixedSize?: number;
  51687. /**
  51688. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51689. */
  51690. alphaBlendingMode: number;
  51691. /**
  51692. * The camera attached to the layer.
  51693. */
  51694. camera: Nullable<Camera>;
  51695. /**
  51696. * The rendering group to draw the layer in.
  51697. */
  51698. renderingGroupId: number;
  51699. }
  51700. /**
  51701. * The effect layer Helps adding post process effect blended with the main pass.
  51702. *
  51703. * This can be for instance use to generate glow or higlight effects on the scene.
  51704. *
  51705. * The effect layer class can not be used directly and is intented to inherited from to be
  51706. * customized per effects.
  51707. */
  51708. export abstract class EffectLayer {
  51709. private _vertexBuffers;
  51710. private _indexBuffer;
  51711. private _cachedDefines;
  51712. private _effectLayerMapGenerationEffect;
  51713. private _effectLayerOptions;
  51714. private _mergeEffect;
  51715. protected _scene: Scene;
  51716. protected _engine: Engine;
  51717. protected _maxSize: number;
  51718. protected _mainTextureDesiredSize: ISize;
  51719. protected _mainTexture: RenderTargetTexture;
  51720. protected _shouldRender: boolean;
  51721. protected _postProcesses: PostProcess[];
  51722. protected _textures: BaseTexture[];
  51723. protected _emissiveTextureAndColor: {
  51724. texture: Nullable<BaseTexture>;
  51725. color: Color4;
  51726. };
  51727. /**
  51728. * The name of the layer
  51729. */
  51730. name: string;
  51731. /**
  51732. * The clear color of the texture used to generate the glow map.
  51733. */
  51734. neutralColor: Color4;
  51735. /**
  51736. * Specifies wether the highlight layer is enabled or not.
  51737. */
  51738. isEnabled: boolean;
  51739. /**
  51740. * Gets the camera attached to the layer.
  51741. */
  51742. get camera(): Nullable<Camera>;
  51743. /**
  51744. * Gets the rendering group id the layer should render in.
  51745. */
  51746. get renderingGroupId(): number;
  51747. set renderingGroupId(renderingGroupId: number);
  51748. /**
  51749. * An event triggered when the effect layer has been disposed.
  51750. */
  51751. onDisposeObservable: Observable<EffectLayer>;
  51752. /**
  51753. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51754. */
  51755. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51756. /**
  51757. * An event triggered when the generated texture is being merged in the scene.
  51758. */
  51759. onBeforeComposeObservable: Observable<EffectLayer>;
  51760. /**
  51761. * An event triggered when the mesh is rendered into the effect render target.
  51762. */
  51763. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51764. /**
  51765. * An event triggered after the mesh has been rendered into the effect render target.
  51766. */
  51767. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51768. /**
  51769. * An event triggered when the generated texture has been merged in the scene.
  51770. */
  51771. onAfterComposeObservable: Observable<EffectLayer>;
  51772. /**
  51773. * An event triggered when the efffect layer changes its size.
  51774. */
  51775. onSizeChangedObservable: Observable<EffectLayer>;
  51776. /** @hidden */
  51777. static _SceneComponentInitialization: (scene: Scene) => void;
  51778. /**
  51779. * Instantiates a new effect Layer and references it in the scene.
  51780. * @param name The name of the layer
  51781. * @param scene The scene to use the layer in
  51782. */
  51783. constructor(
  51784. /** The Friendly of the effect in the scene */
  51785. name: string, scene: Scene);
  51786. /**
  51787. * Get the effect name of the layer.
  51788. * @return The effect name
  51789. */
  51790. abstract getEffectName(): string;
  51791. /**
  51792. * Checks for the readiness of the element composing the layer.
  51793. * @param subMesh the mesh to check for
  51794. * @param useInstances specify wether or not to use instances to render the mesh
  51795. * @return true if ready otherwise, false
  51796. */
  51797. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51798. /**
  51799. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51800. * @returns true if the effect requires stencil during the main canvas render pass.
  51801. */
  51802. abstract needStencil(): boolean;
  51803. /**
  51804. * Create the merge effect. This is the shader use to blit the information back
  51805. * to the main canvas at the end of the scene rendering.
  51806. * @returns The effect containing the shader used to merge the effect on the main canvas
  51807. */
  51808. protected abstract _createMergeEffect(): Effect;
  51809. /**
  51810. * Creates the render target textures and post processes used in the effect layer.
  51811. */
  51812. protected abstract _createTextureAndPostProcesses(): void;
  51813. /**
  51814. * Implementation specific of rendering the generating effect on the main canvas.
  51815. * @param effect The effect used to render through
  51816. */
  51817. protected abstract _internalRender(effect: Effect): void;
  51818. /**
  51819. * Sets the required values for both the emissive texture and and the main color.
  51820. */
  51821. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51822. /**
  51823. * Free any resources and references associated to a mesh.
  51824. * Internal use
  51825. * @param mesh The mesh to free.
  51826. */
  51827. abstract _disposeMesh(mesh: Mesh): void;
  51828. /**
  51829. * Serializes this layer (Glow or Highlight for example)
  51830. * @returns a serialized layer object
  51831. */
  51832. abstract serialize?(): any;
  51833. /**
  51834. * Initializes the effect layer with the required options.
  51835. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51836. */
  51837. protected _init(options: Partial<IEffectLayerOptions>): void;
  51838. /**
  51839. * Generates the index buffer of the full screen quad blending to the main canvas.
  51840. */
  51841. private _generateIndexBuffer;
  51842. /**
  51843. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51844. */
  51845. private _generateVertexBuffer;
  51846. /**
  51847. * Sets the main texture desired size which is the closest power of two
  51848. * of the engine canvas size.
  51849. */
  51850. private _setMainTextureSize;
  51851. /**
  51852. * Creates the main texture for the effect layer.
  51853. */
  51854. protected _createMainTexture(): void;
  51855. /**
  51856. * Adds specific effects defines.
  51857. * @param defines The defines to add specifics to.
  51858. */
  51859. protected _addCustomEffectDefines(defines: string[]): void;
  51860. /**
  51861. * Checks for the readiness of the element composing the layer.
  51862. * @param subMesh the mesh to check for
  51863. * @param useInstances specify wether or not to use instances to render the mesh
  51864. * @param emissiveTexture the associated emissive texture used to generate the glow
  51865. * @return true if ready otherwise, false
  51866. */
  51867. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51868. /**
  51869. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51870. */
  51871. render(): void;
  51872. /**
  51873. * Determine if a given mesh will be used in the current effect.
  51874. * @param mesh mesh to test
  51875. * @returns true if the mesh will be used
  51876. */
  51877. hasMesh(mesh: AbstractMesh): boolean;
  51878. /**
  51879. * Returns true if the layer contains information to display, otherwise false.
  51880. * @returns true if the glow layer should be rendered
  51881. */
  51882. shouldRender(): boolean;
  51883. /**
  51884. * Returns true if the mesh should render, otherwise false.
  51885. * @param mesh The mesh to render
  51886. * @returns true if it should render otherwise false
  51887. */
  51888. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51889. /**
  51890. * Returns true if the mesh can be rendered, otherwise false.
  51891. * @param mesh The mesh to render
  51892. * @param material The material used on the mesh
  51893. * @returns true if it can be rendered otherwise false
  51894. */
  51895. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51896. /**
  51897. * Returns true if the mesh should render, otherwise false.
  51898. * @param mesh The mesh to render
  51899. * @returns true if it should render otherwise false
  51900. */
  51901. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51902. /**
  51903. * Renders the submesh passed in parameter to the generation map.
  51904. */
  51905. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51906. /**
  51907. * Defines wether the current material of the mesh should be use to render the effect.
  51908. * @param mesh defines the current mesh to render
  51909. */
  51910. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51911. /**
  51912. * Rebuild the required buffers.
  51913. * @hidden Internal use only.
  51914. */
  51915. _rebuild(): void;
  51916. /**
  51917. * Dispose only the render target textures and post process.
  51918. */
  51919. private _disposeTextureAndPostProcesses;
  51920. /**
  51921. * Dispose the highlight layer and free resources.
  51922. */
  51923. dispose(): void;
  51924. /**
  51925. * Gets the class name of the effect layer
  51926. * @returns the string with the class name of the effect layer
  51927. */
  51928. getClassName(): string;
  51929. /**
  51930. * Creates an effect layer from parsed effect layer data
  51931. * @param parsedEffectLayer defines effect layer data
  51932. * @param scene defines the current scene
  51933. * @param rootUrl defines the root URL containing the effect layer information
  51934. * @returns a parsed effect Layer
  51935. */
  51936. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51937. }
  51938. }
  51939. declare module BABYLON {
  51940. interface AbstractScene {
  51941. /**
  51942. * The list of effect layers (highlights/glow) added to the scene
  51943. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51944. * @see http://doc.babylonjs.com/how_to/glow_layer
  51945. */
  51946. effectLayers: Array<EffectLayer>;
  51947. /**
  51948. * Removes the given effect layer from this scene.
  51949. * @param toRemove defines the effect layer to remove
  51950. * @returns the index of the removed effect layer
  51951. */
  51952. removeEffectLayer(toRemove: EffectLayer): number;
  51953. /**
  51954. * Adds the given effect layer to this scene
  51955. * @param newEffectLayer defines the effect layer to add
  51956. */
  51957. addEffectLayer(newEffectLayer: EffectLayer): void;
  51958. }
  51959. /**
  51960. * Defines the layer scene component responsible to manage any effect layers
  51961. * in a given scene.
  51962. */
  51963. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51964. /**
  51965. * The component name helpfull to identify the component in the list of scene components.
  51966. */
  51967. readonly name: string;
  51968. /**
  51969. * The scene the component belongs to.
  51970. */
  51971. scene: Scene;
  51972. private _engine;
  51973. private _renderEffects;
  51974. private _needStencil;
  51975. private _previousStencilState;
  51976. /**
  51977. * Creates a new instance of the component for the given scene
  51978. * @param scene Defines the scene to register the component in
  51979. */
  51980. constructor(scene: Scene);
  51981. /**
  51982. * Registers the component in a given scene
  51983. */
  51984. register(): void;
  51985. /**
  51986. * Rebuilds the elements related to this component in case of
  51987. * context lost for instance.
  51988. */
  51989. rebuild(): void;
  51990. /**
  51991. * Serializes the component data to the specified json object
  51992. * @param serializationObject The object to serialize to
  51993. */
  51994. serialize(serializationObject: any): void;
  51995. /**
  51996. * Adds all the elements from the container to the scene
  51997. * @param container the container holding the elements
  51998. */
  51999. addFromContainer(container: AbstractScene): void;
  52000. /**
  52001. * Removes all the elements in the container from the scene
  52002. * @param container contains the elements to remove
  52003. * @param dispose if the removed element should be disposed (default: false)
  52004. */
  52005. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52006. /**
  52007. * Disposes the component and the associated ressources.
  52008. */
  52009. dispose(): void;
  52010. private _isReadyForMesh;
  52011. private _renderMainTexture;
  52012. private _setStencil;
  52013. private _setStencilBack;
  52014. private _draw;
  52015. private _drawCamera;
  52016. private _drawRenderingGroup;
  52017. }
  52018. }
  52019. declare module BABYLON {
  52020. /** @hidden */
  52021. export var glowMapMergePixelShader: {
  52022. name: string;
  52023. shader: string;
  52024. };
  52025. }
  52026. declare module BABYLON {
  52027. /** @hidden */
  52028. export var glowMapMergeVertexShader: {
  52029. name: string;
  52030. shader: string;
  52031. };
  52032. }
  52033. declare module BABYLON {
  52034. interface AbstractScene {
  52035. /**
  52036. * Return a the first highlight layer of the scene with a given name.
  52037. * @param name The name of the highlight layer to look for.
  52038. * @return The highlight layer if found otherwise null.
  52039. */
  52040. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52041. }
  52042. /**
  52043. * Glow layer options. This helps customizing the behaviour
  52044. * of the glow layer.
  52045. */
  52046. export interface IGlowLayerOptions {
  52047. /**
  52048. * Multiplication factor apply to the canvas size to compute the render target size
  52049. * used to generated the glowing objects (the smaller the faster).
  52050. */
  52051. mainTextureRatio: number;
  52052. /**
  52053. * Enforces a fixed size texture to ensure resize independant blur.
  52054. */
  52055. mainTextureFixedSize?: number;
  52056. /**
  52057. * How big is the kernel of the blur texture.
  52058. */
  52059. blurKernelSize: number;
  52060. /**
  52061. * The camera attached to the layer.
  52062. */
  52063. camera: Nullable<Camera>;
  52064. /**
  52065. * Enable MSAA by chosing the number of samples.
  52066. */
  52067. mainTextureSamples?: number;
  52068. /**
  52069. * The rendering group to draw the layer in.
  52070. */
  52071. renderingGroupId: number;
  52072. }
  52073. /**
  52074. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52075. *
  52076. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52077. *
  52078. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52079. */
  52080. export class GlowLayer extends EffectLayer {
  52081. /**
  52082. * Effect Name of the layer.
  52083. */
  52084. static readonly EffectName: string;
  52085. /**
  52086. * The default blur kernel size used for the glow.
  52087. */
  52088. static DefaultBlurKernelSize: number;
  52089. /**
  52090. * The default texture size ratio used for the glow.
  52091. */
  52092. static DefaultTextureRatio: number;
  52093. /**
  52094. * Sets the kernel size of the blur.
  52095. */
  52096. set blurKernelSize(value: number);
  52097. /**
  52098. * Gets the kernel size of the blur.
  52099. */
  52100. get blurKernelSize(): number;
  52101. /**
  52102. * Sets the glow intensity.
  52103. */
  52104. set intensity(value: number);
  52105. /**
  52106. * Gets the glow intensity.
  52107. */
  52108. get intensity(): number;
  52109. private _options;
  52110. private _intensity;
  52111. private _horizontalBlurPostprocess1;
  52112. private _verticalBlurPostprocess1;
  52113. private _horizontalBlurPostprocess2;
  52114. private _verticalBlurPostprocess2;
  52115. private _blurTexture1;
  52116. private _blurTexture2;
  52117. private _postProcesses1;
  52118. private _postProcesses2;
  52119. private _includedOnlyMeshes;
  52120. private _excludedMeshes;
  52121. private _meshesUsingTheirOwnMaterials;
  52122. /**
  52123. * Callback used to let the user override the color selection on a per mesh basis
  52124. */
  52125. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52126. /**
  52127. * Callback used to let the user override the texture selection on a per mesh basis
  52128. */
  52129. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52130. /**
  52131. * Instantiates a new glow Layer and references it to the scene.
  52132. * @param name The name of the layer
  52133. * @param scene The scene to use the layer in
  52134. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52135. */
  52136. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52137. /**
  52138. * Get the effect name of the layer.
  52139. * @return The effect name
  52140. */
  52141. getEffectName(): string;
  52142. /**
  52143. * Create the merge effect. This is the shader use to blit the information back
  52144. * to the main canvas at the end of the scene rendering.
  52145. */
  52146. protected _createMergeEffect(): Effect;
  52147. /**
  52148. * Creates the render target textures and post processes used in the glow layer.
  52149. */
  52150. protected _createTextureAndPostProcesses(): void;
  52151. /**
  52152. * Checks for the readiness of the element composing the layer.
  52153. * @param subMesh the mesh to check for
  52154. * @param useInstances specify wether or not to use instances to render the mesh
  52155. * @param emissiveTexture the associated emissive texture used to generate the glow
  52156. * @return true if ready otherwise, false
  52157. */
  52158. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52159. /**
  52160. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52161. */
  52162. needStencil(): boolean;
  52163. /**
  52164. * Returns true if the mesh can be rendered, otherwise false.
  52165. * @param mesh The mesh to render
  52166. * @param material The material used on the mesh
  52167. * @returns true if it can be rendered otherwise false
  52168. */
  52169. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52170. /**
  52171. * Implementation specific of rendering the generating effect on the main canvas.
  52172. * @param effect The effect used to render through
  52173. */
  52174. protected _internalRender(effect: Effect): void;
  52175. /**
  52176. * Sets the required values for both the emissive texture and and the main color.
  52177. */
  52178. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52179. /**
  52180. * Returns true if the mesh should render, otherwise false.
  52181. * @param mesh The mesh to render
  52182. * @returns true if it should render otherwise false
  52183. */
  52184. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52185. /**
  52186. * Adds specific effects defines.
  52187. * @param defines The defines to add specifics to.
  52188. */
  52189. protected _addCustomEffectDefines(defines: string[]): void;
  52190. /**
  52191. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52192. * @param mesh The mesh to exclude from the glow layer
  52193. */
  52194. addExcludedMesh(mesh: Mesh): void;
  52195. /**
  52196. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52197. * @param mesh The mesh to remove
  52198. */
  52199. removeExcludedMesh(mesh: Mesh): void;
  52200. /**
  52201. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52202. * @param mesh The mesh to include in the glow layer
  52203. */
  52204. addIncludedOnlyMesh(mesh: Mesh): void;
  52205. /**
  52206. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52207. * @param mesh The mesh to remove
  52208. */
  52209. removeIncludedOnlyMesh(mesh: Mesh): void;
  52210. /**
  52211. * Determine if a given mesh will be used in the glow layer
  52212. * @param mesh The mesh to test
  52213. * @returns true if the mesh will be highlighted by the current glow layer
  52214. */
  52215. hasMesh(mesh: AbstractMesh): boolean;
  52216. /**
  52217. * Defines wether the current material of the mesh should be use to render the effect.
  52218. * @param mesh defines the current mesh to render
  52219. */
  52220. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52221. /**
  52222. * Add a mesh to be rendered through its own material and not with emissive only.
  52223. * @param mesh The mesh for which we need to use its material
  52224. */
  52225. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52226. /**
  52227. * Remove a mesh from being rendered through its own material and not with emissive only.
  52228. * @param mesh The mesh for which we need to not use its material
  52229. */
  52230. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52231. /**
  52232. * Free any resources and references associated to a mesh.
  52233. * Internal use
  52234. * @param mesh The mesh to free.
  52235. * @hidden
  52236. */
  52237. _disposeMesh(mesh: Mesh): void;
  52238. /**
  52239. * Gets the class name of the effect layer
  52240. * @returns the string with the class name of the effect layer
  52241. */
  52242. getClassName(): string;
  52243. /**
  52244. * Serializes this glow layer
  52245. * @returns a serialized glow layer object
  52246. */
  52247. serialize(): any;
  52248. /**
  52249. * Creates a Glow Layer from parsed glow layer data
  52250. * @param parsedGlowLayer defines glow layer data
  52251. * @param scene defines the current scene
  52252. * @param rootUrl defines the root URL containing the glow layer information
  52253. * @returns a parsed Glow Layer
  52254. */
  52255. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52256. }
  52257. }
  52258. declare module BABYLON {
  52259. /** @hidden */
  52260. export var glowBlurPostProcessPixelShader: {
  52261. name: string;
  52262. shader: string;
  52263. };
  52264. }
  52265. declare module BABYLON {
  52266. interface AbstractScene {
  52267. /**
  52268. * Return a the first highlight layer of the scene with a given name.
  52269. * @param name The name of the highlight layer to look for.
  52270. * @return The highlight layer if found otherwise null.
  52271. */
  52272. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52273. }
  52274. /**
  52275. * Highlight layer options. This helps customizing the behaviour
  52276. * of the highlight layer.
  52277. */
  52278. export interface IHighlightLayerOptions {
  52279. /**
  52280. * Multiplication factor apply to the canvas size to compute the render target size
  52281. * used to generated the glowing objects (the smaller the faster).
  52282. */
  52283. mainTextureRatio: number;
  52284. /**
  52285. * Enforces a fixed size texture to ensure resize independant blur.
  52286. */
  52287. mainTextureFixedSize?: number;
  52288. /**
  52289. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52290. * of the picture to blur (the smaller the faster).
  52291. */
  52292. blurTextureSizeRatio: number;
  52293. /**
  52294. * How big in texel of the blur texture is the vertical blur.
  52295. */
  52296. blurVerticalSize: number;
  52297. /**
  52298. * How big in texel of the blur texture is the horizontal blur.
  52299. */
  52300. blurHorizontalSize: number;
  52301. /**
  52302. * Alpha blending mode used to apply the blur. Default is combine.
  52303. */
  52304. alphaBlendingMode: number;
  52305. /**
  52306. * The camera attached to the layer.
  52307. */
  52308. camera: Nullable<Camera>;
  52309. /**
  52310. * Should we display highlight as a solid stroke?
  52311. */
  52312. isStroke?: boolean;
  52313. /**
  52314. * The rendering group to draw the layer in.
  52315. */
  52316. renderingGroupId: number;
  52317. }
  52318. /**
  52319. * The highlight layer Helps adding a glow effect around a mesh.
  52320. *
  52321. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52322. * glowy meshes to your scene.
  52323. *
  52324. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52325. */
  52326. export class HighlightLayer extends EffectLayer {
  52327. name: string;
  52328. /**
  52329. * Effect Name of the highlight layer.
  52330. */
  52331. static readonly EffectName: string;
  52332. /**
  52333. * The neutral color used during the preparation of the glow effect.
  52334. * This is black by default as the blend operation is a blend operation.
  52335. */
  52336. static NeutralColor: Color4;
  52337. /**
  52338. * Stencil value used for glowing meshes.
  52339. */
  52340. static GlowingMeshStencilReference: number;
  52341. /**
  52342. * Stencil value used for the other meshes in the scene.
  52343. */
  52344. static NormalMeshStencilReference: number;
  52345. /**
  52346. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52347. */
  52348. innerGlow: boolean;
  52349. /**
  52350. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52351. */
  52352. outerGlow: boolean;
  52353. /**
  52354. * Specifies the horizontal size of the blur.
  52355. */
  52356. set blurHorizontalSize(value: number);
  52357. /**
  52358. * Specifies the vertical size of the blur.
  52359. */
  52360. set blurVerticalSize(value: number);
  52361. /**
  52362. * Gets the horizontal size of the blur.
  52363. */
  52364. get blurHorizontalSize(): number;
  52365. /**
  52366. * Gets the vertical size of the blur.
  52367. */
  52368. get blurVerticalSize(): number;
  52369. /**
  52370. * An event triggered when the highlight layer is being blurred.
  52371. */
  52372. onBeforeBlurObservable: Observable<HighlightLayer>;
  52373. /**
  52374. * An event triggered when the highlight layer has been blurred.
  52375. */
  52376. onAfterBlurObservable: Observable<HighlightLayer>;
  52377. private _instanceGlowingMeshStencilReference;
  52378. private _options;
  52379. private _downSamplePostprocess;
  52380. private _horizontalBlurPostprocess;
  52381. private _verticalBlurPostprocess;
  52382. private _blurTexture;
  52383. private _meshes;
  52384. private _excludedMeshes;
  52385. /**
  52386. * Instantiates a new highlight Layer and references it to the scene..
  52387. * @param name The name of the layer
  52388. * @param scene The scene to use the layer in
  52389. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52390. */
  52391. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52392. /**
  52393. * Get the effect name of the layer.
  52394. * @return The effect name
  52395. */
  52396. getEffectName(): string;
  52397. /**
  52398. * Create the merge effect. This is the shader use to blit the information back
  52399. * to the main canvas at the end of the scene rendering.
  52400. */
  52401. protected _createMergeEffect(): Effect;
  52402. /**
  52403. * Creates the render target textures and post processes used in the highlight layer.
  52404. */
  52405. protected _createTextureAndPostProcesses(): void;
  52406. /**
  52407. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52408. */
  52409. needStencil(): boolean;
  52410. /**
  52411. * Checks for the readiness of the element composing the layer.
  52412. * @param subMesh the mesh to check for
  52413. * @param useInstances specify wether or not to use instances to render the mesh
  52414. * @param emissiveTexture the associated emissive texture used to generate the glow
  52415. * @return true if ready otherwise, false
  52416. */
  52417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52418. /**
  52419. * Implementation specific of rendering the generating effect on the main canvas.
  52420. * @param effect The effect used to render through
  52421. */
  52422. protected _internalRender(effect: Effect): void;
  52423. /**
  52424. * Returns true if the layer contains information to display, otherwise false.
  52425. */
  52426. shouldRender(): boolean;
  52427. /**
  52428. * Returns true if the mesh should render, otherwise false.
  52429. * @param mesh The mesh to render
  52430. * @returns true if it should render otherwise false
  52431. */
  52432. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52433. /**
  52434. * Sets the required values for both the emissive texture and and the main color.
  52435. */
  52436. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52437. /**
  52438. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52439. * @param mesh The mesh to exclude from the highlight layer
  52440. */
  52441. addExcludedMesh(mesh: Mesh): void;
  52442. /**
  52443. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52444. * @param mesh The mesh to highlight
  52445. */
  52446. removeExcludedMesh(mesh: Mesh): void;
  52447. /**
  52448. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52449. * @param mesh mesh to test
  52450. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52451. */
  52452. hasMesh(mesh: AbstractMesh): boolean;
  52453. /**
  52454. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52455. * @param mesh The mesh to highlight
  52456. * @param color The color of the highlight
  52457. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52458. */
  52459. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52460. /**
  52461. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52462. * @param mesh The mesh to highlight
  52463. */
  52464. removeMesh(mesh: Mesh): void;
  52465. /**
  52466. * Force the stencil to the normal expected value for none glowing parts
  52467. */
  52468. private _defaultStencilReference;
  52469. /**
  52470. * Free any resources and references associated to a mesh.
  52471. * Internal use
  52472. * @param mesh The mesh to free.
  52473. * @hidden
  52474. */
  52475. _disposeMesh(mesh: Mesh): void;
  52476. /**
  52477. * Dispose the highlight layer and free resources.
  52478. */
  52479. dispose(): void;
  52480. /**
  52481. * Gets the class name of the effect layer
  52482. * @returns the string with the class name of the effect layer
  52483. */
  52484. getClassName(): string;
  52485. /**
  52486. * Serializes this Highlight layer
  52487. * @returns a serialized Highlight layer object
  52488. */
  52489. serialize(): any;
  52490. /**
  52491. * Creates a Highlight layer from parsed Highlight layer data
  52492. * @param parsedHightlightLayer defines the Highlight layer data
  52493. * @param scene defines the current scene
  52494. * @param rootUrl defines the root URL containing the Highlight layer information
  52495. * @returns a parsed Highlight layer
  52496. */
  52497. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52498. }
  52499. }
  52500. declare module BABYLON {
  52501. interface AbstractScene {
  52502. /**
  52503. * The list of layers (background and foreground) of the scene
  52504. */
  52505. layers: Array<Layer>;
  52506. }
  52507. /**
  52508. * Defines the layer scene component responsible to manage any layers
  52509. * in a given scene.
  52510. */
  52511. export class LayerSceneComponent implements ISceneComponent {
  52512. /**
  52513. * The component name helpfull to identify the component in the list of scene components.
  52514. */
  52515. readonly name: string;
  52516. /**
  52517. * The scene the component belongs to.
  52518. */
  52519. scene: Scene;
  52520. private _engine;
  52521. /**
  52522. * Creates a new instance of the component for the given scene
  52523. * @param scene Defines the scene to register the component in
  52524. */
  52525. constructor(scene: Scene);
  52526. /**
  52527. * Registers the component in a given scene
  52528. */
  52529. register(): void;
  52530. /**
  52531. * Rebuilds the elements related to this component in case of
  52532. * context lost for instance.
  52533. */
  52534. rebuild(): void;
  52535. /**
  52536. * Disposes the component and the associated ressources.
  52537. */
  52538. dispose(): void;
  52539. private _draw;
  52540. private _drawCameraPredicate;
  52541. private _drawCameraBackground;
  52542. private _drawCameraForeground;
  52543. private _drawRenderTargetPredicate;
  52544. private _drawRenderTargetBackground;
  52545. private _drawRenderTargetForeground;
  52546. /**
  52547. * Adds all the elements from the container to the scene
  52548. * @param container the container holding the elements
  52549. */
  52550. addFromContainer(container: AbstractScene): void;
  52551. /**
  52552. * Removes all the elements in the container from the scene
  52553. * @param container contains the elements to remove
  52554. * @param dispose if the removed element should be disposed (default: false)
  52555. */
  52556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52557. }
  52558. }
  52559. declare module BABYLON {
  52560. /** @hidden */
  52561. export var layerPixelShader: {
  52562. name: string;
  52563. shader: string;
  52564. };
  52565. }
  52566. declare module BABYLON {
  52567. /** @hidden */
  52568. export var layerVertexShader: {
  52569. name: string;
  52570. shader: string;
  52571. };
  52572. }
  52573. declare module BABYLON {
  52574. /**
  52575. * This represents a full screen 2d layer.
  52576. * This can be useful to display a picture in the background of your scene for instance.
  52577. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52578. */
  52579. export class Layer {
  52580. /**
  52581. * Define the name of the layer.
  52582. */
  52583. name: string;
  52584. /**
  52585. * Define the texture the layer should display.
  52586. */
  52587. texture: Nullable<Texture>;
  52588. /**
  52589. * Is the layer in background or foreground.
  52590. */
  52591. isBackground: boolean;
  52592. /**
  52593. * Define the color of the layer (instead of texture).
  52594. */
  52595. color: Color4;
  52596. /**
  52597. * Define the scale of the layer in order to zoom in out of the texture.
  52598. */
  52599. scale: Vector2;
  52600. /**
  52601. * Define an offset for the layer in order to shift the texture.
  52602. */
  52603. offset: Vector2;
  52604. /**
  52605. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52606. */
  52607. alphaBlendingMode: number;
  52608. /**
  52609. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52610. * Alpha test will not mix with the background color in case of transparency.
  52611. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52612. */
  52613. alphaTest: boolean;
  52614. /**
  52615. * Define a mask to restrict the layer to only some of the scene cameras.
  52616. */
  52617. layerMask: number;
  52618. /**
  52619. * Define the list of render target the layer is visible into.
  52620. */
  52621. renderTargetTextures: RenderTargetTexture[];
  52622. /**
  52623. * Define if the layer is only used in renderTarget or if it also
  52624. * renders in the main frame buffer of the canvas.
  52625. */
  52626. renderOnlyInRenderTargetTextures: boolean;
  52627. private _scene;
  52628. private _vertexBuffers;
  52629. private _indexBuffer;
  52630. private _effect;
  52631. private _previousDefines;
  52632. /**
  52633. * An event triggered when the layer is disposed.
  52634. */
  52635. onDisposeObservable: Observable<Layer>;
  52636. private _onDisposeObserver;
  52637. /**
  52638. * Back compatibility with callback before the onDisposeObservable existed.
  52639. * The set callback will be triggered when the layer has been disposed.
  52640. */
  52641. set onDispose(callback: () => void);
  52642. /**
  52643. * An event triggered before rendering the scene
  52644. */
  52645. onBeforeRenderObservable: Observable<Layer>;
  52646. private _onBeforeRenderObserver;
  52647. /**
  52648. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52649. * The set callback will be triggered just before rendering the layer.
  52650. */
  52651. set onBeforeRender(callback: () => void);
  52652. /**
  52653. * An event triggered after rendering the scene
  52654. */
  52655. onAfterRenderObservable: Observable<Layer>;
  52656. private _onAfterRenderObserver;
  52657. /**
  52658. * Back compatibility with callback before the onAfterRenderObservable existed.
  52659. * The set callback will be triggered just after rendering the layer.
  52660. */
  52661. set onAfterRender(callback: () => void);
  52662. /**
  52663. * Instantiates a new layer.
  52664. * This represents a full screen 2d layer.
  52665. * This can be useful to display a picture in the background of your scene for instance.
  52666. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52667. * @param name Define the name of the layer in the scene
  52668. * @param imgUrl Define the url of the texture to display in the layer
  52669. * @param scene Define the scene the layer belongs to
  52670. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52671. * @param color Defines a color for the layer
  52672. */
  52673. constructor(
  52674. /**
  52675. * Define the name of the layer.
  52676. */
  52677. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52678. private _createIndexBuffer;
  52679. /** @hidden */
  52680. _rebuild(): void;
  52681. /**
  52682. * Renders the layer in the scene.
  52683. */
  52684. render(): void;
  52685. /**
  52686. * Disposes and releases the associated ressources.
  52687. */
  52688. dispose(): void;
  52689. }
  52690. }
  52691. declare module BABYLON {
  52692. /** @hidden */
  52693. export var lensFlarePixelShader: {
  52694. name: string;
  52695. shader: string;
  52696. };
  52697. }
  52698. declare module BABYLON {
  52699. /** @hidden */
  52700. export var lensFlareVertexShader: {
  52701. name: string;
  52702. shader: string;
  52703. };
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52708. * It is usually composed of several `lensFlare`.
  52709. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52710. */
  52711. export class LensFlareSystem {
  52712. /**
  52713. * Define the name of the lens flare system
  52714. */
  52715. name: string;
  52716. /**
  52717. * List of lens flares used in this system.
  52718. */
  52719. lensFlares: LensFlare[];
  52720. /**
  52721. * Define a limit from the border the lens flare can be visible.
  52722. */
  52723. borderLimit: number;
  52724. /**
  52725. * Define a viewport border we do not want to see the lens flare in.
  52726. */
  52727. viewportBorder: number;
  52728. /**
  52729. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52730. */
  52731. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52732. /**
  52733. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52734. */
  52735. layerMask: number;
  52736. /**
  52737. * Define the id of the lens flare system in the scene.
  52738. * (equal to name by default)
  52739. */
  52740. id: string;
  52741. private _scene;
  52742. private _emitter;
  52743. private _vertexBuffers;
  52744. private _indexBuffer;
  52745. private _effect;
  52746. private _positionX;
  52747. private _positionY;
  52748. private _isEnabled;
  52749. /** @hidden */
  52750. static _SceneComponentInitialization: (scene: Scene) => void;
  52751. /**
  52752. * Instantiates a lens flare system.
  52753. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52754. * It is usually composed of several `lensFlare`.
  52755. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52756. * @param name Define the name of the lens flare system in the scene
  52757. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52758. * @param scene Define the scene the lens flare system belongs to
  52759. */
  52760. constructor(
  52761. /**
  52762. * Define the name of the lens flare system
  52763. */
  52764. name: string, emitter: any, scene: Scene);
  52765. /**
  52766. * Define if the lens flare system is enabled.
  52767. */
  52768. get isEnabled(): boolean;
  52769. set isEnabled(value: boolean);
  52770. /**
  52771. * Get the scene the effects belongs to.
  52772. * @returns the scene holding the lens flare system
  52773. */
  52774. getScene(): Scene;
  52775. /**
  52776. * Get the emitter of the lens flare system.
  52777. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52778. * @returns the emitter of the lens flare system
  52779. */
  52780. getEmitter(): any;
  52781. /**
  52782. * Set the emitter of the lens flare system.
  52783. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52784. * @param newEmitter Define the new emitter of the system
  52785. */
  52786. setEmitter(newEmitter: any): void;
  52787. /**
  52788. * Get the lens flare system emitter position.
  52789. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52790. * @returns the position
  52791. */
  52792. getEmitterPosition(): Vector3;
  52793. /**
  52794. * @hidden
  52795. */
  52796. computeEffectivePosition(globalViewport: Viewport): boolean;
  52797. /** @hidden */
  52798. _isVisible(): boolean;
  52799. /**
  52800. * @hidden
  52801. */
  52802. render(): boolean;
  52803. /**
  52804. * Dispose and release the lens flare with its associated resources.
  52805. */
  52806. dispose(): void;
  52807. /**
  52808. * Parse a lens flare system from a JSON repressentation
  52809. * @param parsedLensFlareSystem Define the JSON to parse
  52810. * @param scene Define the scene the parsed system should be instantiated in
  52811. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52812. * @returns the parsed system
  52813. */
  52814. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52815. /**
  52816. * Serialize the current Lens Flare System into a JSON representation.
  52817. * @returns the serialized JSON
  52818. */
  52819. serialize(): any;
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /**
  52824. * This represents one of the lens effect in a `lensFlareSystem`.
  52825. * It controls one of the indiviual texture used in the effect.
  52826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52827. */
  52828. export class LensFlare {
  52829. /**
  52830. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52831. */
  52832. size: number;
  52833. /**
  52834. * 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.
  52835. */
  52836. position: number;
  52837. /**
  52838. * Define the lens color.
  52839. */
  52840. color: Color3;
  52841. /**
  52842. * Define the lens texture.
  52843. */
  52844. texture: Nullable<Texture>;
  52845. /**
  52846. * Define the alpha mode to render this particular lens.
  52847. */
  52848. alphaMode: number;
  52849. private _system;
  52850. /**
  52851. * Creates a new Lens Flare.
  52852. * This represents one of the lens effect in a `lensFlareSystem`.
  52853. * It controls one of the indiviual texture used in the effect.
  52854. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52855. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52856. * @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.
  52857. * @param color Define the lens color
  52858. * @param imgUrl Define the lens texture url
  52859. * @param system Define the `lensFlareSystem` this flare is part of
  52860. * @returns The newly created Lens Flare
  52861. */
  52862. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52863. /**
  52864. * Instantiates a new Lens Flare.
  52865. * This represents one of the lens effect in a `lensFlareSystem`.
  52866. * It controls one of the indiviual texture used in the effect.
  52867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52868. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52869. * @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.
  52870. * @param color Define the lens color
  52871. * @param imgUrl Define the lens texture url
  52872. * @param system Define the `lensFlareSystem` this flare is part of
  52873. */
  52874. constructor(
  52875. /**
  52876. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52877. */
  52878. size: number,
  52879. /**
  52880. * 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.
  52881. */
  52882. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52883. /**
  52884. * Dispose and release the lens flare with its associated resources.
  52885. */
  52886. dispose(): void;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. interface AbstractScene {
  52891. /**
  52892. * The list of lens flare system added to the scene
  52893. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52894. */
  52895. lensFlareSystems: Array<LensFlareSystem>;
  52896. /**
  52897. * Removes the given lens flare system from this scene.
  52898. * @param toRemove The lens flare system to remove
  52899. * @returns The index of the removed lens flare system
  52900. */
  52901. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52902. /**
  52903. * Adds the given lens flare system to this scene
  52904. * @param newLensFlareSystem The lens flare system to add
  52905. */
  52906. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52907. /**
  52908. * Gets a lens flare system using its name
  52909. * @param name defines the name to look for
  52910. * @returns the lens flare system or null if not found
  52911. */
  52912. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52913. /**
  52914. * Gets a lens flare system using its id
  52915. * @param id defines the id to look for
  52916. * @returns the lens flare system or null if not found
  52917. */
  52918. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52919. }
  52920. /**
  52921. * Defines the lens flare scene component responsible to manage any lens flares
  52922. * in a given scene.
  52923. */
  52924. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52925. /**
  52926. * The component name helpfull to identify the component in the list of scene components.
  52927. */
  52928. readonly name: string;
  52929. /**
  52930. * The scene the component belongs to.
  52931. */
  52932. scene: Scene;
  52933. /**
  52934. * Creates a new instance of the component for the given scene
  52935. * @param scene Defines the scene to register the component in
  52936. */
  52937. constructor(scene: Scene);
  52938. /**
  52939. * Registers the component in a given scene
  52940. */
  52941. register(): void;
  52942. /**
  52943. * Rebuilds the elements related to this component in case of
  52944. * context lost for instance.
  52945. */
  52946. rebuild(): void;
  52947. /**
  52948. * Adds all the elements from the container to the scene
  52949. * @param container the container holding the elements
  52950. */
  52951. addFromContainer(container: AbstractScene): void;
  52952. /**
  52953. * Removes all the elements in the container from the scene
  52954. * @param container contains the elements to remove
  52955. * @param dispose if the removed element should be disposed (default: false)
  52956. */
  52957. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52958. /**
  52959. * Serializes the component data to the specified json object
  52960. * @param serializationObject The object to serialize to
  52961. */
  52962. serialize(serializationObject: any): void;
  52963. /**
  52964. * Disposes the component and the associated ressources.
  52965. */
  52966. dispose(): void;
  52967. private _draw;
  52968. }
  52969. }
  52970. declare module BABYLON {
  52971. /**
  52972. * Defines the shadow generator component responsible to manage any shadow generators
  52973. * in a given scene.
  52974. */
  52975. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52976. /**
  52977. * The component name helpfull to identify the component in the list of scene components.
  52978. */
  52979. readonly name: string;
  52980. /**
  52981. * The scene the component belongs to.
  52982. */
  52983. scene: Scene;
  52984. /**
  52985. * Creates a new instance of the component for the given scene
  52986. * @param scene Defines the scene to register the component in
  52987. */
  52988. constructor(scene: Scene);
  52989. /**
  52990. * Registers the component in a given scene
  52991. */
  52992. register(): void;
  52993. /**
  52994. * Rebuilds the elements related to this component in case of
  52995. * context lost for instance.
  52996. */
  52997. rebuild(): void;
  52998. /**
  52999. * Serializes the component data to the specified json object
  53000. * @param serializationObject The object to serialize to
  53001. */
  53002. serialize(serializationObject: any): void;
  53003. /**
  53004. * Adds all the elements from the container to the scene
  53005. * @param container the container holding the elements
  53006. */
  53007. addFromContainer(container: AbstractScene): void;
  53008. /**
  53009. * Removes all the elements in the container from the scene
  53010. * @param container contains the elements to remove
  53011. * @param dispose if the removed element should be disposed (default: false)
  53012. */
  53013. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53014. /**
  53015. * Rebuilds the elements related to this component in case of
  53016. * context lost for instance.
  53017. */
  53018. dispose(): void;
  53019. private _gatherRenderTargets;
  53020. }
  53021. }
  53022. declare module BABYLON {
  53023. /**
  53024. * A point light is a light defined by an unique point in world space.
  53025. * The light is emitted in every direction from this point.
  53026. * A good example of a point light is a standard light bulb.
  53027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53028. */
  53029. export class PointLight extends ShadowLight {
  53030. private _shadowAngle;
  53031. /**
  53032. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53033. * This specifies what angle the shadow will use to be created.
  53034. *
  53035. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53036. */
  53037. get shadowAngle(): number;
  53038. /**
  53039. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53040. * This specifies what angle the shadow will use to be created.
  53041. *
  53042. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53043. */
  53044. set shadowAngle(value: number);
  53045. /**
  53046. * Gets the direction if it has been set.
  53047. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53048. */
  53049. get direction(): Vector3;
  53050. /**
  53051. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53052. */
  53053. set direction(value: Vector3);
  53054. /**
  53055. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53056. * A PointLight emits the light in every direction.
  53057. * It can cast shadows.
  53058. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53059. * ```javascript
  53060. * var pointLight = new PointLight("pl", camera.position, scene);
  53061. * ```
  53062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53063. * @param name The light friendly name
  53064. * @param position The position of the point light in the scene
  53065. * @param scene The scene the lights belongs to
  53066. */
  53067. constructor(name: string, position: Vector3, scene: Scene);
  53068. /**
  53069. * Returns the string "PointLight"
  53070. * @returns the class name
  53071. */
  53072. getClassName(): string;
  53073. /**
  53074. * Returns the integer 0.
  53075. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53076. */
  53077. getTypeID(): number;
  53078. /**
  53079. * Specifies wether or not the shadowmap should be a cube texture.
  53080. * @returns true if the shadowmap needs to be a cube texture.
  53081. */
  53082. needCube(): boolean;
  53083. /**
  53084. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53085. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53086. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53087. */
  53088. getShadowDirection(faceIndex?: number): Vector3;
  53089. /**
  53090. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53091. * - fov = PI / 2
  53092. * - aspect ratio : 1.0
  53093. * - z-near and far equal to the active camera minZ and maxZ.
  53094. * Returns the PointLight.
  53095. */
  53096. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53097. protected _buildUniformLayout(): void;
  53098. /**
  53099. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53100. * @param effect The effect to update
  53101. * @param lightIndex The index of the light in the effect to update
  53102. * @returns The point light
  53103. */
  53104. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53105. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53106. /**
  53107. * Prepares the list of defines specific to the light type.
  53108. * @param defines the list of defines
  53109. * @param lightIndex defines the index of the light for the effect
  53110. */
  53111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53112. }
  53113. }
  53114. declare module BABYLON {
  53115. /**
  53116. * Header information of HDR texture files.
  53117. */
  53118. export interface HDRInfo {
  53119. /**
  53120. * The height of the texture in pixels.
  53121. */
  53122. height: number;
  53123. /**
  53124. * The width of the texture in pixels.
  53125. */
  53126. width: number;
  53127. /**
  53128. * The index of the beginning of the data in the binary file.
  53129. */
  53130. dataPosition: number;
  53131. }
  53132. /**
  53133. * This groups tools to convert HDR texture to native colors array.
  53134. */
  53135. export class HDRTools {
  53136. private static Ldexp;
  53137. private static Rgbe2float;
  53138. private static readStringLine;
  53139. /**
  53140. * Reads header information from an RGBE texture stored in a native array.
  53141. * More information on this format are available here:
  53142. * https://en.wikipedia.org/wiki/RGBE_image_format
  53143. *
  53144. * @param uint8array The binary file stored in native array.
  53145. * @return The header information.
  53146. */
  53147. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53148. /**
  53149. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53150. * This RGBE texture needs to store the information as a panorama.
  53151. *
  53152. * More information on this format are available here:
  53153. * https://en.wikipedia.org/wiki/RGBE_image_format
  53154. *
  53155. * @param buffer The binary file stored in an array buffer.
  53156. * @param size The expected size of the extracted cubemap.
  53157. * @return The Cube Map information.
  53158. */
  53159. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53160. /**
  53161. * Returns the pixels data extracted from an RGBE texture.
  53162. * This pixels will be stored left to right up to down in the R G B order in one array.
  53163. *
  53164. * More information on this format are available here:
  53165. * https://en.wikipedia.org/wiki/RGBE_image_format
  53166. *
  53167. * @param uint8array The binary file stored in an array buffer.
  53168. * @param hdrInfo The header information of the file.
  53169. * @return The pixels data in RGB right to left up to down order.
  53170. */
  53171. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53172. private static RGBE_ReadPixels_RLE;
  53173. }
  53174. }
  53175. declare module BABYLON {
  53176. /**
  53177. * This represents a texture coming from an HDR input.
  53178. *
  53179. * The only supported format is currently panorama picture stored in RGBE format.
  53180. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53181. */
  53182. export class HDRCubeTexture extends BaseTexture {
  53183. private static _facesMapping;
  53184. private _generateHarmonics;
  53185. private _noMipmap;
  53186. private _textureMatrix;
  53187. private _size;
  53188. private _onLoad;
  53189. private _onError;
  53190. /**
  53191. * The texture URL.
  53192. */
  53193. url: string;
  53194. /**
  53195. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53196. */
  53197. coordinatesMode: number;
  53198. protected _isBlocking: boolean;
  53199. /**
  53200. * Sets wether or not the texture is blocking during loading.
  53201. */
  53202. set isBlocking(value: boolean);
  53203. /**
  53204. * Gets wether or not the texture is blocking during loading.
  53205. */
  53206. get isBlocking(): boolean;
  53207. protected _rotationY: number;
  53208. /**
  53209. * Sets texture matrix rotation angle around Y axis in radians.
  53210. */
  53211. set rotationY(value: number);
  53212. /**
  53213. * Gets texture matrix rotation angle around Y axis radians.
  53214. */
  53215. get rotationY(): number;
  53216. /**
  53217. * Gets or sets the center of the bounding box associated with the cube texture
  53218. * It must define where the camera used to render the texture was set
  53219. */
  53220. boundingBoxPosition: Vector3;
  53221. private _boundingBoxSize;
  53222. /**
  53223. * Gets or sets the size of the bounding box associated with the cube texture
  53224. * When defined, the cubemap will switch to local mode
  53225. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53226. * @example https://www.babylonjs-playground.com/#RNASML
  53227. */
  53228. set boundingBoxSize(value: Vector3);
  53229. get boundingBoxSize(): Vector3;
  53230. /**
  53231. * Instantiates an HDRTexture from the following parameters.
  53232. *
  53233. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53234. * @param scene The scene the texture will be used in
  53235. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53236. * @param noMipmap Forces to not generate the mipmap if true
  53237. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53238. * @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)
  53239. * @param reserved Reserved flag for internal use.
  53240. */
  53241. 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>);
  53242. /**
  53243. * Get the current class name of the texture useful for serialization or dynamic coding.
  53244. * @returns "HDRCubeTexture"
  53245. */
  53246. getClassName(): string;
  53247. /**
  53248. * Occurs when the file is raw .hdr file.
  53249. */
  53250. private loadTexture;
  53251. clone(): HDRCubeTexture;
  53252. delayLoad(): void;
  53253. /**
  53254. * Get the texture reflection matrix used to rotate/transform the reflection.
  53255. * @returns the reflection matrix
  53256. */
  53257. getReflectionTextureMatrix(): Matrix;
  53258. /**
  53259. * Set the texture reflection matrix used to rotate/transform the reflection.
  53260. * @param value Define the reflection matrix to set
  53261. */
  53262. setReflectionTextureMatrix(value: Matrix): void;
  53263. /**
  53264. * Parses a JSON representation of an HDR Texture in order to create the texture
  53265. * @param parsedTexture Define the JSON representation
  53266. * @param scene Define the scene the texture should be created in
  53267. * @param rootUrl Define the root url in case we need to load relative dependencies
  53268. * @returns the newly created texture after parsing
  53269. */
  53270. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53271. serialize(): any;
  53272. }
  53273. }
  53274. declare module BABYLON {
  53275. /**
  53276. * Class used to control physics engine
  53277. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53278. */
  53279. export class PhysicsEngine implements IPhysicsEngine {
  53280. private _physicsPlugin;
  53281. /**
  53282. * Global value used to control the smallest number supported by the simulation
  53283. */
  53284. static Epsilon: number;
  53285. private _impostors;
  53286. private _joints;
  53287. private _subTimeStep;
  53288. /**
  53289. * Gets the gravity vector used by the simulation
  53290. */
  53291. gravity: Vector3;
  53292. /**
  53293. * Factory used to create the default physics plugin.
  53294. * @returns The default physics plugin
  53295. */
  53296. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53297. /**
  53298. * Creates a new Physics Engine
  53299. * @param gravity defines the gravity vector used by the simulation
  53300. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53301. */
  53302. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53303. /**
  53304. * Sets the gravity vector used by the simulation
  53305. * @param gravity defines the gravity vector to use
  53306. */
  53307. setGravity(gravity: Vector3): void;
  53308. /**
  53309. * Set the time step of the physics engine.
  53310. * Default is 1/60.
  53311. * To slow it down, enter 1/600 for example.
  53312. * To speed it up, 1/30
  53313. * @param newTimeStep defines the new timestep to apply to this world.
  53314. */
  53315. setTimeStep(newTimeStep?: number): void;
  53316. /**
  53317. * Get the time step of the physics engine.
  53318. * @returns the current time step
  53319. */
  53320. getTimeStep(): number;
  53321. /**
  53322. * Set the sub time step of the physics engine.
  53323. * Default is 0 meaning there is no sub steps
  53324. * To increase physics resolution precision, set a small value (like 1 ms)
  53325. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53326. */
  53327. setSubTimeStep(subTimeStep?: number): void;
  53328. /**
  53329. * Get the sub time step of the physics engine.
  53330. * @returns the current sub time step
  53331. */
  53332. getSubTimeStep(): number;
  53333. /**
  53334. * Release all resources
  53335. */
  53336. dispose(): void;
  53337. /**
  53338. * Gets the name of the current physics plugin
  53339. * @returns the name of the plugin
  53340. */
  53341. getPhysicsPluginName(): string;
  53342. /**
  53343. * Adding a new impostor for the impostor tracking.
  53344. * This will be done by the impostor itself.
  53345. * @param impostor the impostor to add
  53346. */
  53347. addImpostor(impostor: PhysicsImpostor): void;
  53348. /**
  53349. * Remove an impostor from the engine.
  53350. * This impostor and its mesh will not longer be updated by the physics engine.
  53351. * @param impostor the impostor to remove
  53352. */
  53353. removeImpostor(impostor: PhysicsImpostor): void;
  53354. /**
  53355. * Add a joint to the physics engine
  53356. * @param mainImpostor defines the main impostor to which the joint is added.
  53357. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53358. * @param joint defines the joint that will connect both impostors.
  53359. */
  53360. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53361. /**
  53362. * Removes a joint from the simulation
  53363. * @param mainImpostor defines the impostor used with the joint
  53364. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53365. * @param joint defines the joint to remove
  53366. */
  53367. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53368. /**
  53369. * Called by the scene. No need to call it.
  53370. * @param delta defines the timespam between frames
  53371. */
  53372. _step(delta: number): void;
  53373. /**
  53374. * Gets the current plugin used to run the simulation
  53375. * @returns current plugin
  53376. */
  53377. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53378. /**
  53379. * Gets the list of physic impostors
  53380. * @returns an array of PhysicsImpostor
  53381. */
  53382. getImpostors(): Array<PhysicsImpostor>;
  53383. /**
  53384. * Gets the impostor for a physics enabled object
  53385. * @param object defines the object impersonated by the impostor
  53386. * @returns the PhysicsImpostor or null if not found
  53387. */
  53388. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53389. /**
  53390. * Gets the impostor for a physics body object
  53391. * @param body defines physics body used by the impostor
  53392. * @returns the PhysicsImpostor or null if not found
  53393. */
  53394. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53395. /**
  53396. * Does a raycast in the physics world
  53397. * @param from when should the ray start?
  53398. * @param to when should the ray end?
  53399. * @returns PhysicsRaycastResult
  53400. */
  53401. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53402. }
  53403. }
  53404. declare module BABYLON {
  53405. /** @hidden */
  53406. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53407. private _useDeltaForWorldStep;
  53408. world: any;
  53409. name: string;
  53410. private _physicsMaterials;
  53411. private _fixedTimeStep;
  53412. private _cannonRaycastResult;
  53413. private _raycastResult;
  53414. private _physicsBodysToRemoveAfterStep;
  53415. BJSCANNON: any;
  53416. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53417. setGravity(gravity: Vector3): void;
  53418. setTimeStep(timeStep: number): void;
  53419. getTimeStep(): number;
  53420. executeStep(delta: number): void;
  53421. private _removeMarkedPhysicsBodiesFromWorld;
  53422. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53423. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53424. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53425. private _processChildMeshes;
  53426. removePhysicsBody(impostor: PhysicsImpostor): void;
  53427. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53428. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53429. private _addMaterial;
  53430. private _checkWithEpsilon;
  53431. private _createShape;
  53432. private _createHeightmap;
  53433. private _minus90X;
  53434. private _plus90X;
  53435. private _tmpPosition;
  53436. private _tmpDeltaPosition;
  53437. private _tmpUnityRotation;
  53438. private _updatePhysicsBodyTransformation;
  53439. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53440. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53441. isSupported(): boolean;
  53442. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53444. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53445. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53447. getBodyMass(impostor: PhysicsImpostor): number;
  53448. getBodyFriction(impostor: PhysicsImpostor): number;
  53449. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53450. getBodyRestitution(impostor: PhysicsImpostor): number;
  53451. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53452. sleepBody(impostor: PhysicsImpostor): void;
  53453. wakeUpBody(impostor: PhysicsImpostor): void;
  53454. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53455. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53456. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53457. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53458. getRadius(impostor: PhysicsImpostor): number;
  53459. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53460. dispose(): void;
  53461. private _extendNamespace;
  53462. /**
  53463. * Does a raycast in the physics world
  53464. * @param from when should the ray start?
  53465. * @param to when should the ray end?
  53466. * @returns PhysicsRaycastResult
  53467. */
  53468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53469. }
  53470. }
  53471. declare module BABYLON {
  53472. /** @hidden */
  53473. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53474. world: any;
  53475. name: string;
  53476. BJSOIMO: any;
  53477. private _raycastResult;
  53478. constructor(iterations?: number, oimoInjection?: any);
  53479. setGravity(gravity: Vector3): void;
  53480. setTimeStep(timeStep: number): void;
  53481. getTimeStep(): number;
  53482. private _tmpImpostorsArray;
  53483. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53484. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53485. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53486. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53487. private _tmpPositionVector;
  53488. removePhysicsBody(impostor: PhysicsImpostor): void;
  53489. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53490. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53491. isSupported(): boolean;
  53492. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53493. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53495. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53496. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53497. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53498. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53499. getBodyMass(impostor: PhysicsImpostor): number;
  53500. getBodyFriction(impostor: PhysicsImpostor): number;
  53501. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53502. getBodyRestitution(impostor: PhysicsImpostor): number;
  53503. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53504. sleepBody(impostor: PhysicsImpostor): void;
  53505. wakeUpBody(impostor: PhysicsImpostor): void;
  53506. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53507. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53508. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53509. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53510. getRadius(impostor: PhysicsImpostor): number;
  53511. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53512. dispose(): void;
  53513. /**
  53514. * Does a raycast in the physics world
  53515. * @param from when should the ray start?
  53516. * @param to when should the ray end?
  53517. * @returns PhysicsRaycastResult
  53518. */
  53519. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53520. }
  53521. }
  53522. declare module BABYLON {
  53523. /**
  53524. * Class containing static functions to help procedurally build meshes
  53525. */
  53526. export class RibbonBuilder {
  53527. /**
  53528. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53529. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53530. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53531. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53532. * * 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
  53533. * * 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
  53534. * * 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
  53535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53536. * * 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
  53537. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53538. * * 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
  53539. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53540. * * 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
  53541. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53543. * @param name defines the name of the mesh
  53544. * @param options defines the options used to create the mesh
  53545. * @param scene defines the hosting scene
  53546. * @returns the ribbon mesh
  53547. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53549. */
  53550. static CreateRibbon(name: string, options: {
  53551. pathArray: Vector3[][];
  53552. closeArray?: boolean;
  53553. closePath?: boolean;
  53554. offset?: number;
  53555. updatable?: boolean;
  53556. sideOrientation?: number;
  53557. frontUVs?: Vector4;
  53558. backUVs?: Vector4;
  53559. instance?: Mesh;
  53560. invertUV?: boolean;
  53561. uvs?: Vector2[];
  53562. colors?: Color4[];
  53563. }, scene?: Nullable<Scene>): Mesh;
  53564. }
  53565. }
  53566. declare module BABYLON {
  53567. /**
  53568. * Class containing static functions to help procedurally build meshes
  53569. */
  53570. export class ShapeBuilder {
  53571. /**
  53572. * 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.
  53573. * * 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.
  53574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53575. * * 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.
  53576. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53577. * * 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
  53578. * * 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
  53579. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53581. * * 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
  53582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53584. * @param name defines the name of the mesh
  53585. * @param options defines the options used to create the mesh
  53586. * @param scene defines the hosting scene
  53587. * @returns the extruded shape mesh
  53588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53590. */
  53591. static ExtrudeShape(name: string, options: {
  53592. shape: Vector3[];
  53593. path: Vector3[];
  53594. scale?: number;
  53595. rotation?: number;
  53596. cap?: number;
  53597. updatable?: boolean;
  53598. sideOrientation?: number;
  53599. frontUVs?: Vector4;
  53600. backUVs?: Vector4;
  53601. instance?: Mesh;
  53602. invertUV?: boolean;
  53603. }, scene?: Nullable<Scene>): Mesh;
  53604. /**
  53605. * Creates an custom extruded shape mesh.
  53606. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53607. * * 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.
  53608. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53609. * * 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
  53610. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53611. * * 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
  53612. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53613. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53614. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53615. * * 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
  53616. * * 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
  53617. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53619. * * 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
  53620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53622. * @param name defines the name of the mesh
  53623. * @param options defines the options used to create the mesh
  53624. * @param scene defines the hosting scene
  53625. * @returns the custom extruded shape mesh
  53626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53627. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53629. */
  53630. static ExtrudeShapeCustom(name: string, options: {
  53631. shape: Vector3[];
  53632. path: Vector3[];
  53633. scaleFunction?: any;
  53634. rotationFunction?: any;
  53635. ribbonCloseArray?: boolean;
  53636. ribbonClosePath?: boolean;
  53637. cap?: number;
  53638. updatable?: boolean;
  53639. sideOrientation?: number;
  53640. frontUVs?: Vector4;
  53641. backUVs?: Vector4;
  53642. instance?: Mesh;
  53643. invertUV?: boolean;
  53644. }, scene?: Nullable<Scene>): Mesh;
  53645. private static _ExtrudeShapeGeneric;
  53646. }
  53647. }
  53648. declare module BABYLON {
  53649. /**
  53650. * AmmoJS Physics plugin
  53651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53652. * @see https://github.com/kripken/ammo.js/
  53653. */
  53654. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53655. private _useDeltaForWorldStep;
  53656. /**
  53657. * Reference to the Ammo library
  53658. */
  53659. bjsAMMO: any;
  53660. /**
  53661. * Created ammoJS world which physics bodies are added to
  53662. */
  53663. world: any;
  53664. /**
  53665. * Name of the plugin
  53666. */
  53667. name: string;
  53668. private _timeStep;
  53669. private _fixedTimeStep;
  53670. private _maxSteps;
  53671. private _tmpQuaternion;
  53672. private _tmpAmmoTransform;
  53673. private _tmpAmmoQuaternion;
  53674. private _tmpAmmoConcreteContactResultCallback;
  53675. private _collisionConfiguration;
  53676. private _dispatcher;
  53677. private _overlappingPairCache;
  53678. private _solver;
  53679. private _softBodySolver;
  53680. private _tmpAmmoVectorA;
  53681. private _tmpAmmoVectorB;
  53682. private _tmpAmmoVectorC;
  53683. private _tmpAmmoVectorD;
  53684. private _tmpContactCallbackResult;
  53685. private _tmpAmmoVectorRCA;
  53686. private _tmpAmmoVectorRCB;
  53687. private _raycastResult;
  53688. private static readonly DISABLE_COLLISION_FLAG;
  53689. private static readonly KINEMATIC_FLAG;
  53690. private static readonly DISABLE_DEACTIVATION_FLAG;
  53691. /**
  53692. * Initializes the ammoJS plugin
  53693. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53694. * @param ammoInjection can be used to inject your own ammo reference
  53695. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53696. */
  53697. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53698. /**
  53699. * Sets the gravity of the physics world (m/(s^2))
  53700. * @param gravity Gravity to set
  53701. */
  53702. setGravity(gravity: Vector3): void;
  53703. /**
  53704. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53705. * @param timeStep timestep to use in seconds
  53706. */
  53707. setTimeStep(timeStep: number): void;
  53708. /**
  53709. * 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)
  53710. * @param fixedTimeStep fixedTimeStep to use in seconds
  53711. */
  53712. setFixedTimeStep(fixedTimeStep: number): void;
  53713. /**
  53714. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53715. * @param maxSteps the maximum number of steps by the physics engine per frame
  53716. */
  53717. setMaxSteps(maxSteps: number): void;
  53718. /**
  53719. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53720. * @returns the current timestep in seconds
  53721. */
  53722. getTimeStep(): number;
  53723. /**
  53724. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53725. */
  53726. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53727. private _isImpostorInContact;
  53728. private _isImpostorPairInContact;
  53729. private _stepSimulation;
  53730. /**
  53731. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53732. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53733. * After the step the babylon meshes are set to the position of the physics imposters
  53734. * @param delta amount of time to step forward
  53735. * @param impostors array of imposters to update before/after the step
  53736. */
  53737. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53738. /**
  53739. * Update babylon mesh to match physics world object
  53740. * @param impostor imposter to match
  53741. */
  53742. private _afterSoftStep;
  53743. /**
  53744. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53745. * @param impostor imposter to match
  53746. */
  53747. private _ropeStep;
  53748. /**
  53749. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53750. * @param impostor imposter to match
  53751. */
  53752. private _softbodyOrClothStep;
  53753. private _tmpVector;
  53754. private _tmpMatrix;
  53755. /**
  53756. * Applies an impulse on the imposter
  53757. * @param impostor imposter to apply impulse to
  53758. * @param force amount of force to be applied to the imposter
  53759. * @param contactPoint the location to apply the impulse on the imposter
  53760. */
  53761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53762. /**
  53763. * Applies a force on the imposter
  53764. * @param impostor imposter to apply force
  53765. * @param force amount of force to be applied to the imposter
  53766. * @param contactPoint the location to apply the force on the imposter
  53767. */
  53768. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53769. /**
  53770. * Creates a physics body using the plugin
  53771. * @param impostor the imposter to create the physics body on
  53772. */
  53773. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53774. /**
  53775. * Removes the physics body from the imposter and disposes of the body's memory
  53776. * @param impostor imposter to remove the physics body from
  53777. */
  53778. removePhysicsBody(impostor: PhysicsImpostor): void;
  53779. /**
  53780. * Generates a joint
  53781. * @param impostorJoint the imposter joint to create the joint with
  53782. */
  53783. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53784. /**
  53785. * Removes a joint
  53786. * @param impostorJoint the imposter joint to remove the joint from
  53787. */
  53788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53789. private _addMeshVerts;
  53790. /**
  53791. * Initialise the soft body vertices to match its object's (mesh) vertices
  53792. * Softbody vertices (nodes) are in world space and to match this
  53793. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53794. * @param impostor to create the softbody for
  53795. */
  53796. private _softVertexData;
  53797. /**
  53798. * Create an impostor's soft body
  53799. * @param impostor to create the softbody for
  53800. */
  53801. private _createSoftbody;
  53802. /**
  53803. * Create cloth for an impostor
  53804. * @param impostor to create the softbody for
  53805. */
  53806. private _createCloth;
  53807. /**
  53808. * Create rope for an impostor
  53809. * @param impostor to create the softbody for
  53810. */
  53811. private _createRope;
  53812. /**
  53813. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53814. * @param impostor to create the custom physics shape for
  53815. */
  53816. private _createCustom;
  53817. private _addHullVerts;
  53818. private _createShape;
  53819. /**
  53820. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53821. * @param impostor imposter containing the physics body and babylon object
  53822. */
  53823. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53824. /**
  53825. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53826. * @param impostor imposter containing the physics body and babylon object
  53827. * @param newPosition new position
  53828. * @param newRotation new rotation
  53829. */
  53830. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53831. /**
  53832. * If this plugin is supported
  53833. * @returns true if its supported
  53834. */
  53835. isSupported(): boolean;
  53836. /**
  53837. * Sets the linear velocity of the physics body
  53838. * @param impostor imposter to set the velocity on
  53839. * @param velocity velocity to set
  53840. */
  53841. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53842. /**
  53843. * Sets the angular velocity of the physics body
  53844. * @param impostor imposter to set the velocity on
  53845. * @param velocity velocity to set
  53846. */
  53847. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53848. /**
  53849. * gets the linear velocity
  53850. * @param impostor imposter to get linear velocity from
  53851. * @returns linear velocity
  53852. */
  53853. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53854. /**
  53855. * gets the angular velocity
  53856. * @param impostor imposter to get angular velocity from
  53857. * @returns angular velocity
  53858. */
  53859. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53860. /**
  53861. * Sets the mass of physics body
  53862. * @param impostor imposter to set the mass on
  53863. * @param mass mass to set
  53864. */
  53865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53866. /**
  53867. * Gets the mass of the physics body
  53868. * @param impostor imposter to get the mass from
  53869. * @returns mass
  53870. */
  53871. getBodyMass(impostor: PhysicsImpostor): number;
  53872. /**
  53873. * Gets friction of the impostor
  53874. * @param impostor impostor to get friction from
  53875. * @returns friction value
  53876. */
  53877. getBodyFriction(impostor: PhysicsImpostor): number;
  53878. /**
  53879. * Sets friction of the impostor
  53880. * @param impostor impostor to set friction on
  53881. * @param friction friction value
  53882. */
  53883. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53884. /**
  53885. * Gets restitution of the impostor
  53886. * @param impostor impostor to get restitution from
  53887. * @returns restitution value
  53888. */
  53889. getBodyRestitution(impostor: PhysicsImpostor): number;
  53890. /**
  53891. * Sets resitution of the impostor
  53892. * @param impostor impostor to set resitution on
  53893. * @param restitution resitution value
  53894. */
  53895. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53896. /**
  53897. * Gets pressure inside the impostor
  53898. * @param impostor impostor to get pressure from
  53899. * @returns pressure value
  53900. */
  53901. getBodyPressure(impostor: PhysicsImpostor): number;
  53902. /**
  53903. * Sets pressure inside a soft body impostor
  53904. * Cloth and rope must remain 0 pressure
  53905. * @param impostor impostor to set pressure on
  53906. * @param pressure pressure value
  53907. */
  53908. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53909. /**
  53910. * Gets stiffness of the impostor
  53911. * @param impostor impostor to get stiffness from
  53912. * @returns pressure value
  53913. */
  53914. getBodyStiffness(impostor: PhysicsImpostor): number;
  53915. /**
  53916. * Sets stiffness of the impostor
  53917. * @param impostor impostor to set stiffness on
  53918. * @param stiffness stiffness value from 0 to 1
  53919. */
  53920. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53921. /**
  53922. * Gets velocityIterations of the impostor
  53923. * @param impostor impostor to get velocity iterations from
  53924. * @returns velocityIterations value
  53925. */
  53926. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53927. /**
  53928. * Sets velocityIterations of the impostor
  53929. * @param impostor impostor to set velocity iterations on
  53930. * @param velocityIterations velocityIterations value
  53931. */
  53932. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53933. /**
  53934. * Gets positionIterations of the impostor
  53935. * @param impostor impostor to get position iterations from
  53936. * @returns positionIterations value
  53937. */
  53938. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53939. /**
  53940. * Sets positionIterations of the impostor
  53941. * @param impostor impostor to set position on
  53942. * @param positionIterations positionIterations value
  53943. */
  53944. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53945. /**
  53946. * Append an anchor to a cloth object
  53947. * @param impostor is the cloth impostor to add anchor to
  53948. * @param otherImpostor is the rigid impostor to anchor to
  53949. * @param width ratio across width from 0 to 1
  53950. * @param height ratio up height from 0 to 1
  53951. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53952. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53953. */
  53954. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53955. /**
  53956. * Append an hook to a rope object
  53957. * @param impostor is the rope impostor to add hook to
  53958. * @param otherImpostor is the rigid impostor to hook to
  53959. * @param length ratio along the rope from 0 to 1
  53960. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53961. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53962. */
  53963. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53964. /**
  53965. * Sleeps the physics body and stops it from being active
  53966. * @param impostor impostor to sleep
  53967. */
  53968. sleepBody(impostor: PhysicsImpostor): void;
  53969. /**
  53970. * Activates the physics body
  53971. * @param impostor impostor to activate
  53972. */
  53973. wakeUpBody(impostor: PhysicsImpostor): void;
  53974. /**
  53975. * Updates the distance parameters of the joint
  53976. * @param joint joint to update
  53977. * @param maxDistance maximum distance of the joint
  53978. * @param minDistance minimum distance of the joint
  53979. */
  53980. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53981. /**
  53982. * Sets a motor on the joint
  53983. * @param joint joint to set motor on
  53984. * @param speed speed of the motor
  53985. * @param maxForce maximum force of the motor
  53986. * @param motorIndex index of the motor
  53987. */
  53988. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53989. /**
  53990. * Sets the motors limit
  53991. * @param joint joint to set limit on
  53992. * @param upperLimit upper limit
  53993. * @param lowerLimit lower limit
  53994. */
  53995. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53996. /**
  53997. * Syncs the position and rotation of a mesh with the impostor
  53998. * @param mesh mesh to sync
  53999. * @param impostor impostor to update the mesh with
  54000. */
  54001. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54002. /**
  54003. * Gets the radius of the impostor
  54004. * @param impostor impostor to get radius from
  54005. * @returns the radius
  54006. */
  54007. getRadius(impostor: PhysicsImpostor): number;
  54008. /**
  54009. * Gets the box size of the impostor
  54010. * @param impostor impostor to get box size from
  54011. * @param result the resulting box size
  54012. */
  54013. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54014. /**
  54015. * Disposes of the impostor
  54016. */
  54017. dispose(): void;
  54018. /**
  54019. * Does a raycast in the physics world
  54020. * @param from when should the ray start?
  54021. * @param to when should the ray end?
  54022. * @returns PhysicsRaycastResult
  54023. */
  54024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54025. }
  54026. }
  54027. declare module BABYLON {
  54028. interface AbstractScene {
  54029. /**
  54030. * The list of reflection probes added to the scene
  54031. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54032. */
  54033. reflectionProbes: Array<ReflectionProbe>;
  54034. /**
  54035. * Removes the given reflection probe from this scene.
  54036. * @param toRemove The reflection probe to remove
  54037. * @returns The index of the removed reflection probe
  54038. */
  54039. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54040. /**
  54041. * Adds the given reflection probe to this scene.
  54042. * @param newReflectionProbe The reflection probe to add
  54043. */
  54044. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54045. }
  54046. /**
  54047. * Class used to generate realtime reflection / refraction cube textures
  54048. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54049. */
  54050. export class ReflectionProbe {
  54051. /** defines the name of the probe */
  54052. name: string;
  54053. private _scene;
  54054. private _renderTargetTexture;
  54055. private _projectionMatrix;
  54056. private _viewMatrix;
  54057. private _target;
  54058. private _add;
  54059. private _attachedMesh;
  54060. private _invertYAxis;
  54061. /** Gets or sets probe position (center of the cube map) */
  54062. position: Vector3;
  54063. /**
  54064. * Creates a new reflection probe
  54065. * @param name defines the name of the probe
  54066. * @param size defines the texture resolution (for each face)
  54067. * @param scene defines the hosting scene
  54068. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54069. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54070. */
  54071. constructor(
  54072. /** defines the name of the probe */
  54073. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54074. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54075. get samples(): number;
  54076. set samples(value: number);
  54077. /** Gets or sets the refresh rate to use (on every frame by default) */
  54078. get refreshRate(): number;
  54079. set refreshRate(value: number);
  54080. /**
  54081. * Gets the hosting scene
  54082. * @returns a Scene
  54083. */
  54084. getScene(): Scene;
  54085. /** Gets the internal CubeTexture used to render to */
  54086. get cubeTexture(): RenderTargetTexture;
  54087. /** Gets the list of meshes to render */
  54088. get renderList(): Nullable<AbstractMesh[]>;
  54089. /**
  54090. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54091. * @param mesh defines the mesh to attach to
  54092. */
  54093. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54094. /**
  54095. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54096. * @param renderingGroupId The rendering group id corresponding to its index
  54097. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54098. */
  54099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54100. /**
  54101. * Clean all associated resources
  54102. */
  54103. dispose(): void;
  54104. /**
  54105. * Converts the reflection probe information to a readable string for debug purpose.
  54106. * @param fullDetails Supports for multiple levels of logging within scene loading
  54107. * @returns the human readable reflection probe info
  54108. */
  54109. toString(fullDetails?: boolean): string;
  54110. /**
  54111. * Get the class name of the relfection probe.
  54112. * @returns "ReflectionProbe"
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54117. * @returns The JSON representation of the texture
  54118. */
  54119. serialize(): any;
  54120. /**
  54121. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54122. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54123. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54124. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54125. * @returns The parsed reflection probe if successful
  54126. */
  54127. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54128. }
  54129. }
  54130. declare module BABYLON {
  54131. /** @hidden */
  54132. export var _BabylonLoaderRegistered: boolean;
  54133. /**
  54134. * Helps setting up some configuration for the babylon file loader.
  54135. */
  54136. export class BabylonFileLoaderConfiguration {
  54137. /**
  54138. * The loader does not allow injecting custom physix engine into the plugins.
  54139. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54140. * So you could set this variable to your engine import to make it work.
  54141. */
  54142. static LoaderInjectedPhysicsEngine: any;
  54143. }
  54144. }
  54145. declare module BABYLON {
  54146. /**
  54147. * The Physically based simple base material of BJS.
  54148. *
  54149. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54150. * It is used as the base class for both the specGloss and metalRough conventions.
  54151. */
  54152. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54153. /**
  54154. * Number of Simultaneous lights allowed on the material.
  54155. */
  54156. maxSimultaneousLights: number;
  54157. /**
  54158. * If sets to true, disables all the lights affecting the material.
  54159. */
  54160. disableLighting: boolean;
  54161. /**
  54162. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54163. */
  54164. environmentTexture: BaseTexture;
  54165. /**
  54166. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54167. */
  54168. invertNormalMapX: boolean;
  54169. /**
  54170. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54171. */
  54172. invertNormalMapY: boolean;
  54173. /**
  54174. * Normal map used in the model.
  54175. */
  54176. normalTexture: BaseTexture;
  54177. /**
  54178. * Emissivie color used to self-illuminate the model.
  54179. */
  54180. emissiveColor: Color3;
  54181. /**
  54182. * Emissivie texture used to self-illuminate the model.
  54183. */
  54184. emissiveTexture: BaseTexture;
  54185. /**
  54186. * Occlusion Channel Strenght.
  54187. */
  54188. occlusionStrength: number;
  54189. /**
  54190. * Occlusion Texture of the material (adding extra occlusion effects).
  54191. */
  54192. occlusionTexture: BaseTexture;
  54193. /**
  54194. * Defines the alpha limits in alpha test mode.
  54195. */
  54196. alphaCutOff: number;
  54197. /**
  54198. * Gets the current double sided mode.
  54199. */
  54200. get doubleSided(): boolean;
  54201. /**
  54202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54203. */
  54204. set doubleSided(value: boolean);
  54205. /**
  54206. * Stores the pre-calculated light information of a mesh in a texture.
  54207. */
  54208. lightmapTexture: BaseTexture;
  54209. /**
  54210. * If true, the light map contains occlusion information instead of lighting info.
  54211. */
  54212. useLightmapAsShadowmap: boolean;
  54213. /**
  54214. * Instantiates a new PBRMaterial instance.
  54215. *
  54216. * @param name The material name
  54217. * @param scene The scene the material will be use in.
  54218. */
  54219. constructor(name: string, scene: Scene);
  54220. getClassName(): string;
  54221. }
  54222. }
  54223. declare module BABYLON {
  54224. /**
  54225. * The PBR material of BJS following the metal roughness convention.
  54226. *
  54227. * This fits to the PBR convention in the GLTF definition:
  54228. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54229. */
  54230. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54231. /**
  54232. * The base color has two different interpretations depending on the value of metalness.
  54233. * When the material is a metal, the base color is the specific measured reflectance value
  54234. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54235. * of the material.
  54236. */
  54237. baseColor: Color3;
  54238. /**
  54239. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54240. * well as opacity information in the alpha channel.
  54241. */
  54242. baseTexture: BaseTexture;
  54243. /**
  54244. * Specifies the metallic scalar value of the material.
  54245. * Can also be used to scale the metalness values of the metallic texture.
  54246. */
  54247. metallic: number;
  54248. /**
  54249. * Specifies the roughness scalar value of the material.
  54250. * Can also be used to scale the roughness values of the metallic texture.
  54251. */
  54252. roughness: number;
  54253. /**
  54254. * Texture containing both the metallic value in the B channel and the
  54255. * roughness value in the G channel to keep better precision.
  54256. */
  54257. metallicRoughnessTexture: BaseTexture;
  54258. /**
  54259. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54260. *
  54261. * @param name The material name
  54262. * @param scene The scene the material will be use in.
  54263. */
  54264. constructor(name: string, scene: Scene);
  54265. /**
  54266. * Return the currrent class name of the material.
  54267. */
  54268. getClassName(): string;
  54269. /**
  54270. * Makes a duplicate of the current material.
  54271. * @param name - name to use for the new material.
  54272. */
  54273. clone(name: string): PBRMetallicRoughnessMaterial;
  54274. /**
  54275. * Serialize the material to a parsable JSON object.
  54276. */
  54277. serialize(): any;
  54278. /**
  54279. * Parses a JSON object correponding to the serialize function.
  54280. */
  54281. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54282. }
  54283. }
  54284. declare module BABYLON {
  54285. /**
  54286. * The PBR material of BJS following the specular glossiness convention.
  54287. *
  54288. * This fits to the PBR convention in the GLTF definition:
  54289. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54290. */
  54291. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54292. /**
  54293. * Specifies the diffuse color of the material.
  54294. */
  54295. diffuseColor: Color3;
  54296. /**
  54297. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54298. * channel.
  54299. */
  54300. diffuseTexture: BaseTexture;
  54301. /**
  54302. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54303. */
  54304. specularColor: Color3;
  54305. /**
  54306. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54307. */
  54308. glossiness: number;
  54309. /**
  54310. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54311. */
  54312. specularGlossinessTexture: BaseTexture;
  54313. /**
  54314. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54315. *
  54316. * @param name The material name
  54317. * @param scene The scene the material will be use in.
  54318. */
  54319. constructor(name: string, scene: Scene);
  54320. /**
  54321. * Return the currrent class name of the material.
  54322. */
  54323. getClassName(): string;
  54324. /**
  54325. * Makes a duplicate of the current material.
  54326. * @param name - name to use for the new material.
  54327. */
  54328. clone(name: string): PBRSpecularGlossinessMaterial;
  54329. /**
  54330. * Serialize the material to a parsable JSON object.
  54331. */
  54332. serialize(): any;
  54333. /**
  54334. * Parses a JSON object correponding to the serialize function.
  54335. */
  54336. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54337. }
  54338. }
  54339. declare module BABYLON {
  54340. /**
  54341. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54342. * It can help converting any input color in a desired output one. This can then be used to create effects
  54343. * from sepia, black and white to sixties or futuristic rendering...
  54344. *
  54345. * The only supported format is currently 3dl.
  54346. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54347. */
  54348. export class ColorGradingTexture extends BaseTexture {
  54349. /**
  54350. * The current texture matrix. (will always be identity in color grading texture)
  54351. */
  54352. private _textureMatrix;
  54353. /**
  54354. * The texture URL.
  54355. */
  54356. url: string;
  54357. /**
  54358. * Empty line regex stored for GC.
  54359. */
  54360. private static _noneEmptyLineRegex;
  54361. private _engine;
  54362. /**
  54363. * Instantiates a ColorGradingTexture from the following parameters.
  54364. *
  54365. * @param url The location of the color gradind data (currently only supporting 3dl)
  54366. * @param scene The scene the texture will be used in
  54367. */
  54368. constructor(url: string, scene: Scene);
  54369. /**
  54370. * Returns the texture matrix used in most of the material.
  54371. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54372. */
  54373. getTextureMatrix(): Matrix;
  54374. /**
  54375. * Occurs when the file being loaded is a .3dl LUT file.
  54376. */
  54377. private load3dlTexture;
  54378. /**
  54379. * Starts the loading process of the texture.
  54380. */
  54381. private loadTexture;
  54382. /**
  54383. * Clones the color gradind texture.
  54384. */
  54385. clone(): ColorGradingTexture;
  54386. /**
  54387. * Called during delayed load for textures.
  54388. */
  54389. delayLoad(): void;
  54390. /**
  54391. * Parses a color grading texture serialized by Babylon.
  54392. * @param parsedTexture The texture information being parsedTexture
  54393. * @param scene The scene to load the texture in
  54394. * @param rootUrl The root url of the data assets to load
  54395. * @return A color gradind texture
  54396. */
  54397. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54398. /**
  54399. * Serializes the LUT texture to json format.
  54400. */
  54401. serialize(): any;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54407. */
  54408. export class EquiRectangularCubeTexture extends BaseTexture {
  54409. /** The six faces of the cube. */
  54410. private static _FacesMapping;
  54411. private _noMipmap;
  54412. private _onLoad;
  54413. private _onError;
  54414. /** The size of the cubemap. */
  54415. private _size;
  54416. /** The buffer of the image. */
  54417. private _buffer;
  54418. /** The width of the input image. */
  54419. private _width;
  54420. /** The height of the input image. */
  54421. private _height;
  54422. /** The URL to the image. */
  54423. url: string;
  54424. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54425. coordinatesMode: number;
  54426. /**
  54427. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54428. * @param url The location of the image
  54429. * @param scene The scene the texture will be used in
  54430. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54431. * @param noMipmap Forces to not generate the mipmap if true
  54432. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54433. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54434. * @param onLoad — defines a callback called when texture is loaded
  54435. * @param onError — defines a callback called if there is an error
  54436. */
  54437. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54438. /**
  54439. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54440. */
  54441. private loadImage;
  54442. /**
  54443. * Convert the image buffer into a cubemap and create a CubeTexture.
  54444. */
  54445. private loadTexture;
  54446. /**
  54447. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54448. * @param buffer The ArrayBuffer that should be converted.
  54449. * @returns The buffer as Float32Array.
  54450. */
  54451. private getFloat32ArrayFromArrayBuffer;
  54452. /**
  54453. * Get the current class name of the texture useful for serialization or dynamic coding.
  54454. * @returns "EquiRectangularCubeTexture"
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54459. * @returns A clone of the current EquiRectangularCubeTexture.
  54460. */
  54461. clone(): EquiRectangularCubeTexture;
  54462. }
  54463. }
  54464. declare module BABYLON {
  54465. /**
  54466. * Based on jsTGALoader - Javascript loader for TGA file
  54467. * By Vincent Thibault
  54468. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54469. */
  54470. export class TGATools {
  54471. private static _TYPE_INDEXED;
  54472. private static _TYPE_RGB;
  54473. private static _TYPE_GREY;
  54474. private static _TYPE_RLE_INDEXED;
  54475. private static _TYPE_RLE_RGB;
  54476. private static _TYPE_RLE_GREY;
  54477. private static _ORIGIN_MASK;
  54478. private static _ORIGIN_SHIFT;
  54479. private static _ORIGIN_BL;
  54480. private static _ORIGIN_BR;
  54481. private static _ORIGIN_UL;
  54482. private static _ORIGIN_UR;
  54483. /**
  54484. * Gets the header of a TGA file
  54485. * @param data defines the TGA data
  54486. * @returns the header
  54487. */
  54488. static GetTGAHeader(data: Uint8Array): any;
  54489. /**
  54490. * Uploads TGA content to a Babylon Texture
  54491. * @hidden
  54492. */
  54493. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54494. /** @hidden */
  54495. 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;
  54496. /** @hidden */
  54497. 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;
  54498. /** @hidden */
  54499. 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;
  54500. /** @hidden */
  54501. 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;
  54502. /** @hidden */
  54503. 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;
  54504. /** @hidden */
  54505. 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;
  54506. }
  54507. }
  54508. declare module BABYLON {
  54509. /**
  54510. * Implementation of the TGA Texture Loader.
  54511. * @hidden
  54512. */
  54513. export class _TGATextureLoader implements IInternalTextureLoader {
  54514. /**
  54515. * Defines wether the loader supports cascade loading the different faces.
  54516. */
  54517. readonly supportCascades: boolean;
  54518. /**
  54519. * This returns if the loader support the current file information.
  54520. * @param extension defines the file extension of the file being loaded
  54521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54522. * @param fallback defines the fallback internal texture if any
  54523. * @param isBase64 defines whether the texture is encoded as a base64
  54524. * @param isBuffer defines whether the texture data are stored as a buffer
  54525. * @returns true if the loader can load the specified file
  54526. */
  54527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54528. /**
  54529. * Transform the url before loading if required.
  54530. * @param rootUrl the url of the texture
  54531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54532. * @returns the transformed texture
  54533. */
  54534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54535. /**
  54536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54537. * @param rootUrl the url of the texture
  54538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54539. * @returns the fallback texture
  54540. */
  54541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54542. /**
  54543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54544. * @param data contains the texture data
  54545. * @param texture defines the BabylonJS internal texture
  54546. * @param createPolynomials will be true if polynomials have been requested
  54547. * @param onLoad defines the callback to trigger once the texture is ready
  54548. * @param onError defines the callback to trigger in case of error
  54549. */
  54550. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54551. /**
  54552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54553. * @param data contains the texture data
  54554. * @param texture defines the BabylonJS internal texture
  54555. * @param callback defines the method to call once ready to upload
  54556. */
  54557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54558. }
  54559. }
  54560. declare module BABYLON {
  54561. /**
  54562. * Info about the .basis files
  54563. */
  54564. class BasisFileInfo {
  54565. /**
  54566. * If the file has alpha
  54567. */
  54568. hasAlpha: boolean;
  54569. /**
  54570. * Info about each image of the basis file
  54571. */
  54572. images: Array<{
  54573. levels: Array<{
  54574. width: number;
  54575. height: number;
  54576. transcodedPixels: ArrayBufferView;
  54577. }>;
  54578. }>;
  54579. }
  54580. /**
  54581. * Result of transcoding a basis file
  54582. */
  54583. class TranscodeResult {
  54584. /**
  54585. * Info about the .basis file
  54586. */
  54587. fileInfo: BasisFileInfo;
  54588. /**
  54589. * Format to use when loading the file
  54590. */
  54591. format: number;
  54592. }
  54593. /**
  54594. * Configuration options for the Basis transcoder
  54595. */
  54596. export class BasisTranscodeConfiguration {
  54597. /**
  54598. * Supported compression formats used to determine the supported output format of the transcoder
  54599. */
  54600. supportedCompressionFormats?: {
  54601. /**
  54602. * etc1 compression format
  54603. */
  54604. etc1?: boolean;
  54605. /**
  54606. * s3tc compression format
  54607. */
  54608. s3tc?: boolean;
  54609. /**
  54610. * pvrtc compression format
  54611. */
  54612. pvrtc?: boolean;
  54613. /**
  54614. * etc2 compression format
  54615. */
  54616. etc2?: boolean;
  54617. };
  54618. /**
  54619. * If mipmap levels should be loaded for transcoded images (Default: true)
  54620. */
  54621. loadMipmapLevels?: boolean;
  54622. /**
  54623. * Index of a single image to load (Default: all images)
  54624. */
  54625. loadSingleImage?: number;
  54626. }
  54627. /**
  54628. * Used to load .Basis files
  54629. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54630. */
  54631. export class BasisTools {
  54632. private static _IgnoreSupportedFormats;
  54633. /**
  54634. * URL to use when loading the basis transcoder
  54635. */
  54636. static JSModuleURL: string;
  54637. /**
  54638. * URL to use when loading the wasm module for the transcoder
  54639. */
  54640. static WasmModuleURL: string;
  54641. /**
  54642. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54643. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54644. * @returns internal format corresponding to the Basis format
  54645. */
  54646. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54647. private static _WorkerPromise;
  54648. private static _Worker;
  54649. private static _actionId;
  54650. private static _CreateWorkerAsync;
  54651. /**
  54652. * Transcodes a loaded image file to compressed pixel data
  54653. * @param imageData image data to transcode
  54654. * @param config configuration options for the transcoding
  54655. * @returns a promise resulting in the transcoded image
  54656. */
  54657. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54658. /**
  54659. * Loads a texture from the transcode result
  54660. * @param texture texture load to
  54661. * @param transcodeResult the result of transcoding the basis file to load from
  54662. */
  54663. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54664. }
  54665. }
  54666. declare module BABYLON {
  54667. /**
  54668. * Loader for .basis file format
  54669. */
  54670. export class _BasisTextureLoader implements IInternalTextureLoader {
  54671. /**
  54672. * Defines whether the loader supports cascade loading the different faces.
  54673. */
  54674. readonly supportCascades: boolean;
  54675. /**
  54676. * This returns if the loader support the current file information.
  54677. * @param extension defines the file extension of the file being loaded
  54678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54679. * @param fallback defines the fallback internal texture if any
  54680. * @param isBase64 defines whether the texture is encoded as a base64
  54681. * @param isBuffer defines whether the texture data are stored as a buffer
  54682. * @returns true if the loader can load the specified file
  54683. */
  54684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54685. /**
  54686. * Transform the url before loading if required.
  54687. * @param rootUrl the url of the texture
  54688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54689. * @returns the transformed texture
  54690. */
  54691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54692. /**
  54693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54694. * @param rootUrl the url of the texture
  54695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54696. * @returns the fallback texture
  54697. */
  54698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54699. /**
  54700. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54701. * @param data contains the texture data
  54702. * @param texture defines the BabylonJS internal texture
  54703. * @param createPolynomials will be true if polynomials have been requested
  54704. * @param onLoad defines the callback to trigger once the texture is ready
  54705. * @param onError defines the callback to trigger in case of error
  54706. */
  54707. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54708. /**
  54709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54710. * @param data contains the texture data
  54711. * @param texture defines the BabylonJS internal texture
  54712. * @param callback defines the method to call once ready to upload
  54713. */
  54714. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54715. }
  54716. }
  54717. declare module BABYLON {
  54718. /**
  54719. * 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.
  54720. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54722. */
  54723. export class CustomProceduralTexture extends ProceduralTexture {
  54724. private _animate;
  54725. private _time;
  54726. private _config;
  54727. private _texturePath;
  54728. /**
  54729. * Instantiates a new Custom Procedural Texture.
  54730. * 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.
  54731. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54732. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54733. * @param name Define the name of the texture
  54734. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54735. * @param size Define the size of the texture to create
  54736. * @param scene Define the scene the texture belongs to
  54737. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54738. * @param generateMipMaps Define if the texture should creates mip maps or not
  54739. */
  54740. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54741. private _loadJson;
  54742. /**
  54743. * Is the texture ready to be used ? (rendered at least once)
  54744. * @returns true if ready, otherwise, false.
  54745. */
  54746. isReady(): boolean;
  54747. /**
  54748. * Render the texture to its associated render target.
  54749. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54750. */
  54751. render(useCameraPostProcess?: boolean): void;
  54752. /**
  54753. * Update the list of dependant textures samplers in the shader.
  54754. */
  54755. updateTextures(): void;
  54756. /**
  54757. * Update the uniform values of the procedural texture in the shader.
  54758. */
  54759. updateShaderUniforms(): void;
  54760. /**
  54761. * Define if the texture animates or not.
  54762. */
  54763. get animate(): boolean;
  54764. set animate(value: boolean);
  54765. }
  54766. }
  54767. declare module BABYLON {
  54768. /** @hidden */
  54769. export var noisePixelShader: {
  54770. name: string;
  54771. shader: string;
  54772. };
  54773. }
  54774. declare module BABYLON {
  54775. /**
  54776. * Class used to generate noise procedural textures
  54777. */
  54778. export class NoiseProceduralTexture extends ProceduralTexture {
  54779. private _time;
  54780. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54781. brightness: number;
  54782. /** Defines the number of octaves to process */
  54783. octaves: number;
  54784. /** Defines the level of persistence (0.8 by default) */
  54785. persistence: number;
  54786. /** Gets or sets animation speed factor (default is 1) */
  54787. animationSpeedFactor: number;
  54788. /**
  54789. * Creates a new NoiseProceduralTexture
  54790. * @param name defines the name fo the texture
  54791. * @param size defines the size of the texture (default is 256)
  54792. * @param scene defines the hosting scene
  54793. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54794. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54795. */
  54796. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54797. private _updateShaderUniforms;
  54798. protected _getDefines(): string;
  54799. /** Generate the current state of the procedural texture */
  54800. render(useCameraPostProcess?: boolean): void;
  54801. /**
  54802. * Serializes this noise procedural texture
  54803. * @returns a serialized noise procedural texture object
  54804. */
  54805. serialize(): any;
  54806. /**
  54807. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54808. * @param parsedTexture defines parsed texture data
  54809. * @param scene defines the current scene
  54810. * @param rootUrl defines the root URL containing noise procedural texture information
  54811. * @returns a parsed NoiseProceduralTexture
  54812. */
  54813. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54814. }
  54815. }
  54816. declare module BABYLON {
  54817. /**
  54818. * Raw cube texture where the raw buffers are passed in
  54819. */
  54820. export class RawCubeTexture extends CubeTexture {
  54821. /**
  54822. * Creates a cube texture where the raw buffers are passed in.
  54823. * @param scene defines the scene the texture is attached to
  54824. * @param data defines the array of data to use to create each face
  54825. * @param size defines the size of the textures
  54826. * @param format defines the format of the data
  54827. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54828. * @param generateMipMaps defines if the engine should generate the mip levels
  54829. * @param invertY defines if data must be stored with Y axis inverted
  54830. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54831. * @param compression defines the compression used (null by default)
  54832. */
  54833. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54834. /**
  54835. * Updates the raw cube texture.
  54836. * @param data defines the data to store
  54837. * @param format defines the data format
  54838. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54839. * @param invertY defines if data must be stored with Y axis inverted
  54840. * @param compression defines the compression used (null by default)
  54841. * @param level defines which level of the texture to update
  54842. */
  54843. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54844. /**
  54845. * Updates a raw cube texture with RGBD encoded data.
  54846. * @param data defines the array of data [mipmap][face] to use to create each face
  54847. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54850. * @returns a promsie that resolves when the operation is complete
  54851. */
  54852. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54853. /**
  54854. * Clones the raw cube texture.
  54855. * @return a new cube texture
  54856. */
  54857. clone(): CubeTexture;
  54858. /** @hidden */
  54859. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /**
  54864. * Class used to store 3D textures containing user data
  54865. */
  54866. export class RawTexture3D extends Texture {
  54867. /** Gets or sets the texture format to use */
  54868. format: number;
  54869. private _engine;
  54870. /**
  54871. * Create a new RawTexture3D
  54872. * @param data defines the data of the texture
  54873. * @param width defines the width of the texture
  54874. * @param height defines the height of the texture
  54875. * @param depth defines the depth of the texture
  54876. * @param format defines the texture format to use
  54877. * @param scene defines the hosting scene
  54878. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54879. * @param invertY defines if texture must be stored with Y axis inverted
  54880. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54881. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54882. */
  54883. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54884. /** Gets or sets the texture format to use */
  54885. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54886. /**
  54887. * Update the texture with new data
  54888. * @param data defines the data to store in the texture
  54889. */
  54890. update(data: ArrayBufferView): void;
  54891. }
  54892. }
  54893. declare module BABYLON {
  54894. /**
  54895. * Class used to store 2D array textures containing user data
  54896. */
  54897. export class RawTexture2DArray extends Texture {
  54898. /** Gets or sets the texture format to use */
  54899. format: number;
  54900. private _engine;
  54901. /**
  54902. * Create a new RawTexture2DArray
  54903. * @param data defines the data of the texture
  54904. * @param width defines the width of the texture
  54905. * @param height defines the height of the texture
  54906. * @param depth defines the number of layers of the texture
  54907. * @param format defines the texture format to use
  54908. * @param scene defines the hosting scene
  54909. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54910. * @param invertY defines if texture must be stored with Y axis inverted
  54911. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54912. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54913. */
  54914. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54915. /** Gets or sets the texture format to use */
  54916. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54917. /**
  54918. * Update the texture with new data
  54919. * @param data defines the data to store in the texture
  54920. */
  54921. update(data: ArrayBufferView): void;
  54922. }
  54923. }
  54924. declare module BABYLON {
  54925. /**
  54926. * Creates a refraction texture used by refraction channel of the standard material.
  54927. * It is like a mirror but to see through a material.
  54928. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54929. */
  54930. export class RefractionTexture extends RenderTargetTexture {
  54931. /**
  54932. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54933. * 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.
  54934. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54935. */
  54936. refractionPlane: Plane;
  54937. /**
  54938. * Define how deep under the surface we should see.
  54939. */
  54940. depth: number;
  54941. /**
  54942. * Creates a refraction texture used by refraction channel of the standard material.
  54943. * It is like a mirror but to see through a material.
  54944. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54945. * @param name Define the texture name
  54946. * @param size Define the size of the underlying texture
  54947. * @param scene Define the scene the refraction belongs to
  54948. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54949. */
  54950. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54951. /**
  54952. * Clone the refraction texture.
  54953. * @returns the cloned texture
  54954. */
  54955. clone(): RefractionTexture;
  54956. /**
  54957. * Serialize the texture to a JSON representation you could use in Parse later on
  54958. * @returns the serialized JSON representation
  54959. */
  54960. serialize(): any;
  54961. }
  54962. }
  54963. declare module BABYLON {
  54964. /**
  54965. * Defines the options related to the creation of an HtmlElementTexture
  54966. */
  54967. export interface IHtmlElementTextureOptions {
  54968. /**
  54969. * Defines wether mip maps should be created or not.
  54970. */
  54971. generateMipMaps?: boolean;
  54972. /**
  54973. * Defines the sampling mode of the texture.
  54974. */
  54975. samplingMode?: number;
  54976. /**
  54977. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54978. */
  54979. engine: Nullable<ThinEngine>;
  54980. /**
  54981. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54982. */
  54983. scene: Nullable<Scene>;
  54984. }
  54985. /**
  54986. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54987. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54988. * is automatically managed.
  54989. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54990. * in your application.
  54991. *
  54992. * As the update is not automatic, you need to call them manually.
  54993. */
  54994. export class HtmlElementTexture extends BaseTexture {
  54995. /**
  54996. * The texture URL.
  54997. */
  54998. element: HTMLVideoElement | HTMLCanvasElement;
  54999. private static readonly DefaultOptions;
  55000. private _textureMatrix;
  55001. private _engine;
  55002. private _isVideo;
  55003. private _generateMipMaps;
  55004. private _samplingMode;
  55005. /**
  55006. * Instantiates a HtmlElementTexture from the following parameters.
  55007. *
  55008. * @param name Defines the name of the texture
  55009. * @param element Defines the video or canvas the texture is filled with
  55010. * @param options Defines the other none mandatory texture creation options
  55011. */
  55012. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55013. private _createInternalTexture;
  55014. /**
  55015. * Returns the texture matrix used in most of the material.
  55016. */
  55017. getTextureMatrix(): Matrix;
  55018. /**
  55019. * Updates the content of the texture.
  55020. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55021. */
  55022. update(invertY?: Nullable<boolean>): void;
  55023. }
  55024. }
  55025. declare module BABYLON {
  55026. /**
  55027. * Enum used to define the target of a block
  55028. */
  55029. export enum NodeMaterialBlockTargets {
  55030. /** Vertex shader */
  55031. Vertex = 1,
  55032. /** Fragment shader */
  55033. Fragment = 2,
  55034. /** Neutral */
  55035. Neutral = 4,
  55036. /** Vertex and Fragment */
  55037. VertexAndFragment = 3
  55038. }
  55039. }
  55040. declare module BABYLON {
  55041. /**
  55042. * Defines the kind of connection point for node based material
  55043. */
  55044. export enum NodeMaterialBlockConnectionPointTypes {
  55045. /** Float */
  55046. Float = 1,
  55047. /** Int */
  55048. Int = 2,
  55049. /** Vector2 */
  55050. Vector2 = 4,
  55051. /** Vector3 */
  55052. Vector3 = 8,
  55053. /** Vector4 */
  55054. Vector4 = 16,
  55055. /** Color3 */
  55056. Color3 = 32,
  55057. /** Color4 */
  55058. Color4 = 64,
  55059. /** Matrix */
  55060. Matrix = 128,
  55061. /** Detect type based on connection */
  55062. AutoDetect = 1024,
  55063. /** Output type that will be defined by input type */
  55064. BasedOnInput = 2048
  55065. }
  55066. }
  55067. declare module BABYLON {
  55068. /**
  55069. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55070. */
  55071. export enum NodeMaterialBlockConnectionPointMode {
  55072. /** Value is an uniform */
  55073. Uniform = 0,
  55074. /** Value is a mesh attribute */
  55075. Attribute = 1,
  55076. /** Value is a varying between vertex and fragment shaders */
  55077. Varying = 2,
  55078. /** Mode is undefined */
  55079. Undefined = 3
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * Enum used to define system values e.g. values automatically provided by the system
  55085. */
  55086. export enum NodeMaterialSystemValues {
  55087. /** World */
  55088. World = 1,
  55089. /** View */
  55090. View = 2,
  55091. /** Projection */
  55092. Projection = 3,
  55093. /** ViewProjection */
  55094. ViewProjection = 4,
  55095. /** WorldView */
  55096. WorldView = 5,
  55097. /** WorldViewProjection */
  55098. WorldViewProjection = 6,
  55099. /** CameraPosition */
  55100. CameraPosition = 7,
  55101. /** Fog Color */
  55102. FogColor = 8,
  55103. /** Delta time */
  55104. DeltaTime = 9
  55105. }
  55106. }
  55107. declare module BABYLON {
  55108. /**
  55109. * Root class for all node material optimizers
  55110. */
  55111. export class NodeMaterialOptimizer {
  55112. /**
  55113. * Function used to optimize a NodeMaterial graph
  55114. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55115. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55116. */
  55117. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /**
  55122. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55123. */
  55124. export class TransformBlock extends NodeMaterialBlock {
  55125. /**
  55126. * Defines the value to use to complement W value to transform it to a Vector4
  55127. */
  55128. complementW: number;
  55129. /**
  55130. * Defines the value to use to complement z value to transform it to a Vector4
  55131. */
  55132. complementZ: number;
  55133. /**
  55134. * Creates a new TransformBlock
  55135. * @param name defines the block name
  55136. */
  55137. constructor(name: string);
  55138. /**
  55139. * Gets the current class name
  55140. * @returns the class name
  55141. */
  55142. getClassName(): string;
  55143. /**
  55144. * Gets the vector input
  55145. */
  55146. get vector(): NodeMaterialConnectionPoint;
  55147. /**
  55148. * Gets the output component
  55149. */
  55150. get output(): NodeMaterialConnectionPoint;
  55151. /**
  55152. * Gets the matrix transform input
  55153. */
  55154. get transform(): NodeMaterialConnectionPoint;
  55155. protected _buildBlock(state: NodeMaterialBuildState): this;
  55156. serialize(): any;
  55157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55158. protected _dumpPropertiesCode(): string;
  55159. }
  55160. }
  55161. declare module BABYLON {
  55162. /**
  55163. * Block used to output the vertex position
  55164. */
  55165. export class VertexOutputBlock extends NodeMaterialBlock {
  55166. /**
  55167. * Creates a new VertexOutputBlock
  55168. * @param name defines the block name
  55169. */
  55170. constructor(name: string);
  55171. /**
  55172. * Gets the current class name
  55173. * @returns the class name
  55174. */
  55175. getClassName(): string;
  55176. /**
  55177. * Gets the vector input component
  55178. */
  55179. get vector(): NodeMaterialConnectionPoint;
  55180. protected _buildBlock(state: NodeMaterialBuildState): this;
  55181. }
  55182. }
  55183. declare module BABYLON {
  55184. /**
  55185. * Block used to output the final color
  55186. */
  55187. export class FragmentOutputBlock extends NodeMaterialBlock {
  55188. /**
  55189. * Create a new FragmentOutputBlock
  55190. * @param name defines the block name
  55191. */
  55192. constructor(name: string);
  55193. /**
  55194. * Gets the current class name
  55195. * @returns the class name
  55196. */
  55197. getClassName(): string;
  55198. /**
  55199. * Gets the rgba input component
  55200. */
  55201. get rgba(): NodeMaterialConnectionPoint;
  55202. /**
  55203. * Gets the rgb input component
  55204. */
  55205. get rgb(): NodeMaterialConnectionPoint;
  55206. /**
  55207. * Gets the a input component
  55208. */
  55209. get a(): NodeMaterialConnectionPoint;
  55210. protected _buildBlock(state: NodeMaterialBuildState): this;
  55211. }
  55212. }
  55213. declare module BABYLON {
  55214. /**
  55215. * Block used to read a reflection texture from a sampler
  55216. */
  55217. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55218. private _define3DName;
  55219. private _defineCubicName;
  55220. private _defineExplicitName;
  55221. private _defineProjectionName;
  55222. private _defineLocalCubicName;
  55223. private _defineSphericalName;
  55224. private _definePlanarName;
  55225. private _defineEquirectangularName;
  55226. private _defineMirroredEquirectangularFixedName;
  55227. private _defineEquirectangularFixedName;
  55228. private _defineSkyboxName;
  55229. private _cubeSamplerName;
  55230. private _2DSamplerName;
  55231. private _positionUVWName;
  55232. private _directionWName;
  55233. private _reflectionCoordsName;
  55234. private _reflection2DCoordsName;
  55235. private _reflectionColorName;
  55236. private _reflectionMatrixName;
  55237. /**
  55238. * Gets or sets the texture associated with the node
  55239. */
  55240. texture: Nullable<BaseTexture>;
  55241. /**
  55242. * Create a new TextureBlock
  55243. * @param name defines the block name
  55244. */
  55245. constructor(name: string);
  55246. /**
  55247. * Gets the current class name
  55248. * @returns the class name
  55249. */
  55250. getClassName(): string;
  55251. /**
  55252. * Gets the world position input component
  55253. */
  55254. get position(): NodeMaterialConnectionPoint;
  55255. /**
  55256. * Gets the world position input component
  55257. */
  55258. get worldPosition(): NodeMaterialConnectionPoint;
  55259. /**
  55260. * Gets the world normal input component
  55261. */
  55262. get worldNormal(): NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the world input component
  55265. */
  55266. get world(): NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the camera (or eye) position component
  55269. */
  55270. get cameraPosition(): NodeMaterialConnectionPoint;
  55271. /**
  55272. * Gets the view input component
  55273. */
  55274. get view(): NodeMaterialConnectionPoint;
  55275. /**
  55276. * Gets the rgb output component
  55277. */
  55278. get rgb(): NodeMaterialConnectionPoint;
  55279. /**
  55280. * Gets the r output component
  55281. */
  55282. get r(): NodeMaterialConnectionPoint;
  55283. /**
  55284. * Gets the g output component
  55285. */
  55286. get g(): NodeMaterialConnectionPoint;
  55287. /**
  55288. * Gets the b output component
  55289. */
  55290. get b(): NodeMaterialConnectionPoint;
  55291. autoConfigure(material: NodeMaterial): void;
  55292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55293. isReady(): boolean;
  55294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55295. private _injectVertexCode;
  55296. private _writeOutput;
  55297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55298. protected _dumpPropertiesCode(): string;
  55299. serialize(): any;
  55300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /**
  55305. * Interface used to configure the node material editor
  55306. */
  55307. export interface INodeMaterialEditorOptions {
  55308. /** Define the URl to load node editor script */
  55309. editorURL?: string;
  55310. }
  55311. /** @hidden */
  55312. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55313. /** BONES */
  55314. NUM_BONE_INFLUENCERS: number;
  55315. BonesPerMesh: number;
  55316. BONETEXTURE: boolean;
  55317. /** MORPH TARGETS */
  55318. MORPHTARGETS: boolean;
  55319. MORPHTARGETS_NORMAL: boolean;
  55320. MORPHTARGETS_TANGENT: boolean;
  55321. MORPHTARGETS_UV: boolean;
  55322. NUM_MORPH_INFLUENCERS: number;
  55323. /** IMAGE PROCESSING */
  55324. IMAGEPROCESSING: boolean;
  55325. VIGNETTE: boolean;
  55326. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55327. VIGNETTEBLENDMODEOPAQUE: boolean;
  55328. TONEMAPPING: boolean;
  55329. TONEMAPPING_ACES: boolean;
  55330. CONTRAST: boolean;
  55331. EXPOSURE: boolean;
  55332. COLORCURVES: boolean;
  55333. COLORGRADING: boolean;
  55334. COLORGRADING3D: boolean;
  55335. SAMPLER3DGREENDEPTH: boolean;
  55336. SAMPLER3DBGRMAP: boolean;
  55337. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55338. /** MISC. */
  55339. BUMPDIRECTUV: number;
  55340. constructor();
  55341. setValue(name: string, value: boolean): void;
  55342. }
  55343. /**
  55344. * Class used to configure NodeMaterial
  55345. */
  55346. export interface INodeMaterialOptions {
  55347. /**
  55348. * Defines if blocks should emit comments
  55349. */
  55350. emitComments: boolean;
  55351. }
  55352. /**
  55353. * Class used to create a node based material built by assembling shader blocks
  55354. */
  55355. export class NodeMaterial extends PushMaterial {
  55356. private static _BuildIdGenerator;
  55357. private _options;
  55358. private _vertexCompilationState;
  55359. private _fragmentCompilationState;
  55360. private _sharedData;
  55361. private _buildId;
  55362. private _buildWasSuccessful;
  55363. private _cachedWorldViewMatrix;
  55364. private _cachedWorldViewProjectionMatrix;
  55365. private _optimizers;
  55366. private _animationFrame;
  55367. /** Define the URl to load node editor script */
  55368. static EditorURL: string;
  55369. private BJSNODEMATERIALEDITOR;
  55370. /** Get the inspector from bundle or global */
  55371. private _getGlobalNodeMaterialEditor;
  55372. /**
  55373. * Gets or sets data used by visual editor
  55374. * @see https://nme.babylonjs.com
  55375. */
  55376. editorData: any;
  55377. /**
  55378. * 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)
  55379. */
  55380. ignoreAlpha: boolean;
  55381. /**
  55382. * Defines the maximum number of lights that can be used in the material
  55383. */
  55384. maxSimultaneousLights: number;
  55385. /**
  55386. * Observable raised when the material is built
  55387. */
  55388. onBuildObservable: Observable<NodeMaterial>;
  55389. /**
  55390. * Gets or sets the root nodes of the material vertex shader
  55391. */
  55392. _vertexOutputNodes: NodeMaterialBlock[];
  55393. /**
  55394. * Gets or sets the root nodes of the material fragment (pixel) shader
  55395. */
  55396. _fragmentOutputNodes: NodeMaterialBlock[];
  55397. /** Gets or sets options to control the node material overall behavior */
  55398. get options(): INodeMaterialOptions;
  55399. set options(options: INodeMaterialOptions);
  55400. /**
  55401. * Default configuration related to image processing available in the standard Material.
  55402. */
  55403. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55404. /**
  55405. * Gets the image processing configuration used either in this material.
  55406. */
  55407. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55408. /**
  55409. * Sets the Default image processing configuration used either in the this material.
  55410. *
  55411. * If sets to null, the scene one is in use.
  55412. */
  55413. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55414. /**
  55415. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55416. */
  55417. attachedBlocks: NodeMaterialBlock[];
  55418. /**
  55419. * Create a new node based material
  55420. * @param name defines the material name
  55421. * @param scene defines the hosting scene
  55422. * @param options defines creation option
  55423. */
  55424. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55425. /**
  55426. * Gets the current class name of the material e.g. "NodeMaterial"
  55427. * @returns the class name
  55428. */
  55429. getClassName(): string;
  55430. /**
  55431. * Keep track of the image processing observer to allow dispose and replace.
  55432. */
  55433. private _imageProcessingObserver;
  55434. /**
  55435. * Attaches a new image processing configuration to the Standard Material.
  55436. * @param configuration
  55437. */
  55438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55439. /**
  55440. * Get a block by its name
  55441. * @param name defines the name of the block to retrieve
  55442. * @returns the required block or null if not found
  55443. */
  55444. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55445. /**
  55446. * Get a block by its name
  55447. * @param predicate defines the predicate used to find the good candidate
  55448. * @returns the required block or null if not found
  55449. */
  55450. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55451. /**
  55452. * Get an input block by its name
  55453. * @param predicate defines the predicate used to find the good candidate
  55454. * @returns the required input block or null if not found
  55455. */
  55456. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55457. /**
  55458. * Gets the list of input blocks attached to this material
  55459. * @returns an array of InputBlocks
  55460. */
  55461. getInputBlocks(): InputBlock[];
  55462. /**
  55463. * Adds a new optimizer to the list of optimizers
  55464. * @param optimizer defines the optimizers to add
  55465. * @returns the current material
  55466. */
  55467. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55468. /**
  55469. * Remove an optimizer from the list of optimizers
  55470. * @param optimizer defines the optimizers to remove
  55471. * @returns the current material
  55472. */
  55473. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55474. /**
  55475. * Add a new block to the list of output nodes
  55476. * @param node defines the node to add
  55477. * @returns the current material
  55478. */
  55479. addOutputNode(node: NodeMaterialBlock): this;
  55480. /**
  55481. * Remove a block from the list of root nodes
  55482. * @param node defines the node to remove
  55483. * @returns the current material
  55484. */
  55485. removeOutputNode(node: NodeMaterialBlock): this;
  55486. private _addVertexOutputNode;
  55487. private _removeVertexOutputNode;
  55488. private _addFragmentOutputNode;
  55489. private _removeFragmentOutputNode;
  55490. /**
  55491. * Specifies if the material will require alpha blending
  55492. * @returns a boolean specifying if alpha blending is needed
  55493. */
  55494. needAlphaBlending(): boolean;
  55495. /**
  55496. * Specifies if this material should be rendered in alpha test mode
  55497. * @returns a boolean specifying if an alpha test is needed.
  55498. */
  55499. needAlphaTesting(): boolean;
  55500. private _initializeBlock;
  55501. private _resetDualBlocks;
  55502. /**
  55503. * Remove a block from the current node material
  55504. * @param block defines the block to remove
  55505. */
  55506. removeBlock(block: NodeMaterialBlock): void;
  55507. /**
  55508. * Build the material and generates the inner effect
  55509. * @param verbose defines if the build should log activity
  55510. */
  55511. build(verbose?: boolean): void;
  55512. /**
  55513. * Runs an otpimization phase to try to improve the shader code
  55514. */
  55515. optimize(): void;
  55516. private _prepareDefinesForAttributes;
  55517. /**
  55518. * Get if the submesh is ready to be used and all its information available.
  55519. * Child classes can use it to update shaders
  55520. * @param mesh defines the mesh to check
  55521. * @param subMesh defines which submesh to check
  55522. * @param useInstances specifies that instances should be used
  55523. * @returns a boolean indicating that the submesh is ready or not
  55524. */
  55525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55526. /**
  55527. * Get a string representing the shaders built by the current node graph
  55528. */
  55529. get compiledShaders(): string;
  55530. /**
  55531. * Binds the world matrix to the material
  55532. * @param world defines the world transformation matrix
  55533. */
  55534. bindOnlyWorldMatrix(world: Matrix): void;
  55535. /**
  55536. * Binds the submesh to this material by preparing the effect and shader to draw
  55537. * @param world defines the world transformation matrix
  55538. * @param mesh defines the mesh containing the submesh
  55539. * @param subMesh defines the submesh to bind the material to
  55540. */
  55541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55542. /**
  55543. * Gets the active textures from the material
  55544. * @returns an array of textures
  55545. */
  55546. getActiveTextures(): BaseTexture[];
  55547. /**
  55548. * Gets the list of texture blocks
  55549. * @returns an array of texture blocks
  55550. */
  55551. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55552. /**
  55553. * Specifies if the material uses a texture
  55554. * @param texture defines the texture to check against the material
  55555. * @returns a boolean specifying if the material uses the texture
  55556. */
  55557. hasTexture(texture: BaseTexture): boolean;
  55558. /**
  55559. * Disposes the material
  55560. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55561. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55562. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55563. */
  55564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55565. /** Creates the node editor window. */
  55566. private _createNodeEditor;
  55567. /**
  55568. * Launch the node material editor
  55569. * @param config Define the configuration of the editor
  55570. * @return a promise fulfilled when the node editor is visible
  55571. */
  55572. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55573. /**
  55574. * Clear the current material
  55575. */
  55576. clear(): void;
  55577. /**
  55578. * Clear the current material and set it to a default state
  55579. */
  55580. setToDefault(): void;
  55581. /**
  55582. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55583. * @param url defines the url to load from
  55584. * @returns a promise that will fullfil when the material is fully loaded
  55585. */
  55586. loadAsync(url: string): Promise<void>;
  55587. private _gatherBlocks;
  55588. /**
  55589. * Generate a string containing the code declaration required to create an equivalent of this material
  55590. * @returns a string
  55591. */
  55592. generateCode(): string;
  55593. /**
  55594. * Serializes this material in a JSON representation
  55595. * @returns the serialized material object
  55596. */
  55597. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  55598. private _restoreConnections;
  55599. /**
  55600. * Clear the current graph and load a new one from a serialization object
  55601. * @param source defines the JSON representation of the material
  55602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55603. */
  55604. loadFromSerialization(source: any, rootUrl?: string): void;
  55605. /**
  55606. * Creates a node material from parsed material data
  55607. * @param source defines the JSON representation of the material
  55608. * @param scene defines the hosting scene
  55609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55610. * @returns a new node material
  55611. */
  55612. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55613. /**
  55614. * Creates a new node material set to default basic configuration
  55615. * @param name defines the name of the material
  55616. * @param scene defines the hosting scene
  55617. * @returns a new NodeMaterial
  55618. */
  55619. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /**
  55624. * Block used to read a texture from a sampler
  55625. */
  55626. export class TextureBlock extends NodeMaterialBlock {
  55627. private _defineName;
  55628. private _linearDefineName;
  55629. private _tempTextureRead;
  55630. private _samplerName;
  55631. private _transformedUVName;
  55632. private _textureTransformName;
  55633. private _textureInfoName;
  55634. private _mainUVName;
  55635. private _mainUVDefineName;
  55636. /**
  55637. * Gets or sets the texture associated with the node
  55638. */
  55639. texture: Nullable<Texture>;
  55640. /**
  55641. * Create a new TextureBlock
  55642. * @param name defines the block name
  55643. */
  55644. constructor(name: string);
  55645. /**
  55646. * Gets the current class name
  55647. * @returns the class name
  55648. */
  55649. getClassName(): string;
  55650. /**
  55651. * Gets the uv input component
  55652. */
  55653. get uv(): NodeMaterialConnectionPoint;
  55654. /**
  55655. * Gets the rgba output component
  55656. */
  55657. get rgba(): NodeMaterialConnectionPoint;
  55658. /**
  55659. * Gets the rgb output component
  55660. */
  55661. get rgb(): NodeMaterialConnectionPoint;
  55662. /**
  55663. * Gets the r output component
  55664. */
  55665. get r(): NodeMaterialConnectionPoint;
  55666. /**
  55667. * Gets the g output component
  55668. */
  55669. get g(): NodeMaterialConnectionPoint;
  55670. /**
  55671. * Gets the b output component
  55672. */
  55673. get b(): NodeMaterialConnectionPoint;
  55674. /**
  55675. * Gets the a output component
  55676. */
  55677. get a(): NodeMaterialConnectionPoint;
  55678. get target(): NodeMaterialBlockTargets;
  55679. autoConfigure(material: NodeMaterial): void;
  55680. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55682. private _getTextureBase;
  55683. isReady(): boolean;
  55684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55685. private get _isMixed();
  55686. private _injectVertexCode;
  55687. private _writeTextureRead;
  55688. private _writeOutput;
  55689. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55690. protected _dumpPropertiesCode(): string;
  55691. serialize(): any;
  55692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55693. }
  55694. }
  55695. declare module BABYLON {
  55696. /**
  55697. * Class used to store shared data between 2 NodeMaterialBuildState
  55698. */
  55699. export class NodeMaterialBuildStateSharedData {
  55700. /**
  55701. * Gets the list of emitted varyings
  55702. */
  55703. temps: string[];
  55704. /**
  55705. * Gets the list of emitted varyings
  55706. */
  55707. varyings: string[];
  55708. /**
  55709. * Gets the varying declaration string
  55710. */
  55711. varyingDeclaration: string;
  55712. /**
  55713. * Input blocks
  55714. */
  55715. inputBlocks: InputBlock[];
  55716. /**
  55717. * Input blocks
  55718. */
  55719. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55720. /**
  55721. * Bindable blocks (Blocks that need to set data to the effect)
  55722. */
  55723. bindableBlocks: NodeMaterialBlock[];
  55724. /**
  55725. * List of blocks that can provide a compilation fallback
  55726. */
  55727. blocksWithFallbacks: NodeMaterialBlock[];
  55728. /**
  55729. * List of blocks that can provide a define update
  55730. */
  55731. blocksWithDefines: NodeMaterialBlock[];
  55732. /**
  55733. * List of blocks that can provide a repeatable content
  55734. */
  55735. repeatableContentBlocks: NodeMaterialBlock[];
  55736. /**
  55737. * List of blocks that can provide a dynamic list of uniforms
  55738. */
  55739. dynamicUniformBlocks: NodeMaterialBlock[];
  55740. /**
  55741. * List of blocks that can block the isReady function for the material
  55742. */
  55743. blockingBlocks: NodeMaterialBlock[];
  55744. /**
  55745. * Gets the list of animated inputs
  55746. */
  55747. animatedInputs: InputBlock[];
  55748. /**
  55749. * Build Id used to avoid multiple recompilations
  55750. */
  55751. buildId: number;
  55752. /** List of emitted variables */
  55753. variableNames: {
  55754. [key: string]: number;
  55755. };
  55756. /** List of emitted defines */
  55757. defineNames: {
  55758. [key: string]: number;
  55759. };
  55760. /** Should emit comments? */
  55761. emitComments: boolean;
  55762. /** Emit build activity */
  55763. verbose: boolean;
  55764. /** Gets or sets the hosting scene */
  55765. scene: Scene;
  55766. /**
  55767. * Gets the compilation hints emitted at compilation time
  55768. */
  55769. hints: {
  55770. needWorldViewMatrix: boolean;
  55771. needWorldViewProjectionMatrix: boolean;
  55772. needAlphaBlending: boolean;
  55773. needAlphaTesting: boolean;
  55774. };
  55775. /**
  55776. * List of compilation checks
  55777. */
  55778. checks: {
  55779. emitVertex: boolean;
  55780. emitFragment: boolean;
  55781. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55782. };
  55783. /** Creates a new shared data */
  55784. constructor();
  55785. /**
  55786. * Emits console errors and exceptions if there is a failing check
  55787. */
  55788. emitErrors(): void;
  55789. }
  55790. }
  55791. declare module BABYLON {
  55792. /**
  55793. * Class used to store node based material build state
  55794. */
  55795. export class NodeMaterialBuildState {
  55796. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55797. supportUniformBuffers: boolean;
  55798. /**
  55799. * Gets the list of emitted attributes
  55800. */
  55801. attributes: string[];
  55802. /**
  55803. * Gets the list of emitted uniforms
  55804. */
  55805. uniforms: string[];
  55806. /**
  55807. * Gets the list of emitted constants
  55808. */
  55809. constants: string[];
  55810. /**
  55811. * Gets the list of emitted samplers
  55812. */
  55813. samplers: string[];
  55814. /**
  55815. * Gets the list of emitted functions
  55816. */
  55817. functions: {
  55818. [key: string]: string;
  55819. };
  55820. /**
  55821. * Gets the list of emitted extensions
  55822. */
  55823. extensions: {
  55824. [key: string]: string;
  55825. };
  55826. /**
  55827. * Gets the target of the compilation state
  55828. */
  55829. target: NodeMaterialBlockTargets;
  55830. /**
  55831. * Gets the list of emitted counters
  55832. */
  55833. counters: {
  55834. [key: string]: number;
  55835. };
  55836. /**
  55837. * Shared data between multiple NodeMaterialBuildState instances
  55838. */
  55839. sharedData: NodeMaterialBuildStateSharedData;
  55840. /** @hidden */
  55841. _vertexState: NodeMaterialBuildState;
  55842. /** @hidden */
  55843. _attributeDeclaration: string;
  55844. /** @hidden */
  55845. _uniformDeclaration: string;
  55846. /** @hidden */
  55847. _constantDeclaration: string;
  55848. /** @hidden */
  55849. _samplerDeclaration: string;
  55850. /** @hidden */
  55851. _varyingTransfer: string;
  55852. private _repeatableContentAnchorIndex;
  55853. /** @hidden */
  55854. _builtCompilationString: string;
  55855. /**
  55856. * Gets the emitted compilation strings
  55857. */
  55858. compilationString: string;
  55859. /**
  55860. * Finalize the compilation strings
  55861. * @param state defines the current compilation state
  55862. */
  55863. finalize(state: NodeMaterialBuildState): void;
  55864. /** @hidden */
  55865. get _repeatableContentAnchor(): string;
  55866. /** @hidden */
  55867. _getFreeVariableName(prefix: string): string;
  55868. /** @hidden */
  55869. _getFreeDefineName(prefix: string): string;
  55870. /** @hidden */
  55871. _excludeVariableName(name: string): void;
  55872. /** @hidden */
  55873. _emit2DSampler(name: string): void;
  55874. /** @hidden */
  55875. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55876. /** @hidden */
  55877. _emitExtension(name: string, extension: string): void;
  55878. /** @hidden */
  55879. _emitFunction(name: string, code: string, comments: string): void;
  55880. /** @hidden */
  55881. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55882. replaceStrings?: {
  55883. search: RegExp;
  55884. replace: string;
  55885. }[];
  55886. repeatKey?: string;
  55887. }): string;
  55888. /** @hidden */
  55889. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55890. repeatKey?: string;
  55891. removeAttributes?: boolean;
  55892. removeUniforms?: boolean;
  55893. removeVaryings?: boolean;
  55894. removeIfDef?: boolean;
  55895. replaceStrings?: {
  55896. search: RegExp;
  55897. replace: string;
  55898. }[];
  55899. }, storeKey?: string): void;
  55900. /** @hidden */
  55901. _registerTempVariable(name: string): boolean;
  55902. /** @hidden */
  55903. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55904. /** @hidden */
  55905. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55906. /** @hidden */
  55907. _emitFloat(value: number): string;
  55908. }
  55909. }
  55910. declare module BABYLON {
  55911. /**
  55912. * Defines a block that can be used inside a node based material
  55913. */
  55914. export class NodeMaterialBlock {
  55915. private _buildId;
  55916. private _buildTarget;
  55917. private _target;
  55918. private _isFinalMerger;
  55919. private _isInput;
  55920. protected _isUnique: boolean;
  55921. /** @hidden */
  55922. _codeVariableName: string;
  55923. /** @hidden */
  55924. _inputs: NodeMaterialConnectionPoint[];
  55925. /** @hidden */
  55926. _outputs: NodeMaterialConnectionPoint[];
  55927. /** @hidden */
  55928. _preparationId: number;
  55929. /**
  55930. * Gets or sets the name of the block
  55931. */
  55932. name: string;
  55933. /**
  55934. * Gets or sets the unique id of the node
  55935. */
  55936. uniqueId: number;
  55937. /**
  55938. * Gets or sets the comments associated with this block
  55939. */
  55940. comments: string;
  55941. /**
  55942. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55943. */
  55944. get isUnique(): boolean;
  55945. /**
  55946. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55947. */
  55948. get isFinalMerger(): boolean;
  55949. /**
  55950. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55951. */
  55952. get isInput(): boolean;
  55953. /**
  55954. * Gets or sets the build Id
  55955. */
  55956. get buildId(): number;
  55957. set buildId(value: number);
  55958. /**
  55959. * Gets or sets the target of the block
  55960. */
  55961. get target(): NodeMaterialBlockTargets;
  55962. set target(value: NodeMaterialBlockTargets);
  55963. /**
  55964. * Gets the list of input points
  55965. */
  55966. get inputs(): NodeMaterialConnectionPoint[];
  55967. /** Gets the list of output points */
  55968. get outputs(): NodeMaterialConnectionPoint[];
  55969. /**
  55970. * Find an input by its name
  55971. * @param name defines the name of the input to look for
  55972. * @returns the input or null if not found
  55973. */
  55974. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55975. /**
  55976. * Find an output by its name
  55977. * @param name defines the name of the outputto look for
  55978. * @returns the output or null if not found
  55979. */
  55980. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55981. /**
  55982. * Creates a new NodeMaterialBlock
  55983. * @param name defines the block name
  55984. * @param target defines the target of that block (Vertex by default)
  55985. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55986. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55987. */
  55988. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55989. /**
  55990. * Initialize the block and prepare the context for build
  55991. * @param state defines the state that will be used for the build
  55992. */
  55993. initialize(state: NodeMaterialBuildState): void;
  55994. /**
  55995. * Bind data to effect. Will only be called for blocks with isBindable === true
  55996. * @param effect defines the effect to bind data to
  55997. * @param nodeMaterial defines the hosting NodeMaterial
  55998. * @param mesh defines the mesh that will be rendered
  55999. */
  56000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56001. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56002. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56003. protected _writeFloat(value: number): string;
  56004. /**
  56005. * Gets the current class name e.g. "NodeMaterialBlock"
  56006. * @returns the class name
  56007. */
  56008. getClassName(): string;
  56009. /**
  56010. * Register a new input. Must be called inside a block constructor
  56011. * @param name defines the connection point name
  56012. * @param type defines the connection point type
  56013. * @param isOptional defines a boolean indicating that this input can be omitted
  56014. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56015. * @returns the current block
  56016. */
  56017. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56018. /**
  56019. * Register a new output. Must be called inside a block constructor
  56020. * @param name defines the connection point name
  56021. * @param type defines the connection point type
  56022. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56023. * @returns the current block
  56024. */
  56025. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56026. /**
  56027. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56028. * @param forOutput defines an optional connection point to check compatibility with
  56029. * @returns the first available input or null
  56030. */
  56031. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56032. /**
  56033. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56034. * @param forBlock defines an optional block to check compatibility with
  56035. * @returns the first available input or null
  56036. */
  56037. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56038. /**
  56039. * Gets the sibling of the given output
  56040. * @param current defines the current output
  56041. * @returns the next output in the list or null
  56042. */
  56043. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56044. /**
  56045. * Connect current block with another block
  56046. * @param other defines the block to connect with
  56047. * @param options define the various options to help pick the right connections
  56048. * @returns the current block
  56049. */
  56050. connectTo(other: NodeMaterialBlock, options?: {
  56051. input?: string;
  56052. output?: string;
  56053. outputSwizzle?: string;
  56054. }): this | undefined;
  56055. protected _buildBlock(state: NodeMaterialBuildState): void;
  56056. /**
  56057. * Add uniforms, samplers and uniform buffers at compilation time
  56058. * @param state defines the state to update
  56059. * @param nodeMaterial defines the node material requesting the update
  56060. * @param defines defines the material defines to update
  56061. * @param uniformBuffers defines the list of uniform buffer names
  56062. */
  56063. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56064. /**
  56065. * Add potential fallbacks if shader compilation fails
  56066. * @param mesh defines the mesh to be rendered
  56067. * @param fallbacks defines the current prioritized list of fallbacks
  56068. */
  56069. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56070. /**
  56071. * Initialize defines for shader compilation
  56072. * @param mesh defines the mesh to be rendered
  56073. * @param nodeMaterial defines the node material requesting the update
  56074. * @param defines defines the material defines to update
  56075. * @param useInstances specifies that instances should be used
  56076. */
  56077. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56078. /**
  56079. * Update defines for shader compilation
  56080. * @param mesh defines the mesh to be rendered
  56081. * @param nodeMaterial defines the node material requesting the update
  56082. * @param defines defines the material defines to update
  56083. * @param useInstances specifies that instances should be used
  56084. */
  56085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56086. /**
  56087. * Lets the block try to connect some inputs automatically
  56088. * @param material defines the hosting NodeMaterial
  56089. */
  56090. autoConfigure(material: NodeMaterial): void;
  56091. /**
  56092. * Function called when a block is declared as repeatable content generator
  56093. * @param vertexShaderState defines the current compilation state for the vertex shader
  56094. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56095. * @param mesh defines the mesh to be rendered
  56096. * @param defines defines the material defines to update
  56097. */
  56098. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56099. /**
  56100. * Checks if the block is ready
  56101. * @param mesh defines the mesh to be rendered
  56102. * @param nodeMaterial defines the node material requesting the update
  56103. * @param defines defines the material defines to update
  56104. * @param useInstances specifies that instances should be used
  56105. * @returns true if the block is ready
  56106. */
  56107. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56108. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56109. private _processBuild;
  56110. /**
  56111. * Compile the current node and generate the shader code
  56112. * @param state defines the current compilation state (uniforms, samplers, current string)
  56113. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56114. * @returns true if already built
  56115. */
  56116. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56117. protected _inputRename(name: string): string;
  56118. protected _outputRename(name: string): string;
  56119. protected _dumpPropertiesCode(): string;
  56120. /** @hidden */
  56121. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56122. /** @hidden */
  56123. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56124. /**
  56125. * Clone the current block to a new identical block
  56126. * @param scene defines the hosting scene
  56127. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56128. * @returns a copy of the current block
  56129. */
  56130. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56131. /**
  56132. * Serializes this block in a JSON representation
  56133. * @returns the serialized block object
  56134. */
  56135. serialize(): any;
  56136. /** @hidden */
  56137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56138. /**
  56139. * Release resources
  56140. */
  56141. dispose(): void;
  56142. }
  56143. }
  56144. declare module BABYLON {
  56145. /**
  56146. * Enum defining the type of animations supported by InputBlock
  56147. */
  56148. export enum AnimatedInputBlockTypes {
  56149. /** No animation */
  56150. None = 0,
  56151. /** Time based animation. Will only work for floats */
  56152. Time = 1
  56153. }
  56154. }
  56155. declare module BABYLON {
  56156. /**
  56157. * Block used to expose an input value
  56158. */
  56159. export class InputBlock extends NodeMaterialBlock {
  56160. private _mode;
  56161. private _associatedVariableName;
  56162. private _storedValue;
  56163. private _valueCallback;
  56164. private _type;
  56165. private _animationType;
  56166. /** Gets or set a value used to limit the range of float values */
  56167. min: number;
  56168. /** Gets or set a value used to limit the range of float values */
  56169. max: number;
  56170. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56171. matrixMode: number;
  56172. /** @hidden */
  56173. _systemValue: Nullable<NodeMaterialSystemValues>;
  56174. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56175. visibleInInspector: boolean;
  56176. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56177. isConstant: boolean;
  56178. /** Gets or sets the group to use to display this block in the Inspector */
  56179. groupInInspector: string;
  56180. /**
  56181. * Gets or sets the connection point type (default is float)
  56182. */
  56183. get type(): NodeMaterialBlockConnectionPointTypes;
  56184. /**
  56185. * Creates a new InputBlock
  56186. * @param name defines the block name
  56187. * @param target defines the target of that block (Vertex by default)
  56188. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56189. */
  56190. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56191. /**
  56192. * Gets the output component
  56193. */
  56194. get output(): NodeMaterialConnectionPoint;
  56195. /**
  56196. * Set the source of this connection point to a vertex attribute
  56197. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56198. * @returns the current connection point
  56199. */
  56200. setAsAttribute(attributeName?: string): InputBlock;
  56201. /**
  56202. * Set the source of this connection point to a system value
  56203. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56204. * @returns the current connection point
  56205. */
  56206. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56207. /**
  56208. * Gets or sets the value of that point.
  56209. * Please note that this value will be ignored if valueCallback is defined
  56210. */
  56211. get value(): any;
  56212. set value(value: any);
  56213. /**
  56214. * Gets or sets a callback used to get the value of that point.
  56215. * Please note that setting this value will force the connection point to ignore the value property
  56216. */
  56217. get valueCallback(): () => any;
  56218. set valueCallback(value: () => any);
  56219. /**
  56220. * Gets or sets the associated variable name in the shader
  56221. */
  56222. get associatedVariableName(): string;
  56223. set associatedVariableName(value: string);
  56224. /** Gets or sets the type of animation applied to the input */
  56225. get animationType(): AnimatedInputBlockTypes;
  56226. set animationType(value: AnimatedInputBlockTypes);
  56227. /**
  56228. * Gets a boolean indicating that this connection point not defined yet
  56229. */
  56230. get isUndefined(): boolean;
  56231. /**
  56232. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56233. * In this case the connection point name must be the name of the uniform to use.
  56234. * Can only be set on inputs
  56235. */
  56236. get isUniform(): boolean;
  56237. set isUniform(value: boolean);
  56238. /**
  56239. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56240. * In this case the connection point name must be the name of the attribute to use
  56241. * Can only be set on inputs
  56242. */
  56243. get isAttribute(): boolean;
  56244. set isAttribute(value: boolean);
  56245. /**
  56246. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56247. * Can only be set on exit points
  56248. */
  56249. get isVarying(): boolean;
  56250. set isVarying(value: boolean);
  56251. /**
  56252. * Gets a boolean indicating that the current connection point is a system value
  56253. */
  56254. get isSystemValue(): boolean;
  56255. /**
  56256. * Gets or sets the current well known value or null if not defined as a system value
  56257. */
  56258. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56259. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56260. /**
  56261. * Gets the current class name
  56262. * @returns the class name
  56263. */
  56264. getClassName(): string;
  56265. /**
  56266. * Animate the input if animationType !== None
  56267. * @param scene defines the rendering scene
  56268. */
  56269. animate(scene: Scene): void;
  56270. private _emitDefine;
  56271. initialize(state: NodeMaterialBuildState): void;
  56272. /**
  56273. * Set the input block to its default value (based on its type)
  56274. */
  56275. setDefaultValue(): void;
  56276. private _emitConstant;
  56277. private _emit;
  56278. /** @hidden */
  56279. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56280. /** @hidden */
  56281. _transmit(effect: Effect, scene: Scene): void;
  56282. protected _buildBlock(state: NodeMaterialBuildState): void;
  56283. protected _dumpPropertiesCode(): string;
  56284. serialize(): any;
  56285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56286. }
  56287. }
  56288. declare module BABYLON {
  56289. /**
  56290. * Enum used to define the compatibility state between two connection points
  56291. */
  56292. export enum NodeMaterialConnectionPointCompatibilityStates {
  56293. /** Points are compatibles */
  56294. Compatible = 0,
  56295. /** Points are incompatible because of their types */
  56296. TypeIncompatible = 1,
  56297. /** Points are incompatible because of their targets (vertex vs fragment) */
  56298. TargetIncompatible = 2
  56299. }
  56300. /**
  56301. * Defines the direction of a connection point
  56302. */
  56303. export enum NodeMaterialConnectionPointDirection {
  56304. /** Input */
  56305. Input = 0,
  56306. /** Output */
  56307. Output = 1
  56308. }
  56309. /**
  56310. * Defines a connection point for a block
  56311. */
  56312. export class NodeMaterialConnectionPoint {
  56313. /** @hidden */
  56314. _ownerBlock: NodeMaterialBlock;
  56315. /** @hidden */
  56316. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56317. private _endpoints;
  56318. private _associatedVariableName;
  56319. private _direction;
  56320. /** @hidden */
  56321. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56322. /** @hidden */
  56323. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56324. private _type;
  56325. /** @hidden */
  56326. _enforceAssociatedVariableName: boolean;
  56327. /** Gets the direction of the point */
  56328. get direction(): NodeMaterialConnectionPointDirection;
  56329. /**
  56330. * Gets or sets the additional types supported by this connection point
  56331. */
  56332. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56333. /**
  56334. * Gets or sets the additional types excluded by this connection point
  56335. */
  56336. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56337. /**
  56338. * Observable triggered when this point is connected
  56339. */
  56340. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56341. /**
  56342. * Gets or sets the associated variable name in the shader
  56343. */
  56344. get associatedVariableName(): string;
  56345. set associatedVariableName(value: string);
  56346. /**
  56347. * Gets or sets the connection point type (default is float)
  56348. */
  56349. get type(): NodeMaterialBlockConnectionPointTypes;
  56350. set type(value: NodeMaterialBlockConnectionPointTypes);
  56351. /**
  56352. * Gets or sets the connection point name
  56353. */
  56354. name: string;
  56355. /**
  56356. * Gets or sets a boolean indicating that this connection point can be omitted
  56357. */
  56358. isOptional: boolean;
  56359. /**
  56360. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56361. */
  56362. define: string;
  56363. /** @hidden */
  56364. _prioritizeVertex: boolean;
  56365. private _target;
  56366. /** Gets or sets the target of that connection point */
  56367. get target(): NodeMaterialBlockTargets;
  56368. set target(value: NodeMaterialBlockTargets);
  56369. /**
  56370. * Gets a boolean indicating that the current point is connected
  56371. */
  56372. get isConnected(): boolean;
  56373. /**
  56374. * Gets a boolean indicating that the current point is connected to an input block
  56375. */
  56376. get isConnectedToInputBlock(): boolean;
  56377. /**
  56378. * Gets a the connected input block (if any)
  56379. */
  56380. get connectInputBlock(): Nullable<InputBlock>;
  56381. /** Get the other side of the connection (if any) */
  56382. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56383. /** Get the block that owns this connection point */
  56384. get ownerBlock(): NodeMaterialBlock;
  56385. /** Get the block connected on the other side of this connection (if any) */
  56386. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56387. /** Get the block connected on the endpoints of this connection (if any) */
  56388. get connectedBlocks(): Array<NodeMaterialBlock>;
  56389. /** Gets the list of connected endpoints */
  56390. get endpoints(): NodeMaterialConnectionPoint[];
  56391. /** Gets a boolean indicating if that output point is connected to at least one input */
  56392. get hasEndpoints(): boolean;
  56393. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56394. get isConnectedInVertexShader(): boolean;
  56395. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56396. get isConnectedInFragmentShader(): boolean;
  56397. /**
  56398. * Creates a new connection point
  56399. * @param name defines the connection point name
  56400. * @param ownerBlock defines the block hosting this connection point
  56401. * @param direction defines the direction of the connection point
  56402. */
  56403. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56404. /**
  56405. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56406. * @returns the class name
  56407. */
  56408. getClassName(): string;
  56409. /**
  56410. * Gets a boolean indicating if the current point can be connected to another point
  56411. * @param connectionPoint defines the other connection point
  56412. * @returns a boolean
  56413. */
  56414. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56415. /**
  56416. * Gets a number indicating if the current point can be connected to another point
  56417. * @param connectionPoint defines the other connection point
  56418. * @returns a number defining the compatibility state
  56419. */
  56420. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56421. /**
  56422. * Connect this point to another connection point
  56423. * @param connectionPoint defines the other connection point
  56424. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56425. * @returns the current connection point
  56426. */
  56427. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56428. /**
  56429. * Disconnect this point from one of his endpoint
  56430. * @param endpoint defines the other connection point
  56431. * @returns the current connection point
  56432. */
  56433. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56434. /**
  56435. * Serializes this point in a JSON representation
  56436. * @returns the serialized point object
  56437. */
  56438. serialize(): any;
  56439. /**
  56440. * Release resources
  56441. */
  56442. dispose(): void;
  56443. }
  56444. }
  56445. declare module BABYLON {
  56446. /**
  56447. * Block used to add support for vertex skinning (bones)
  56448. */
  56449. export class BonesBlock extends NodeMaterialBlock {
  56450. /**
  56451. * Creates a new BonesBlock
  56452. * @param name defines the block name
  56453. */
  56454. constructor(name: string);
  56455. /**
  56456. * Initialize the block and prepare the context for build
  56457. * @param state defines the state that will be used for the build
  56458. */
  56459. initialize(state: NodeMaterialBuildState): void;
  56460. /**
  56461. * Gets the current class name
  56462. * @returns the class name
  56463. */
  56464. getClassName(): string;
  56465. /**
  56466. * Gets the matrix indices input component
  56467. */
  56468. get matricesIndices(): NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the matrix weights input component
  56471. */
  56472. get matricesWeights(): NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the extra matrix indices input component
  56475. */
  56476. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the extra matrix weights input component
  56479. */
  56480. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56481. /**
  56482. * Gets the world input component
  56483. */
  56484. get world(): NodeMaterialConnectionPoint;
  56485. /**
  56486. * Gets the output component
  56487. */
  56488. get output(): NodeMaterialConnectionPoint;
  56489. autoConfigure(material: NodeMaterial): void;
  56490. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56493. protected _buildBlock(state: NodeMaterialBuildState): this;
  56494. }
  56495. }
  56496. declare module BABYLON {
  56497. /**
  56498. * Block used to add support for instances
  56499. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56500. */
  56501. export class InstancesBlock extends NodeMaterialBlock {
  56502. /**
  56503. * Creates a new InstancesBlock
  56504. * @param name defines the block name
  56505. */
  56506. constructor(name: string);
  56507. /**
  56508. * Gets the current class name
  56509. * @returns the class name
  56510. */
  56511. getClassName(): string;
  56512. /**
  56513. * Gets the first world row input component
  56514. */
  56515. get world0(): NodeMaterialConnectionPoint;
  56516. /**
  56517. * Gets the second world row input component
  56518. */
  56519. get world1(): NodeMaterialConnectionPoint;
  56520. /**
  56521. * Gets the third world row input component
  56522. */
  56523. get world2(): NodeMaterialConnectionPoint;
  56524. /**
  56525. * Gets the forth world row input component
  56526. */
  56527. get world3(): NodeMaterialConnectionPoint;
  56528. /**
  56529. * Gets the world input component
  56530. */
  56531. get world(): NodeMaterialConnectionPoint;
  56532. /**
  56533. * Gets the output component
  56534. */
  56535. get output(): NodeMaterialConnectionPoint;
  56536. autoConfigure(material: NodeMaterial): void;
  56537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56538. protected _buildBlock(state: NodeMaterialBuildState): this;
  56539. }
  56540. }
  56541. declare module BABYLON {
  56542. /**
  56543. * Block used to add morph targets support to vertex shader
  56544. */
  56545. export class MorphTargetsBlock extends NodeMaterialBlock {
  56546. private _repeatableContentAnchor;
  56547. private _repeatebleContentGenerated;
  56548. /**
  56549. * Create a new MorphTargetsBlock
  56550. * @param name defines the block name
  56551. */
  56552. constructor(name: string);
  56553. /**
  56554. * Gets the current class name
  56555. * @returns the class name
  56556. */
  56557. getClassName(): string;
  56558. /**
  56559. * Gets the position input component
  56560. */
  56561. get position(): NodeMaterialConnectionPoint;
  56562. /**
  56563. * Gets the normal input component
  56564. */
  56565. get normal(): NodeMaterialConnectionPoint;
  56566. /**
  56567. * Gets the tangent input component
  56568. */
  56569. get tangent(): NodeMaterialConnectionPoint;
  56570. /**
  56571. * Gets the tangent input component
  56572. */
  56573. get uv(): NodeMaterialConnectionPoint;
  56574. /**
  56575. * Gets the position output component
  56576. */
  56577. get positionOutput(): NodeMaterialConnectionPoint;
  56578. /**
  56579. * Gets the normal output component
  56580. */
  56581. get normalOutput(): NodeMaterialConnectionPoint;
  56582. /**
  56583. * Gets the tangent output component
  56584. */
  56585. get tangentOutput(): NodeMaterialConnectionPoint;
  56586. /**
  56587. * Gets the tangent output component
  56588. */
  56589. get uvOutput(): NodeMaterialConnectionPoint;
  56590. initialize(state: NodeMaterialBuildState): void;
  56591. autoConfigure(material: NodeMaterial): void;
  56592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56594. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56595. protected _buildBlock(state: NodeMaterialBuildState): this;
  56596. }
  56597. }
  56598. declare module BABYLON {
  56599. /**
  56600. * Block used to get data information from a light
  56601. */
  56602. export class LightInformationBlock extends NodeMaterialBlock {
  56603. private _lightDataUniformName;
  56604. private _lightColorUniformName;
  56605. private _lightTypeDefineName;
  56606. /**
  56607. * Gets or sets the light associated with this block
  56608. */
  56609. light: Nullable<Light>;
  56610. /**
  56611. * Creates a new LightInformationBlock
  56612. * @param name defines the block name
  56613. */
  56614. constructor(name: string);
  56615. /**
  56616. * Gets the current class name
  56617. * @returns the class name
  56618. */
  56619. getClassName(): string;
  56620. /**
  56621. * Gets the world position input component
  56622. */
  56623. get worldPosition(): NodeMaterialConnectionPoint;
  56624. /**
  56625. * Gets the direction output component
  56626. */
  56627. get direction(): NodeMaterialConnectionPoint;
  56628. /**
  56629. * Gets the direction output component
  56630. */
  56631. get color(): NodeMaterialConnectionPoint;
  56632. /**
  56633. * Gets the direction output component
  56634. */
  56635. get intensity(): NodeMaterialConnectionPoint;
  56636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56638. protected _buildBlock(state: NodeMaterialBuildState): this;
  56639. serialize(): any;
  56640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /**
  56645. * Block used to add image processing support to fragment shader
  56646. */
  56647. export class ImageProcessingBlock extends NodeMaterialBlock {
  56648. /**
  56649. * Create a new ImageProcessingBlock
  56650. * @param name defines the block name
  56651. */
  56652. constructor(name: string);
  56653. /**
  56654. * Gets the current class name
  56655. * @returns the class name
  56656. */
  56657. getClassName(): string;
  56658. /**
  56659. * Gets the color input component
  56660. */
  56661. get color(): NodeMaterialConnectionPoint;
  56662. /**
  56663. * Gets the output component
  56664. */
  56665. get output(): NodeMaterialConnectionPoint;
  56666. /**
  56667. * Initialize the block and prepare the context for build
  56668. * @param state defines the state that will be used for the build
  56669. */
  56670. initialize(state: NodeMaterialBuildState): void;
  56671. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56672. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56674. protected _buildBlock(state: NodeMaterialBuildState): this;
  56675. }
  56676. }
  56677. declare module BABYLON {
  56678. /**
  56679. * Block used to pertub normals based on a normal map
  56680. */
  56681. export class PerturbNormalBlock extends NodeMaterialBlock {
  56682. private _tangentSpaceParameterName;
  56683. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56684. invertX: boolean;
  56685. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56686. invertY: boolean;
  56687. /**
  56688. * Create a new PerturbNormalBlock
  56689. * @param name defines the block name
  56690. */
  56691. constructor(name: string);
  56692. /**
  56693. * Gets the current class name
  56694. * @returns the class name
  56695. */
  56696. getClassName(): string;
  56697. /**
  56698. * Gets the world position input component
  56699. */
  56700. get worldPosition(): NodeMaterialConnectionPoint;
  56701. /**
  56702. * Gets the world normal input component
  56703. */
  56704. get worldNormal(): NodeMaterialConnectionPoint;
  56705. /**
  56706. * Gets the uv input component
  56707. */
  56708. get uv(): NodeMaterialConnectionPoint;
  56709. /**
  56710. * Gets the normal map color input component
  56711. */
  56712. get normalMapColor(): NodeMaterialConnectionPoint;
  56713. /**
  56714. * Gets the strength input component
  56715. */
  56716. get strength(): NodeMaterialConnectionPoint;
  56717. /**
  56718. * Gets the output component
  56719. */
  56720. get output(): NodeMaterialConnectionPoint;
  56721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56722. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56723. autoConfigure(material: NodeMaterial): void;
  56724. protected _buildBlock(state: NodeMaterialBuildState): this;
  56725. protected _dumpPropertiesCode(): string;
  56726. serialize(): any;
  56727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56728. }
  56729. }
  56730. declare module BABYLON {
  56731. /**
  56732. * Block used to discard a pixel if a value is smaller than a cutoff
  56733. */
  56734. export class DiscardBlock extends NodeMaterialBlock {
  56735. /**
  56736. * Create a new DiscardBlock
  56737. * @param name defines the block name
  56738. */
  56739. constructor(name: string);
  56740. /**
  56741. * Gets the current class name
  56742. * @returns the class name
  56743. */
  56744. getClassName(): string;
  56745. /**
  56746. * Gets the color input component
  56747. */
  56748. get value(): NodeMaterialConnectionPoint;
  56749. /**
  56750. * Gets the cutoff input component
  56751. */
  56752. get cutoff(): NodeMaterialConnectionPoint;
  56753. protected _buildBlock(state: NodeMaterialBuildState): this;
  56754. }
  56755. }
  56756. declare module BABYLON {
  56757. /**
  56758. * Block used to test if the fragment shader is front facing
  56759. */
  56760. export class FrontFacingBlock extends NodeMaterialBlock {
  56761. /**
  56762. * Creates a new FrontFacingBlock
  56763. * @param name defines the block name
  56764. */
  56765. constructor(name: string);
  56766. /**
  56767. * Gets the current class name
  56768. * @returns the class name
  56769. */
  56770. getClassName(): string;
  56771. /**
  56772. * Gets the output component
  56773. */
  56774. get output(): NodeMaterialConnectionPoint;
  56775. protected _buildBlock(state: NodeMaterialBuildState): this;
  56776. }
  56777. }
  56778. declare module BABYLON {
  56779. /**
  56780. * Block used to get the derivative value on x and y of a given input
  56781. */
  56782. export class DerivativeBlock extends NodeMaterialBlock {
  56783. /**
  56784. * Create a new DerivativeBlock
  56785. * @param name defines the block name
  56786. */
  56787. constructor(name: string);
  56788. /**
  56789. * Gets the current class name
  56790. * @returns the class name
  56791. */
  56792. getClassName(): string;
  56793. /**
  56794. * Gets the input component
  56795. */
  56796. get input(): NodeMaterialConnectionPoint;
  56797. /**
  56798. * Gets the derivative output on x
  56799. */
  56800. get dx(): NodeMaterialConnectionPoint;
  56801. /**
  56802. * Gets the derivative output on y
  56803. */
  56804. get dy(): NodeMaterialConnectionPoint;
  56805. protected _buildBlock(state: NodeMaterialBuildState): this;
  56806. }
  56807. }
  56808. declare module BABYLON {
  56809. /**
  56810. * Block used to add support for scene fog
  56811. */
  56812. export class FogBlock extends NodeMaterialBlock {
  56813. private _fogDistanceName;
  56814. private _fogParameters;
  56815. /**
  56816. * Create a new FogBlock
  56817. * @param name defines the block name
  56818. */
  56819. constructor(name: string);
  56820. /**
  56821. * Gets the current class name
  56822. * @returns the class name
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Gets the world position input component
  56827. */
  56828. get worldPosition(): NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the view input component
  56831. */
  56832. get view(): NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the color input component
  56835. */
  56836. get input(): NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the fog color input component
  56839. */
  56840. get fogColor(): NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the output component
  56843. */
  56844. get output(): NodeMaterialConnectionPoint;
  56845. autoConfigure(material: NodeMaterial): void;
  56846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56848. protected _buildBlock(state: NodeMaterialBuildState): this;
  56849. }
  56850. }
  56851. declare module BABYLON {
  56852. /**
  56853. * Block used to add light in the fragment shader
  56854. */
  56855. export class LightBlock extends NodeMaterialBlock {
  56856. private _lightId;
  56857. /**
  56858. * Gets or sets the light associated with this block
  56859. */
  56860. light: Nullable<Light>;
  56861. /**
  56862. * Create a new LightBlock
  56863. * @param name defines the block name
  56864. */
  56865. constructor(name: string);
  56866. /**
  56867. * Gets the current class name
  56868. * @returns the class name
  56869. */
  56870. getClassName(): string;
  56871. /**
  56872. * Gets the world position input component
  56873. */
  56874. get worldPosition(): NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the world normal input component
  56877. */
  56878. get worldNormal(): NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the camera (or eye) position component
  56881. */
  56882. get cameraPosition(): NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the glossiness component
  56885. */
  56886. get glossiness(): NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the glossinness power component
  56889. */
  56890. get glossPower(): NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the diffuse color component
  56893. */
  56894. get diffuseColor(): NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the specular color component
  56897. */
  56898. get specularColor(): NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the diffuse output component
  56901. */
  56902. get diffuseOutput(): NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the specular output component
  56905. */
  56906. get specularOutput(): NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the shadow output component
  56909. */
  56910. get shadow(): NodeMaterialConnectionPoint;
  56911. autoConfigure(material: NodeMaterial): void;
  56912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56913. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56915. private _injectVertexCode;
  56916. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56917. serialize(): any;
  56918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56919. }
  56920. }
  56921. declare module BABYLON {
  56922. /**
  56923. * Block used to multiply 2 values
  56924. */
  56925. export class MultiplyBlock extends NodeMaterialBlock {
  56926. /**
  56927. * Creates a new MultiplyBlock
  56928. * @param name defines the block name
  56929. */
  56930. constructor(name: string);
  56931. /**
  56932. * Gets the current class name
  56933. * @returns the class name
  56934. */
  56935. getClassName(): string;
  56936. /**
  56937. * Gets the left operand input component
  56938. */
  56939. get left(): NodeMaterialConnectionPoint;
  56940. /**
  56941. * Gets the right operand input component
  56942. */
  56943. get right(): NodeMaterialConnectionPoint;
  56944. /**
  56945. * Gets the output component
  56946. */
  56947. get output(): NodeMaterialConnectionPoint;
  56948. protected _buildBlock(state: NodeMaterialBuildState): this;
  56949. }
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * Block used to add 2 vectors
  56954. */
  56955. export class AddBlock extends NodeMaterialBlock {
  56956. /**
  56957. * Creates a new AddBlock
  56958. * @param name defines the block name
  56959. */
  56960. constructor(name: string);
  56961. /**
  56962. * Gets the current class name
  56963. * @returns the class name
  56964. */
  56965. getClassName(): string;
  56966. /**
  56967. * Gets the left operand input component
  56968. */
  56969. get left(): NodeMaterialConnectionPoint;
  56970. /**
  56971. * Gets the right operand input component
  56972. */
  56973. get right(): NodeMaterialConnectionPoint;
  56974. /**
  56975. * Gets the output component
  56976. */
  56977. get output(): NodeMaterialConnectionPoint;
  56978. protected _buildBlock(state: NodeMaterialBuildState): this;
  56979. }
  56980. }
  56981. declare module BABYLON {
  56982. /**
  56983. * Block used to scale a vector by a float
  56984. */
  56985. export class ScaleBlock extends NodeMaterialBlock {
  56986. /**
  56987. * Creates a new ScaleBlock
  56988. * @param name defines the block name
  56989. */
  56990. constructor(name: string);
  56991. /**
  56992. * Gets the current class name
  56993. * @returns the class name
  56994. */
  56995. getClassName(): string;
  56996. /**
  56997. * Gets the input component
  56998. */
  56999. get input(): NodeMaterialConnectionPoint;
  57000. /**
  57001. * Gets the factor input component
  57002. */
  57003. get factor(): NodeMaterialConnectionPoint;
  57004. /**
  57005. * Gets the output component
  57006. */
  57007. get output(): NodeMaterialConnectionPoint;
  57008. protected _buildBlock(state: NodeMaterialBuildState): this;
  57009. }
  57010. }
  57011. declare module BABYLON {
  57012. /**
  57013. * Block used to clamp a float
  57014. */
  57015. export class ClampBlock extends NodeMaterialBlock {
  57016. /** Gets or sets the minimum range */
  57017. minimum: number;
  57018. /** Gets or sets the maximum range */
  57019. maximum: number;
  57020. /**
  57021. * Creates a new ClampBlock
  57022. * @param name defines the block name
  57023. */
  57024. constructor(name: string);
  57025. /**
  57026. * Gets the current class name
  57027. * @returns the class name
  57028. */
  57029. getClassName(): string;
  57030. /**
  57031. * Gets the value input component
  57032. */
  57033. get value(): NodeMaterialConnectionPoint;
  57034. /**
  57035. * Gets the output component
  57036. */
  57037. get output(): NodeMaterialConnectionPoint;
  57038. protected _buildBlock(state: NodeMaterialBuildState): this;
  57039. protected _dumpPropertiesCode(): string;
  57040. serialize(): any;
  57041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Block used to apply a cross product between 2 vectors
  57047. */
  57048. export class CrossBlock extends NodeMaterialBlock {
  57049. /**
  57050. * Creates a new CrossBlock
  57051. * @param name defines the block name
  57052. */
  57053. constructor(name: string);
  57054. /**
  57055. * Gets the current class name
  57056. * @returns the class name
  57057. */
  57058. getClassName(): string;
  57059. /**
  57060. * Gets the left operand input component
  57061. */
  57062. get left(): NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the right operand input component
  57065. */
  57066. get right(): NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the output component
  57069. */
  57070. get output(): NodeMaterialConnectionPoint;
  57071. protected _buildBlock(state: NodeMaterialBuildState): this;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /**
  57076. * Block used to apply a dot product between 2 vectors
  57077. */
  57078. export class DotBlock extends NodeMaterialBlock {
  57079. /**
  57080. * Creates a new DotBlock
  57081. * @param name defines the block name
  57082. */
  57083. constructor(name: string);
  57084. /**
  57085. * Gets the current class name
  57086. * @returns the class name
  57087. */
  57088. getClassName(): string;
  57089. /**
  57090. * Gets the left operand input component
  57091. */
  57092. get left(): NodeMaterialConnectionPoint;
  57093. /**
  57094. * Gets the right operand input component
  57095. */
  57096. get right(): NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the output component
  57099. */
  57100. get output(): NodeMaterialConnectionPoint;
  57101. protected _buildBlock(state: NodeMaterialBuildState): this;
  57102. }
  57103. }
  57104. declare module BABYLON {
  57105. /**
  57106. * Block used to remap a float from a range to a new one
  57107. */
  57108. export class RemapBlock extends NodeMaterialBlock {
  57109. /**
  57110. * Gets or sets the source range
  57111. */
  57112. sourceRange: Vector2;
  57113. /**
  57114. * Gets or sets the target range
  57115. */
  57116. targetRange: Vector2;
  57117. /**
  57118. * Creates a new RemapBlock
  57119. * @param name defines the block name
  57120. */
  57121. constructor(name: string);
  57122. /**
  57123. * Gets the current class name
  57124. * @returns the class name
  57125. */
  57126. getClassName(): string;
  57127. /**
  57128. * Gets the input component
  57129. */
  57130. get input(): NodeMaterialConnectionPoint;
  57131. /**
  57132. * Gets the source min input component
  57133. */
  57134. get sourceMin(): NodeMaterialConnectionPoint;
  57135. /**
  57136. * Gets the source max input component
  57137. */
  57138. get sourceMax(): NodeMaterialConnectionPoint;
  57139. /**
  57140. * Gets the target min input component
  57141. */
  57142. get targetMin(): NodeMaterialConnectionPoint;
  57143. /**
  57144. * Gets the target max input component
  57145. */
  57146. get targetMax(): NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the output component
  57149. */
  57150. get output(): NodeMaterialConnectionPoint;
  57151. protected _buildBlock(state: NodeMaterialBuildState): this;
  57152. protected _dumpPropertiesCode(): string;
  57153. serialize(): any;
  57154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57155. }
  57156. }
  57157. declare module BABYLON {
  57158. /**
  57159. * Block used to normalize a vector
  57160. */
  57161. export class NormalizeBlock extends NodeMaterialBlock {
  57162. /**
  57163. * Creates a new NormalizeBlock
  57164. * @param name defines the block name
  57165. */
  57166. constructor(name: string);
  57167. /**
  57168. * Gets the current class name
  57169. * @returns the class name
  57170. */
  57171. getClassName(): string;
  57172. /**
  57173. * Gets the input component
  57174. */
  57175. get input(): NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the output component
  57178. */
  57179. get output(): NodeMaterialConnectionPoint;
  57180. protected _buildBlock(state: NodeMaterialBuildState): this;
  57181. }
  57182. }
  57183. declare module BABYLON {
  57184. /**
  57185. * Operations supported by the Trigonometry block
  57186. */
  57187. export enum TrigonometryBlockOperations {
  57188. /** Cos */
  57189. Cos = 0,
  57190. /** Sin */
  57191. Sin = 1,
  57192. /** Abs */
  57193. Abs = 2,
  57194. /** Exp */
  57195. Exp = 3,
  57196. /** Exp2 */
  57197. Exp2 = 4,
  57198. /** Round */
  57199. Round = 5,
  57200. /** Floor */
  57201. Floor = 6,
  57202. /** Ceiling */
  57203. Ceiling = 7,
  57204. /** Square root */
  57205. Sqrt = 8,
  57206. /** Log */
  57207. Log = 9,
  57208. /** Tangent */
  57209. Tan = 10,
  57210. /** Arc tangent */
  57211. ArcTan = 11,
  57212. /** Arc cosinus */
  57213. ArcCos = 12,
  57214. /** Arc sinus */
  57215. ArcSin = 13,
  57216. /** Fraction */
  57217. Fract = 14,
  57218. /** Sign */
  57219. Sign = 15,
  57220. /** To radians (from degrees) */
  57221. Radians = 16,
  57222. /** To degrees (from radians) */
  57223. Degrees = 17
  57224. }
  57225. /**
  57226. * Block used to apply trigonometry operation to floats
  57227. */
  57228. export class TrigonometryBlock extends NodeMaterialBlock {
  57229. /**
  57230. * Gets or sets the operation applied by the block
  57231. */
  57232. operation: TrigonometryBlockOperations;
  57233. /**
  57234. * Creates a new TrigonometryBlock
  57235. * @param name defines the block name
  57236. */
  57237. constructor(name: string);
  57238. /**
  57239. * Gets the current class name
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Gets the input component
  57245. */
  57246. get input(): NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the output component
  57249. */
  57250. get output(): NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. serialize(): any;
  57253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57254. protected _dumpPropertiesCode(): string;
  57255. }
  57256. }
  57257. declare module BABYLON {
  57258. /**
  57259. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57260. */
  57261. export class ColorMergerBlock extends NodeMaterialBlock {
  57262. /**
  57263. * Create a new ColorMergerBlock
  57264. * @param name defines the block name
  57265. */
  57266. constructor(name: string);
  57267. /**
  57268. * Gets the current class name
  57269. * @returns the class name
  57270. */
  57271. getClassName(): string;
  57272. /**
  57273. * Gets the rgb component (input)
  57274. */
  57275. get rgbIn(): NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the r component (input)
  57278. */
  57279. get r(): NodeMaterialConnectionPoint;
  57280. /**
  57281. * Gets the g component (input)
  57282. */
  57283. get g(): NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the b component (input)
  57286. */
  57287. get b(): NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the a component (input)
  57290. */
  57291. get a(): NodeMaterialConnectionPoint;
  57292. /**
  57293. * Gets the rgba component (output)
  57294. */
  57295. get rgba(): NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the rgb component (output)
  57298. */
  57299. get rgbOut(): NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the rgb component (output)
  57302. * @deprecated Please use rgbOut instead.
  57303. */
  57304. get rgb(): NodeMaterialConnectionPoint;
  57305. protected _buildBlock(state: NodeMaterialBuildState): this;
  57306. }
  57307. }
  57308. declare module BABYLON {
  57309. /**
  57310. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57311. */
  57312. export class VectorMergerBlock extends NodeMaterialBlock {
  57313. /**
  57314. * Create a new VectorMergerBlock
  57315. * @param name defines the block name
  57316. */
  57317. constructor(name: string);
  57318. /**
  57319. * Gets the current class name
  57320. * @returns the class name
  57321. */
  57322. getClassName(): string;
  57323. /**
  57324. * Gets the xyz component (input)
  57325. */
  57326. get xyzIn(): NodeMaterialConnectionPoint;
  57327. /**
  57328. * Gets the xy component (input)
  57329. */
  57330. get xyIn(): NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the x component (input)
  57333. */
  57334. get x(): NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the y component (input)
  57337. */
  57338. get y(): NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the z component (input)
  57341. */
  57342. get z(): NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the w component (input)
  57345. */
  57346. get w(): NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the xyzw component (output)
  57349. */
  57350. get xyzw(): NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the xyz component (output)
  57353. */
  57354. get xyzOut(): NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the xy component (output)
  57357. */
  57358. get xyOut(): NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the xy component (output)
  57361. * @deprecated Please use xyOut instead.
  57362. */
  57363. get xy(): NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the xyz component (output)
  57366. * @deprecated Please use xyzOut instead.
  57367. */
  57368. get xyz(): NodeMaterialConnectionPoint;
  57369. protected _buildBlock(state: NodeMaterialBuildState): this;
  57370. }
  57371. }
  57372. declare module BABYLON {
  57373. /**
  57374. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57375. */
  57376. export class ColorSplitterBlock extends NodeMaterialBlock {
  57377. /**
  57378. * Create a new ColorSplitterBlock
  57379. * @param name defines the block name
  57380. */
  57381. constructor(name: string);
  57382. /**
  57383. * Gets the current class name
  57384. * @returns the class name
  57385. */
  57386. getClassName(): string;
  57387. /**
  57388. * Gets the rgba component (input)
  57389. */
  57390. get rgba(): NodeMaterialConnectionPoint;
  57391. /**
  57392. * Gets the rgb component (input)
  57393. */
  57394. get rgbIn(): NodeMaterialConnectionPoint;
  57395. /**
  57396. * Gets the rgb component (output)
  57397. */
  57398. get rgbOut(): NodeMaterialConnectionPoint;
  57399. /**
  57400. * Gets the r component (output)
  57401. */
  57402. get r(): NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the g component (output)
  57405. */
  57406. get g(): NodeMaterialConnectionPoint;
  57407. /**
  57408. * Gets the b component (output)
  57409. */
  57410. get b(): NodeMaterialConnectionPoint;
  57411. /**
  57412. * Gets the a component (output)
  57413. */
  57414. get a(): NodeMaterialConnectionPoint;
  57415. protected _inputRename(name: string): string;
  57416. protected _outputRename(name: string): string;
  57417. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57418. }
  57419. }
  57420. declare module BABYLON {
  57421. /**
  57422. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57423. */
  57424. export class VectorSplitterBlock extends NodeMaterialBlock {
  57425. /**
  57426. * Create a new VectorSplitterBlock
  57427. * @param name defines the block name
  57428. */
  57429. constructor(name: string);
  57430. /**
  57431. * Gets the current class name
  57432. * @returns the class name
  57433. */
  57434. getClassName(): string;
  57435. /**
  57436. * Gets the xyzw component (input)
  57437. */
  57438. get xyzw(): NodeMaterialConnectionPoint;
  57439. /**
  57440. * Gets the xyz component (input)
  57441. */
  57442. get xyzIn(): NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the xy component (input)
  57445. */
  57446. get xyIn(): NodeMaterialConnectionPoint;
  57447. /**
  57448. * Gets the xyz component (output)
  57449. */
  57450. get xyzOut(): NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the xy component (output)
  57453. */
  57454. get xyOut(): NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the x component (output)
  57457. */
  57458. get x(): NodeMaterialConnectionPoint;
  57459. /**
  57460. * Gets the y component (output)
  57461. */
  57462. get y(): NodeMaterialConnectionPoint;
  57463. /**
  57464. * Gets the z component (output)
  57465. */
  57466. get z(): NodeMaterialConnectionPoint;
  57467. /**
  57468. * Gets the w component (output)
  57469. */
  57470. get w(): NodeMaterialConnectionPoint;
  57471. protected _inputRename(name: string): string;
  57472. protected _outputRename(name: string): string;
  57473. protected _buildBlock(state: NodeMaterialBuildState): this;
  57474. }
  57475. }
  57476. declare module BABYLON {
  57477. /**
  57478. * Block used to lerp between 2 values
  57479. */
  57480. export class LerpBlock extends NodeMaterialBlock {
  57481. /**
  57482. * Creates a new LerpBlock
  57483. * @param name defines the block name
  57484. */
  57485. constructor(name: string);
  57486. /**
  57487. * Gets the current class name
  57488. * @returns the class name
  57489. */
  57490. getClassName(): string;
  57491. /**
  57492. * Gets the left operand input component
  57493. */
  57494. get left(): NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the right operand input component
  57497. */
  57498. get right(): NodeMaterialConnectionPoint;
  57499. /**
  57500. * Gets the gradient operand input component
  57501. */
  57502. get gradient(): NodeMaterialConnectionPoint;
  57503. /**
  57504. * Gets the output component
  57505. */
  57506. get output(): NodeMaterialConnectionPoint;
  57507. protected _buildBlock(state: NodeMaterialBuildState): this;
  57508. }
  57509. }
  57510. declare module BABYLON {
  57511. /**
  57512. * Block used to divide 2 vectors
  57513. */
  57514. export class DivideBlock extends NodeMaterialBlock {
  57515. /**
  57516. * Creates a new DivideBlock
  57517. * @param name defines the block name
  57518. */
  57519. constructor(name: string);
  57520. /**
  57521. * Gets the current class name
  57522. * @returns the class name
  57523. */
  57524. getClassName(): string;
  57525. /**
  57526. * Gets the left operand input component
  57527. */
  57528. get left(): NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the right operand input component
  57531. */
  57532. get right(): NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the output component
  57535. */
  57536. get output(): NodeMaterialConnectionPoint;
  57537. protected _buildBlock(state: NodeMaterialBuildState): this;
  57538. }
  57539. }
  57540. declare module BABYLON {
  57541. /**
  57542. * Block used to subtract 2 vectors
  57543. */
  57544. export class SubtractBlock extends NodeMaterialBlock {
  57545. /**
  57546. * Creates a new SubtractBlock
  57547. * @param name defines the block name
  57548. */
  57549. constructor(name: string);
  57550. /**
  57551. * Gets the current class name
  57552. * @returns the class name
  57553. */
  57554. getClassName(): string;
  57555. /**
  57556. * Gets the left operand input component
  57557. */
  57558. get left(): NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the right operand input component
  57561. */
  57562. get right(): NodeMaterialConnectionPoint;
  57563. /**
  57564. * Gets the output component
  57565. */
  57566. get output(): NodeMaterialConnectionPoint;
  57567. protected _buildBlock(state: NodeMaterialBuildState): this;
  57568. }
  57569. }
  57570. declare module BABYLON {
  57571. /**
  57572. * Block used to step a value
  57573. */
  57574. export class StepBlock extends NodeMaterialBlock {
  57575. /**
  57576. * Creates a new StepBlock
  57577. * @param name defines the block name
  57578. */
  57579. constructor(name: string);
  57580. /**
  57581. * Gets the current class name
  57582. * @returns the class name
  57583. */
  57584. getClassName(): string;
  57585. /**
  57586. * Gets the value operand input component
  57587. */
  57588. get value(): NodeMaterialConnectionPoint;
  57589. /**
  57590. * Gets the edge operand input component
  57591. */
  57592. get edge(): NodeMaterialConnectionPoint;
  57593. /**
  57594. * Gets the output component
  57595. */
  57596. get output(): NodeMaterialConnectionPoint;
  57597. protected _buildBlock(state: NodeMaterialBuildState): this;
  57598. }
  57599. }
  57600. declare module BABYLON {
  57601. /**
  57602. * Block used to get the opposite (1 - x) of a value
  57603. */
  57604. export class OneMinusBlock extends NodeMaterialBlock {
  57605. /**
  57606. * Creates a new OneMinusBlock
  57607. * @param name defines the block name
  57608. */
  57609. constructor(name: string);
  57610. /**
  57611. * Gets the current class name
  57612. * @returns the class name
  57613. */
  57614. getClassName(): string;
  57615. /**
  57616. * Gets the input component
  57617. */
  57618. get input(): NodeMaterialConnectionPoint;
  57619. /**
  57620. * Gets the output component
  57621. */
  57622. get output(): NodeMaterialConnectionPoint;
  57623. protected _buildBlock(state: NodeMaterialBuildState): this;
  57624. }
  57625. }
  57626. declare module BABYLON {
  57627. /**
  57628. * Block used to get the view direction
  57629. */
  57630. export class ViewDirectionBlock extends NodeMaterialBlock {
  57631. /**
  57632. * Creates a new ViewDirectionBlock
  57633. * @param name defines the block name
  57634. */
  57635. constructor(name: string);
  57636. /**
  57637. * Gets the current class name
  57638. * @returns the class name
  57639. */
  57640. getClassName(): string;
  57641. /**
  57642. * Gets the world position component
  57643. */
  57644. get worldPosition(): NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the camera position component
  57647. */
  57648. get cameraPosition(): NodeMaterialConnectionPoint;
  57649. /**
  57650. * Gets the output component
  57651. */
  57652. get output(): NodeMaterialConnectionPoint;
  57653. autoConfigure(material: NodeMaterial): void;
  57654. protected _buildBlock(state: NodeMaterialBuildState): this;
  57655. }
  57656. }
  57657. declare module BABYLON {
  57658. /**
  57659. * Block used to compute fresnel value
  57660. */
  57661. export class FresnelBlock extends NodeMaterialBlock {
  57662. /**
  57663. * Create a new FresnelBlock
  57664. * @param name defines the block name
  57665. */
  57666. constructor(name: string);
  57667. /**
  57668. * Gets the current class name
  57669. * @returns the class name
  57670. */
  57671. getClassName(): string;
  57672. /**
  57673. * Gets the world normal input component
  57674. */
  57675. get worldNormal(): NodeMaterialConnectionPoint;
  57676. /**
  57677. * Gets the view direction input component
  57678. */
  57679. get viewDirection(): NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the bias input component
  57682. */
  57683. get bias(): NodeMaterialConnectionPoint;
  57684. /**
  57685. * Gets the camera (or eye) position component
  57686. */
  57687. get power(): NodeMaterialConnectionPoint;
  57688. /**
  57689. * Gets the fresnel output component
  57690. */
  57691. get fresnel(): NodeMaterialConnectionPoint;
  57692. autoConfigure(material: NodeMaterial): void;
  57693. protected _buildBlock(state: NodeMaterialBuildState): this;
  57694. }
  57695. }
  57696. declare module BABYLON {
  57697. /**
  57698. * Block used to get the max of 2 values
  57699. */
  57700. export class MaxBlock extends NodeMaterialBlock {
  57701. /**
  57702. * Creates a new MaxBlock
  57703. * @param name defines the block name
  57704. */
  57705. constructor(name: string);
  57706. /**
  57707. * Gets the current class name
  57708. * @returns the class name
  57709. */
  57710. getClassName(): string;
  57711. /**
  57712. * Gets the left operand input component
  57713. */
  57714. get left(): NodeMaterialConnectionPoint;
  57715. /**
  57716. * Gets the right operand input component
  57717. */
  57718. get right(): NodeMaterialConnectionPoint;
  57719. /**
  57720. * Gets the output component
  57721. */
  57722. get output(): NodeMaterialConnectionPoint;
  57723. protected _buildBlock(state: NodeMaterialBuildState): this;
  57724. }
  57725. }
  57726. declare module BABYLON {
  57727. /**
  57728. * Block used to get the min of 2 values
  57729. */
  57730. export class MinBlock extends NodeMaterialBlock {
  57731. /**
  57732. * Creates a new MinBlock
  57733. * @param name defines the block name
  57734. */
  57735. constructor(name: string);
  57736. /**
  57737. * Gets the current class name
  57738. * @returns the class name
  57739. */
  57740. getClassName(): string;
  57741. /**
  57742. * Gets the left operand input component
  57743. */
  57744. get left(): NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the right operand input component
  57747. */
  57748. get right(): NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the output component
  57751. */
  57752. get output(): NodeMaterialConnectionPoint;
  57753. protected _buildBlock(state: NodeMaterialBuildState): this;
  57754. }
  57755. }
  57756. declare module BABYLON {
  57757. /**
  57758. * Block used to get the distance between 2 values
  57759. */
  57760. export class DistanceBlock extends NodeMaterialBlock {
  57761. /**
  57762. * Creates a new DistanceBlock
  57763. * @param name defines the block name
  57764. */
  57765. constructor(name: string);
  57766. /**
  57767. * Gets the current class name
  57768. * @returns the class name
  57769. */
  57770. getClassName(): string;
  57771. /**
  57772. * Gets the left operand input component
  57773. */
  57774. get left(): NodeMaterialConnectionPoint;
  57775. /**
  57776. * Gets the right operand input component
  57777. */
  57778. get right(): NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the output component
  57781. */
  57782. get output(): NodeMaterialConnectionPoint;
  57783. protected _buildBlock(state: NodeMaterialBuildState): this;
  57784. }
  57785. }
  57786. declare module BABYLON {
  57787. /**
  57788. * Block used to get the length of a vector
  57789. */
  57790. export class LengthBlock extends NodeMaterialBlock {
  57791. /**
  57792. * Creates a new LengthBlock
  57793. * @param name defines the block name
  57794. */
  57795. constructor(name: string);
  57796. /**
  57797. * Gets the current class name
  57798. * @returns the class name
  57799. */
  57800. getClassName(): string;
  57801. /**
  57802. * Gets the value input component
  57803. */
  57804. get value(): NodeMaterialConnectionPoint;
  57805. /**
  57806. * Gets the output component
  57807. */
  57808. get output(): NodeMaterialConnectionPoint;
  57809. protected _buildBlock(state: NodeMaterialBuildState): this;
  57810. }
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * Block used to get negative version of a value (i.e. x * -1)
  57815. */
  57816. export class NegateBlock extends NodeMaterialBlock {
  57817. /**
  57818. * Creates a new NegateBlock
  57819. * @param name defines the block name
  57820. */
  57821. constructor(name: string);
  57822. /**
  57823. * Gets the current class name
  57824. * @returns the class name
  57825. */
  57826. getClassName(): string;
  57827. /**
  57828. * Gets the value input component
  57829. */
  57830. get value(): NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the output component
  57833. */
  57834. get output(): NodeMaterialConnectionPoint;
  57835. protected _buildBlock(state: NodeMaterialBuildState): this;
  57836. }
  57837. }
  57838. declare module BABYLON {
  57839. /**
  57840. * Block used to get the value of the first parameter raised to the power of the second
  57841. */
  57842. export class PowBlock extends NodeMaterialBlock {
  57843. /**
  57844. * Creates a new PowBlock
  57845. * @param name defines the block name
  57846. */
  57847. constructor(name: string);
  57848. /**
  57849. * Gets the current class name
  57850. * @returns the class name
  57851. */
  57852. getClassName(): string;
  57853. /**
  57854. * Gets the value operand input component
  57855. */
  57856. get value(): NodeMaterialConnectionPoint;
  57857. /**
  57858. * Gets the power operand input component
  57859. */
  57860. get power(): NodeMaterialConnectionPoint;
  57861. /**
  57862. * Gets the output component
  57863. */
  57864. get output(): NodeMaterialConnectionPoint;
  57865. protected _buildBlock(state: NodeMaterialBuildState): this;
  57866. }
  57867. }
  57868. declare module BABYLON {
  57869. /**
  57870. * Block used to get a random number
  57871. */
  57872. export class RandomNumberBlock extends NodeMaterialBlock {
  57873. /**
  57874. * Creates a new RandomNumberBlock
  57875. * @param name defines the block name
  57876. */
  57877. constructor(name: string);
  57878. /**
  57879. * Gets the current class name
  57880. * @returns the class name
  57881. */
  57882. getClassName(): string;
  57883. /**
  57884. * Gets the seed input component
  57885. */
  57886. get seed(): NodeMaterialConnectionPoint;
  57887. /**
  57888. * Gets the output component
  57889. */
  57890. get output(): NodeMaterialConnectionPoint;
  57891. protected _buildBlock(state: NodeMaterialBuildState): this;
  57892. }
  57893. }
  57894. declare module BABYLON {
  57895. /**
  57896. * Block used to compute arc tangent of 2 values
  57897. */
  57898. export class ArcTan2Block extends NodeMaterialBlock {
  57899. /**
  57900. * Creates a new ArcTan2Block
  57901. * @param name defines the block name
  57902. */
  57903. constructor(name: string);
  57904. /**
  57905. * Gets the current class name
  57906. * @returns the class name
  57907. */
  57908. getClassName(): string;
  57909. /**
  57910. * Gets the x operand input component
  57911. */
  57912. get x(): NodeMaterialConnectionPoint;
  57913. /**
  57914. * Gets the y operand input component
  57915. */
  57916. get y(): NodeMaterialConnectionPoint;
  57917. /**
  57918. * Gets the output component
  57919. */
  57920. get output(): NodeMaterialConnectionPoint;
  57921. protected _buildBlock(state: NodeMaterialBuildState): this;
  57922. }
  57923. }
  57924. declare module BABYLON {
  57925. /**
  57926. * Block used to smooth step a value
  57927. */
  57928. export class SmoothStepBlock extends NodeMaterialBlock {
  57929. /**
  57930. * Creates a new SmoothStepBlock
  57931. * @param name defines the block name
  57932. */
  57933. constructor(name: string);
  57934. /**
  57935. * Gets the current class name
  57936. * @returns the class name
  57937. */
  57938. getClassName(): string;
  57939. /**
  57940. * Gets the value operand input component
  57941. */
  57942. get value(): NodeMaterialConnectionPoint;
  57943. /**
  57944. * Gets the first edge operand input component
  57945. */
  57946. get edge0(): NodeMaterialConnectionPoint;
  57947. /**
  57948. * Gets the second edge operand input component
  57949. */
  57950. get edge1(): NodeMaterialConnectionPoint;
  57951. /**
  57952. * Gets the output component
  57953. */
  57954. get output(): NodeMaterialConnectionPoint;
  57955. protected _buildBlock(state: NodeMaterialBuildState): this;
  57956. }
  57957. }
  57958. declare module BABYLON {
  57959. /**
  57960. * Block used to get the reciprocal (1 / x) of a value
  57961. */
  57962. export class ReciprocalBlock extends NodeMaterialBlock {
  57963. /**
  57964. * Creates a new ReciprocalBlock
  57965. * @param name defines the block name
  57966. */
  57967. constructor(name: string);
  57968. /**
  57969. * Gets the current class name
  57970. * @returns the class name
  57971. */
  57972. getClassName(): string;
  57973. /**
  57974. * Gets the input component
  57975. */
  57976. get input(): NodeMaterialConnectionPoint;
  57977. /**
  57978. * Gets the output component
  57979. */
  57980. get output(): NodeMaterialConnectionPoint;
  57981. protected _buildBlock(state: NodeMaterialBuildState): this;
  57982. }
  57983. }
  57984. declare module BABYLON {
  57985. /**
  57986. * Block used to replace a color by another one
  57987. */
  57988. export class ReplaceColorBlock extends NodeMaterialBlock {
  57989. /**
  57990. * Creates a new ReplaceColorBlock
  57991. * @param name defines the block name
  57992. */
  57993. constructor(name: string);
  57994. /**
  57995. * Gets the current class name
  57996. * @returns the class name
  57997. */
  57998. getClassName(): string;
  57999. /**
  58000. * Gets the value input component
  58001. */
  58002. get value(): NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the reference input component
  58005. */
  58006. get reference(): NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the distance input component
  58009. */
  58010. get distance(): NodeMaterialConnectionPoint;
  58011. /**
  58012. * Gets the replacement input component
  58013. */
  58014. get replacement(): NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the output component
  58017. */
  58018. get output(): NodeMaterialConnectionPoint;
  58019. protected _buildBlock(state: NodeMaterialBuildState): this;
  58020. }
  58021. }
  58022. declare module BABYLON {
  58023. /**
  58024. * Block used to posterize a value
  58025. * @see https://en.wikipedia.org/wiki/Posterization
  58026. */
  58027. export class PosterizeBlock extends NodeMaterialBlock {
  58028. /**
  58029. * Creates a new PosterizeBlock
  58030. * @param name defines the block name
  58031. */
  58032. constructor(name: string);
  58033. /**
  58034. * Gets the current class name
  58035. * @returns the class name
  58036. */
  58037. getClassName(): string;
  58038. /**
  58039. * Gets the value input component
  58040. */
  58041. get value(): NodeMaterialConnectionPoint;
  58042. /**
  58043. * Gets the steps input component
  58044. */
  58045. get steps(): NodeMaterialConnectionPoint;
  58046. /**
  58047. * Gets the output component
  58048. */
  58049. get output(): NodeMaterialConnectionPoint;
  58050. protected _buildBlock(state: NodeMaterialBuildState): this;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. /**
  58055. * Operations supported by the Wave block
  58056. */
  58057. export enum WaveBlockKind {
  58058. /** SawTooth */
  58059. SawTooth = 0,
  58060. /** Square */
  58061. Square = 1,
  58062. /** Triangle */
  58063. Triangle = 2
  58064. }
  58065. /**
  58066. * Block used to apply wave operation to floats
  58067. */
  58068. export class WaveBlock extends NodeMaterialBlock {
  58069. /**
  58070. * Gets or sets the kibnd of wave to be applied by the block
  58071. */
  58072. kind: WaveBlockKind;
  58073. /**
  58074. * Creates a new WaveBlock
  58075. * @param name defines the block name
  58076. */
  58077. constructor(name: string);
  58078. /**
  58079. * Gets the current class name
  58080. * @returns the class name
  58081. */
  58082. getClassName(): string;
  58083. /**
  58084. * Gets the input component
  58085. */
  58086. get input(): NodeMaterialConnectionPoint;
  58087. /**
  58088. * Gets the output component
  58089. */
  58090. get output(): NodeMaterialConnectionPoint;
  58091. protected _buildBlock(state: NodeMaterialBuildState): this;
  58092. serialize(): any;
  58093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58094. }
  58095. }
  58096. declare module BABYLON {
  58097. /**
  58098. * Class used to store a color step for the GradientBlock
  58099. */
  58100. export class GradientBlockColorStep {
  58101. /**
  58102. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58103. */
  58104. step: number;
  58105. /**
  58106. * Gets or sets the color associated with this step
  58107. */
  58108. color: Color3;
  58109. /**
  58110. * Creates a new GradientBlockColorStep
  58111. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58112. * @param color defines the color associated with this step
  58113. */
  58114. constructor(
  58115. /**
  58116. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58117. */
  58118. step: number,
  58119. /**
  58120. * Gets or sets the color associated with this step
  58121. */
  58122. color: Color3);
  58123. }
  58124. /**
  58125. * Block used to return a color from a gradient based on an input value between 0 and 1
  58126. */
  58127. export class GradientBlock extends NodeMaterialBlock {
  58128. /**
  58129. * Gets or sets the list of color steps
  58130. */
  58131. colorSteps: GradientBlockColorStep[];
  58132. /**
  58133. * Creates a new GradientBlock
  58134. * @param name defines the block name
  58135. */
  58136. constructor(name: string);
  58137. /**
  58138. * Gets the current class name
  58139. * @returns the class name
  58140. */
  58141. getClassName(): string;
  58142. /**
  58143. * Gets the gradient input component
  58144. */
  58145. get gradient(): NodeMaterialConnectionPoint;
  58146. /**
  58147. * Gets the output component
  58148. */
  58149. get output(): NodeMaterialConnectionPoint;
  58150. private _writeColorConstant;
  58151. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58152. serialize(): any;
  58153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58154. protected _dumpPropertiesCode(): string;
  58155. }
  58156. }
  58157. declare module BABYLON {
  58158. /**
  58159. * Block used to normalize lerp between 2 values
  58160. */
  58161. export class NLerpBlock extends NodeMaterialBlock {
  58162. /**
  58163. * Creates a new NLerpBlock
  58164. * @param name defines the block name
  58165. */
  58166. constructor(name: string);
  58167. /**
  58168. * Gets the current class name
  58169. * @returns the class name
  58170. */
  58171. getClassName(): string;
  58172. /**
  58173. * Gets the left operand input component
  58174. */
  58175. get left(): NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the right operand input component
  58178. */
  58179. get right(): NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the gradient operand input component
  58182. */
  58183. get gradient(): NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the output component
  58186. */
  58187. get output(): NodeMaterialConnectionPoint;
  58188. protected _buildBlock(state: NodeMaterialBuildState): this;
  58189. }
  58190. }
  58191. declare module BABYLON {
  58192. /**
  58193. * block used to Generate a Worley Noise 3D Noise Pattern
  58194. */
  58195. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58196. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58197. manhattanDistance: boolean;
  58198. /**
  58199. * Creates a new WorleyNoise3DBlock
  58200. * @param name defines the block name
  58201. */
  58202. constructor(name: string);
  58203. /**
  58204. * Gets the current class name
  58205. * @returns the class name
  58206. */
  58207. getClassName(): string;
  58208. /**
  58209. * Gets the seed input component
  58210. */
  58211. get seed(): NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the jitter input component
  58214. */
  58215. get jitter(): NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the output component
  58218. */
  58219. get output(): NodeMaterialConnectionPoint;
  58220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58221. /**
  58222. * Exposes the properties to the UI?
  58223. */
  58224. protected _dumpPropertiesCode(): string;
  58225. /**
  58226. * Exposes the properties to the Seralize?
  58227. */
  58228. serialize(): any;
  58229. /**
  58230. * Exposes the properties to the deseralize?
  58231. */
  58232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58233. }
  58234. }
  58235. declare module BABYLON {
  58236. /**
  58237. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58238. */
  58239. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58240. /**
  58241. * Creates a new SimplexPerlin3DBlock
  58242. * @param name defines the block name
  58243. */
  58244. constructor(name: string);
  58245. /**
  58246. * Gets the current class name
  58247. * @returns the class name
  58248. */
  58249. getClassName(): string;
  58250. /**
  58251. * Gets the seed operand input component
  58252. */
  58253. get seed(): NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the output component
  58256. */
  58257. get output(): NodeMaterialConnectionPoint;
  58258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58259. }
  58260. }
  58261. declare module BABYLON {
  58262. /**
  58263. * Block used to blend normals
  58264. */
  58265. export class NormalBlendBlock extends NodeMaterialBlock {
  58266. /**
  58267. * Creates a new NormalBlendBlock
  58268. * @param name defines the block name
  58269. */
  58270. constructor(name: string);
  58271. /**
  58272. * Gets the current class name
  58273. * @returns the class name
  58274. */
  58275. getClassName(): string;
  58276. /**
  58277. * Gets the first input component
  58278. */
  58279. get normalMap0(): NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the second input component
  58282. */
  58283. get normalMap1(): NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the output component
  58286. */
  58287. get output(): NodeMaterialConnectionPoint;
  58288. protected _buildBlock(state: NodeMaterialBuildState): this;
  58289. }
  58290. }
  58291. declare module BABYLON {
  58292. /**
  58293. * Block used to rotate a 2d vector by a given angle
  58294. */
  58295. export class Rotate2dBlock extends NodeMaterialBlock {
  58296. /**
  58297. * Creates a new Rotate2dBlock
  58298. * @param name defines the block name
  58299. */
  58300. constructor(name: string);
  58301. /**
  58302. * Gets the current class name
  58303. * @returns the class name
  58304. */
  58305. getClassName(): string;
  58306. /**
  58307. * Gets the input vector
  58308. */
  58309. get input(): NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the input angle
  58312. */
  58313. get angle(): NodeMaterialConnectionPoint;
  58314. /**
  58315. * Gets the output component
  58316. */
  58317. get output(): NodeMaterialConnectionPoint;
  58318. autoConfigure(material: NodeMaterial): void;
  58319. protected _buildBlock(state: NodeMaterialBuildState): this;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /**
  58324. * Block used to get the reflected vector from a direction and a normal
  58325. */
  58326. export class ReflectBlock extends NodeMaterialBlock {
  58327. /**
  58328. * Creates a new ReflectBlock
  58329. * @param name defines the block name
  58330. */
  58331. constructor(name: string);
  58332. /**
  58333. * Gets the current class name
  58334. * @returns the class name
  58335. */
  58336. getClassName(): string;
  58337. /**
  58338. * Gets the incident component
  58339. */
  58340. get incident(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Gets the normal component
  58343. */
  58344. get normal(): NodeMaterialConnectionPoint;
  58345. /**
  58346. * Gets the output component
  58347. */
  58348. get output(): NodeMaterialConnectionPoint;
  58349. protected _buildBlock(state: NodeMaterialBuildState): this;
  58350. }
  58351. }
  58352. declare module BABYLON {
  58353. /**
  58354. * Block used to get the refracted vector from a direction and a normal
  58355. */
  58356. export class RefractBlock extends NodeMaterialBlock {
  58357. /**
  58358. * Creates a new RefractBlock
  58359. * @param name defines the block name
  58360. */
  58361. constructor(name: string);
  58362. /**
  58363. * Gets the current class name
  58364. * @returns the class name
  58365. */
  58366. getClassName(): string;
  58367. /**
  58368. * Gets the incident component
  58369. */
  58370. get incident(): NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the normal component
  58373. */
  58374. get normal(): NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the index of refraction component
  58377. */
  58378. get ior(): NodeMaterialConnectionPoint;
  58379. /**
  58380. * Gets the output component
  58381. */
  58382. get output(): NodeMaterialConnectionPoint;
  58383. protected _buildBlock(state: NodeMaterialBuildState): this;
  58384. }
  58385. }
  58386. declare module BABYLON {
  58387. /**
  58388. * Block used to desaturate a color
  58389. */
  58390. export class DesaturateBlock extends NodeMaterialBlock {
  58391. /**
  58392. * Creates a new DesaturateBlock
  58393. * @param name defines the block name
  58394. */
  58395. constructor(name: string);
  58396. /**
  58397. * Gets the current class name
  58398. * @returns the class name
  58399. */
  58400. getClassName(): string;
  58401. /**
  58402. * Gets the color operand input component
  58403. */
  58404. get color(): NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the level operand input component
  58407. */
  58408. get level(): NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the output component
  58411. */
  58412. get output(): NodeMaterialConnectionPoint;
  58413. protected _buildBlock(state: NodeMaterialBuildState): this;
  58414. }
  58415. }
  58416. declare module BABYLON {
  58417. /**
  58418. * Effect Render Options
  58419. */
  58420. export interface IEffectRendererOptions {
  58421. /**
  58422. * Defines the vertices positions.
  58423. */
  58424. positions?: number[];
  58425. /**
  58426. * Defines the indices.
  58427. */
  58428. indices?: number[];
  58429. }
  58430. /**
  58431. * Helper class to render one or more effects
  58432. */
  58433. export class EffectRenderer {
  58434. private engine;
  58435. private static _DefaultOptions;
  58436. private _vertexBuffers;
  58437. private _indexBuffer;
  58438. private _ringBufferIndex;
  58439. private _ringScreenBuffer;
  58440. private _fullscreenViewport;
  58441. private _getNextFrameBuffer;
  58442. /**
  58443. * Creates an effect renderer
  58444. * @param engine the engine to use for rendering
  58445. * @param options defines the options of the effect renderer
  58446. */
  58447. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58448. /**
  58449. * Sets the current viewport in normalized coordinates 0-1
  58450. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58451. */
  58452. setViewport(viewport?: Viewport): void;
  58453. /**
  58454. * Binds the embedded attributes buffer to the effect.
  58455. * @param effect Defines the effect to bind the attributes for
  58456. */
  58457. bindBuffers(effect: Effect): void;
  58458. /**
  58459. * Sets the current effect wrapper to use during draw.
  58460. * The effect needs to be ready before calling this api.
  58461. * This also sets the default full screen position attribute.
  58462. * @param effectWrapper Defines the effect to draw with
  58463. */
  58464. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58465. /**
  58466. * Draws a full screen quad.
  58467. */
  58468. draw(): void;
  58469. /**
  58470. * renders one or more effects to a specified texture
  58471. * @param effectWrappers list of effects to renderer
  58472. * @param outputTexture texture to draw to, if null it will render to the screen
  58473. */
  58474. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58475. /**
  58476. * Disposes of the effect renderer
  58477. */
  58478. dispose(): void;
  58479. }
  58480. /**
  58481. * Options to create an EffectWrapper
  58482. */
  58483. interface EffectWrapperCreationOptions {
  58484. /**
  58485. * Engine to use to create the effect
  58486. */
  58487. engine: ThinEngine;
  58488. /**
  58489. * Fragment shader for the effect
  58490. */
  58491. fragmentShader: string;
  58492. /**
  58493. * Vertex shader for the effect
  58494. */
  58495. vertexShader?: string;
  58496. /**
  58497. * Attributes to use in the shader
  58498. */
  58499. attributeNames?: Array<string>;
  58500. /**
  58501. * Uniforms to use in the shader
  58502. */
  58503. uniformNames?: Array<string>;
  58504. /**
  58505. * Texture sampler names to use in the shader
  58506. */
  58507. samplerNames?: Array<string>;
  58508. /**
  58509. * The friendly name of the effect displayed in Spector.
  58510. */
  58511. name?: string;
  58512. }
  58513. /**
  58514. * Wraps an effect to be used for rendering
  58515. */
  58516. export class EffectWrapper {
  58517. /**
  58518. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58519. */
  58520. onApplyObservable: Observable<{}>;
  58521. /**
  58522. * The underlying effect
  58523. */
  58524. effect: Effect;
  58525. /**
  58526. * Creates an effect to be renderer
  58527. * @param creationOptions options to create the effect
  58528. */
  58529. constructor(creationOptions: EffectWrapperCreationOptions);
  58530. /**
  58531. * Disposes of the effect wrapper
  58532. */
  58533. dispose(): void;
  58534. }
  58535. }
  58536. declare module BABYLON {
  58537. /**
  58538. * Helper class to push actions to a pool of workers.
  58539. */
  58540. export class WorkerPool implements IDisposable {
  58541. private _workerInfos;
  58542. private _pendingActions;
  58543. /**
  58544. * Constructor
  58545. * @param workers Array of workers to use for actions
  58546. */
  58547. constructor(workers: Array<Worker>);
  58548. /**
  58549. * Terminates all workers and clears any pending actions.
  58550. */
  58551. dispose(): void;
  58552. /**
  58553. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58554. * pended until a worker has completed its action.
  58555. * @param action The action to perform. Call onComplete when the action is complete.
  58556. */
  58557. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58558. private _execute;
  58559. }
  58560. }
  58561. declare module BABYLON {
  58562. /**
  58563. * Configuration for Draco compression
  58564. */
  58565. export interface IDracoCompressionConfiguration {
  58566. /**
  58567. * Configuration for the decoder.
  58568. */
  58569. decoder: {
  58570. /**
  58571. * The url to the WebAssembly module.
  58572. */
  58573. wasmUrl?: string;
  58574. /**
  58575. * The url to the WebAssembly binary.
  58576. */
  58577. wasmBinaryUrl?: string;
  58578. /**
  58579. * The url to the fallback JavaScript module.
  58580. */
  58581. fallbackUrl?: string;
  58582. };
  58583. }
  58584. /**
  58585. * Draco compression (https://google.github.io/draco/)
  58586. *
  58587. * This class wraps the Draco module.
  58588. *
  58589. * **Encoder**
  58590. *
  58591. * The encoder is not currently implemented.
  58592. *
  58593. * **Decoder**
  58594. *
  58595. * 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.
  58596. *
  58597. * To update the configuration, use the following code:
  58598. * ```javascript
  58599. * DracoCompression.Configuration = {
  58600. * decoder: {
  58601. * wasmUrl: "<url to the WebAssembly library>",
  58602. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58603. * fallbackUrl: "<url to the fallback JavaScript library>",
  58604. * }
  58605. * };
  58606. * ```
  58607. *
  58608. * 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.
  58609. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58610. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58611. *
  58612. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58613. * ```javascript
  58614. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58615. * ```
  58616. *
  58617. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58618. */
  58619. export class DracoCompression implements IDisposable {
  58620. private _workerPoolPromise?;
  58621. private _decoderModulePromise?;
  58622. /**
  58623. * The configuration. Defaults to the following urls:
  58624. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58625. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58626. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58627. */
  58628. static Configuration: IDracoCompressionConfiguration;
  58629. /**
  58630. * Returns true if the decoder configuration is available.
  58631. */
  58632. static get DecoderAvailable(): boolean;
  58633. /**
  58634. * Default number of workers to create when creating the draco compression object.
  58635. */
  58636. static DefaultNumWorkers: number;
  58637. private static GetDefaultNumWorkers;
  58638. private static _Default;
  58639. /**
  58640. * Default instance for the draco compression object.
  58641. */
  58642. static get Default(): DracoCompression;
  58643. /**
  58644. * Constructor
  58645. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58646. */
  58647. constructor(numWorkers?: number);
  58648. /**
  58649. * Stop all async operations and release resources.
  58650. */
  58651. dispose(): void;
  58652. /**
  58653. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58654. * @returns a promise that resolves when ready
  58655. */
  58656. whenReadyAsync(): Promise<void>;
  58657. /**
  58658. * Decode Draco compressed mesh data to vertex data.
  58659. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58660. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58661. * @returns A promise that resolves with the decoded vertex data
  58662. */
  58663. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58664. [kind: string]: number;
  58665. }): Promise<VertexData>;
  58666. }
  58667. }
  58668. declare module BABYLON {
  58669. /**
  58670. * Class for building Constructive Solid Geometry
  58671. */
  58672. export class CSG {
  58673. private polygons;
  58674. /**
  58675. * The world matrix
  58676. */
  58677. matrix: Matrix;
  58678. /**
  58679. * Stores the position
  58680. */
  58681. position: Vector3;
  58682. /**
  58683. * Stores the rotation
  58684. */
  58685. rotation: Vector3;
  58686. /**
  58687. * Stores the rotation quaternion
  58688. */
  58689. rotationQuaternion: Nullable<Quaternion>;
  58690. /**
  58691. * Stores the scaling vector
  58692. */
  58693. scaling: Vector3;
  58694. /**
  58695. * Convert the Mesh to CSG
  58696. * @param mesh The Mesh to convert to CSG
  58697. * @returns A new CSG from the Mesh
  58698. */
  58699. static FromMesh(mesh: Mesh): CSG;
  58700. /**
  58701. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58702. * @param polygons Polygons used to construct a CSG solid
  58703. */
  58704. private static FromPolygons;
  58705. /**
  58706. * Clones, or makes a deep copy, of the CSG
  58707. * @returns A new CSG
  58708. */
  58709. clone(): CSG;
  58710. /**
  58711. * Unions this CSG with another CSG
  58712. * @param csg The CSG to union against this CSG
  58713. * @returns The unioned CSG
  58714. */
  58715. union(csg: CSG): CSG;
  58716. /**
  58717. * Unions this CSG with another CSG in place
  58718. * @param csg The CSG to union against this CSG
  58719. */
  58720. unionInPlace(csg: CSG): void;
  58721. /**
  58722. * Subtracts this CSG with another CSG
  58723. * @param csg The CSG to subtract against this CSG
  58724. * @returns A new CSG
  58725. */
  58726. subtract(csg: CSG): CSG;
  58727. /**
  58728. * Subtracts this CSG with another CSG in place
  58729. * @param csg The CSG to subtact against this CSG
  58730. */
  58731. subtractInPlace(csg: CSG): void;
  58732. /**
  58733. * Intersect this CSG with another CSG
  58734. * @param csg The CSG to intersect against this CSG
  58735. * @returns A new CSG
  58736. */
  58737. intersect(csg: CSG): CSG;
  58738. /**
  58739. * Intersects this CSG with another CSG in place
  58740. * @param csg The CSG to intersect against this CSG
  58741. */
  58742. intersectInPlace(csg: CSG): void;
  58743. /**
  58744. * Return a new CSG solid with solid and empty space switched. This solid is
  58745. * not modified.
  58746. * @returns A new CSG solid with solid and empty space switched
  58747. */
  58748. inverse(): CSG;
  58749. /**
  58750. * Inverses the CSG in place
  58751. */
  58752. inverseInPlace(): void;
  58753. /**
  58754. * This is used to keep meshes transformations so they can be restored
  58755. * when we build back a Babylon Mesh
  58756. * NB : All CSG operations are performed in world coordinates
  58757. * @param csg The CSG to copy the transform attributes from
  58758. * @returns This CSG
  58759. */
  58760. copyTransformAttributes(csg: CSG): CSG;
  58761. /**
  58762. * Build Raw mesh from CSG
  58763. * Coordinates here are in world space
  58764. * @param name The name of the mesh geometry
  58765. * @param scene The Scene
  58766. * @param keepSubMeshes Specifies if the submeshes should be kept
  58767. * @returns A new Mesh
  58768. */
  58769. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58770. /**
  58771. * Build Mesh from CSG taking material and transforms into account
  58772. * @param name The name of the Mesh
  58773. * @param material The material of the Mesh
  58774. * @param scene The Scene
  58775. * @param keepSubMeshes Specifies if submeshes should be kept
  58776. * @returns The new Mesh
  58777. */
  58778. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58779. }
  58780. }
  58781. declare module BABYLON {
  58782. /**
  58783. * Class used to create a trail following a mesh
  58784. */
  58785. export class TrailMesh extends Mesh {
  58786. private _generator;
  58787. private _autoStart;
  58788. private _running;
  58789. private _diameter;
  58790. private _length;
  58791. private _sectionPolygonPointsCount;
  58792. private _sectionVectors;
  58793. private _sectionNormalVectors;
  58794. private _beforeRenderObserver;
  58795. /**
  58796. * @constructor
  58797. * @param name The value used by scene.getMeshByName() to do a lookup.
  58798. * @param generator The mesh to generate a trail.
  58799. * @param scene The scene to add this mesh to.
  58800. * @param diameter Diameter of trailing mesh. Default is 1.
  58801. * @param length Length of trailing mesh. Default is 60.
  58802. * @param autoStart Automatically start trailing mesh. Default true.
  58803. */
  58804. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58805. /**
  58806. * "TrailMesh"
  58807. * @returns "TrailMesh"
  58808. */
  58809. getClassName(): string;
  58810. private _createMesh;
  58811. /**
  58812. * Start trailing mesh.
  58813. */
  58814. start(): void;
  58815. /**
  58816. * Stop trailing mesh.
  58817. */
  58818. stop(): void;
  58819. /**
  58820. * Update trailing mesh geometry.
  58821. */
  58822. update(): void;
  58823. /**
  58824. * Returns a new TrailMesh object.
  58825. * @param name is a string, the name given to the new mesh
  58826. * @param newGenerator use new generator object for cloned trail mesh
  58827. * @returns a new mesh
  58828. */
  58829. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58830. /**
  58831. * Serializes this trail mesh
  58832. * @param serializationObject object to write serialization to
  58833. */
  58834. serialize(serializationObject: any): void;
  58835. /**
  58836. * Parses a serialized trail mesh
  58837. * @param parsedMesh the serialized mesh
  58838. * @param scene the scene to create the trail mesh in
  58839. * @returns the created trail mesh
  58840. */
  58841. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58842. }
  58843. }
  58844. declare module BABYLON {
  58845. /**
  58846. * Class containing static functions to help procedurally build meshes
  58847. */
  58848. export class TiledBoxBuilder {
  58849. /**
  58850. * Creates a box mesh
  58851. * 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)
  58852. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58854. * * 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
  58855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58856. * @param name defines the name of the mesh
  58857. * @param options defines the options used to create the mesh
  58858. * @param scene defines the hosting scene
  58859. * @returns the box mesh
  58860. */
  58861. static CreateTiledBox(name: string, options: {
  58862. pattern?: number;
  58863. width?: number;
  58864. height?: number;
  58865. depth?: number;
  58866. tileSize?: number;
  58867. tileWidth?: number;
  58868. tileHeight?: number;
  58869. alignHorizontal?: number;
  58870. alignVertical?: number;
  58871. faceUV?: Vector4[];
  58872. faceColors?: Color4[];
  58873. sideOrientation?: number;
  58874. updatable?: boolean;
  58875. }, scene?: Nullable<Scene>): Mesh;
  58876. }
  58877. }
  58878. declare module BABYLON {
  58879. /**
  58880. * Class containing static functions to help procedurally build meshes
  58881. */
  58882. export class TorusKnotBuilder {
  58883. /**
  58884. * Creates a torus knot mesh
  58885. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58886. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58887. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58888. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58890. * * 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
  58891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58892. * @param name defines the name of the mesh
  58893. * @param options defines the options used to create the mesh
  58894. * @param scene defines the hosting scene
  58895. * @returns the torus knot mesh
  58896. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58897. */
  58898. static CreateTorusKnot(name: string, options: {
  58899. radius?: number;
  58900. tube?: number;
  58901. radialSegments?: number;
  58902. tubularSegments?: number;
  58903. p?: number;
  58904. q?: number;
  58905. updatable?: boolean;
  58906. sideOrientation?: number;
  58907. frontUVs?: Vector4;
  58908. backUVs?: Vector4;
  58909. }, scene: any): Mesh;
  58910. }
  58911. }
  58912. declare module BABYLON {
  58913. /**
  58914. * Polygon
  58915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58916. */
  58917. export class Polygon {
  58918. /**
  58919. * Creates a rectangle
  58920. * @param xmin bottom X coord
  58921. * @param ymin bottom Y coord
  58922. * @param xmax top X coord
  58923. * @param ymax top Y coord
  58924. * @returns points that make the resulting rectation
  58925. */
  58926. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58927. /**
  58928. * Creates a circle
  58929. * @param radius radius of circle
  58930. * @param cx scale in x
  58931. * @param cy scale in y
  58932. * @param numberOfSides number of sides that make up the circle
  58933. * @returns points that make the resulting circle
  58934. */
  58935. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58936. /**
  58937. * Creates a polygon from input string
  58938. * @param input Input polygon data
  58939. * @returns the parsed points
  58940. */
  58941. static Parse(input: string): Vector2[];
  58942. /**
  58943. * Starts building a polygon from x and y coordinates
  58944. * @param x x coordinate
  58945. * @param y y coordinate
  58946. * @returns the started path2
  58947. */
  58948. static StartingAt(x: number, y: number): Path2;
  58949. }
  58950. /**
  58951. * Builds a polygon
  58952. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58953. */
  58954. export class PolygonMeshBuilder {
  58955. private _points;
  58956. private _outlinepoints;
  58957. private _holes;
  58958. private _name;
  58959. private _scene;
  58960. private _epoints;
  58961. private _eholes;
  58962. private _addToepoint;
  58963. /**
  58964. * Babylon reference to the earcut plugin.
  58965. */
  58966. bjsEarcut: any;
  58967. /**
  58968. * Creates a PolygonMeshBuilder
  58969. * @param name name of the builder
  58970. * @param contours Path of the polygon
  58971. * @param scene scene to add to when creating the mesh
  58972. * @param earcutInjection can be used to inject your own earcut reference
  58973. */
  58974. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58975. /**
  58976. * Adds a whole within the polygon
  58977. * @param hole Array of points defining the hole
  58978. * @returns this
  58979. */
  58980. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58981. /**
  58982. * Creates the polygon
  58983. * @param updatable If the mesh should be updatable
  58984. * @param depth The depth of the mesh created
  58985. * @returns the created mesh
  58986. */
  58987. build(updatable?: boolean, depth?: number): Mesh;
  58988. /**
  58989. * Creates the polygon
  58990. * @param depth The depth of the mesh created
  58991. * @returns the created VertexData
  58992. */
  58993. buildVertexData(depth?: number): VertexData;
  58994. /**
  58995. * Adds a side to the polygon
  58996. * @param positions points that make the polygon
  58997. * @param normals normals of the polygon
  58998. * @param uvs uvs of the polygon
  58999. * @param indices indices of the polygon
  59000. * @param bounds bounds of the polygon
  59001. * @param points points of the polygon
  59002. * @param depth depth of the polygon
  59003. * @param flip flip of the polygon
  59004. */
  59005. private addSide;
  59006. }
  59007. }
  59008. declare module BABYLON {
  59009. /**
  59010. * Class containing static functions to help procedurally build meshes
  59011. */
  59012. export class PolygonBuilder {
  59013. /**
  59014. * Creates a polygon mesh
  59015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59016. * * 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
  59017. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59019. * * 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)
  59020. * * Remember you can only change the shape positions, not their number when updating a polygon
  59021. * @param name defines the name of the mesh
  59022. * @param options defines the options used to create the mesh
  59023. * @param scene defines the hosting scene
  59024. * @param earcutInjection can be used to inject your own earcut reference
  59025. * @returns the polygon mesh
  59026. */
  59027. static CreatePolygon(name: string, options: {
  59028. shape: Vector3[];
  59029. holes?: Vector3[][];
  59030. depth?: number;
  59031. faceUV?: Vector4[];
  59032. faceColors?: Color4[];
  59033. updatable?: boolean;
  59034. sideOrientation?: number;
  59035. frontUVs?: Vector4;
  59036. backUVs?: Vector4;
  59037. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59038. /**
  59039. * Creates an extruded polygon mesh, with depth in the Y direction.
  59040. * * 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)
  59041. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59042. * @param name defines the name of the mesh
  59043. * @param options defines the options used to create the mesh
  59044. * @param scene defines the hosting scene
  59045. * @param earcutInjection can be used to inject your own earcut reference
  59046. * @returns the polygon mesh
  59047. */
  59048. static ExtrudePolygon(name: string, options: {
  59049. shape: Vector3[];
  59050. holes?: Vector3[][];
  59051. depth?: number;
  59052. faceUV?: Vector4[];
  59053. faceColors?: Color4[];
  59054. updatable?: boolean;
  59055. sideOrientation?: number;
  59056. frontUVs?: Vector4;
  59057. backUVs?: Vector4;
  59058. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59059. }
  59060. }
  59061. declare module BABYLON {
  59062. /**
  59063. * Class containing static functions to help procedurally build meshes
  59064. */
  59065. export class LatheBuilder {
  59066. /**
  59067. * Creates lathe mesh.
  59068. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59069. * * 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
  59070. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59071. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59072. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59073. * * 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
  59074. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59075. * * 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
  59076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59077. * * 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
  59078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59080. * @param name defines the name of the mesh
  59081. * @param options defines the options used to create the mesh
  59082. * @param scene defines the hosting scene
  59083. * @returns the lathe mesh
  59084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59085. */
  59086. static CreateLathe(name: string, options: {
  59087. shape: Vector3[];
  59088. radius?: number;
  59089. tessellation?: number;
  59090. clip?: number;
  59091. arc?: number;
  59092. closed?: boolean;
  59093. updatable?: boolean;
  59094. sideOrientation?: number;
  59095. frontUVs?: Vector4;
  59096. backUVs?: Vector4;
  59097. cap?: number;
  59098. invertUV?: boolean;
  59099. }, scene?: Nullable<Scene>): Mesh;
  59100. }
  59101. }
  59102. declare module BABYLON {
  59103. /**
  59104. * Class containing static functions to help procedurally build meshes
  59105. */
  59106. export class TiledPlaneBuilder {
  59107. /**
  59108. * Creates a tiled plane mesh
  59109. * * The parameter `pattern` will, depending on value, do nothing or
  59110. * * * flip (reflect about central vertical) alternate tiles across and up
  59111. * * * flip every tile on alternate rows
  59112. * * * rotate (180 degs) alternate tiles across and up
  59113. * * * rotate every tile on alternate rows
  59114. * * * flip and rotate alternate tiles across and up
  59115. * * * flip and rotate every tile on alternate rows
  59116. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59117. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59118. * * 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
  59119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59120. * * 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)
  59121. * * 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)
  59122. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59123. * @param name defines the name of the mesh
  59124. * @param options defines the options used to create the mesh
  59125. * @param scene defines the hosting scene
  59126. * @returns the box mesh
  59127. */
  59128. static CreateTiledPlane(name: string, options: {
  59129. pattern?: number;
  59130. tileSize?: number;
  59131. tileWidth?: number;
  59132. tileHeight?: number;
  59133. size?: number;
  59134. width?: number;
  59135. height?: number;
  59136. alignHorizontal?: number;
  59137. alignVertical?: number;
  59138. sideOrientation?: number;
  59139. frontUVs?: Vector4;
  59140. backUVs?: Vector4;
  59141. updatable?: boolean;
  59142. }, scene?: Nullable<Scene>): Mesh;
  59143. }
  59144. }
  59145. declare module BABYLON {
  59146. /**
  59147. * Class containing static functions to help procedurally build meshes
  59148. */
  59149. export class TubeBuilder {
  59150. /**
  59151. * Creates a tube mesh.
  59152. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59153. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59154. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59155. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59156. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59157. * * 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)
  59158. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59159. * * 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
  59160. * * 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
  59161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59162. * * 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
  59163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59165. * @param name defines the name of the mesh
  59166. * @param options defines the options used to create the mesh
  59167. * @param scene defines the hosting scene
  59168. * @returns the tube mesh
  59169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59170. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59171. */
  59172. static CreateTube(name: string, options: {
  59173. path: Vector3[];
  59174. radius?: number;
  59175. tessellation?: number;
  59176. radiusFunction?: {
  59177. (i: number, distance: number): number;
  59178. };
  59179. cap?: number;
  59180. arc?: number;
  59181. updatable?: boolean;
  59182. sideOrientation?: number;
  59183. frontUVs?: Vector4;
  59184. backUVs?: Vector4;
  59185. instance?: Mesh;
  59186. invertUV?: boolean;
  59187. }, scene?: Nullable<Scene>): Mesh;
  59188. }
  59189. }
  59190. declare module BABYLON {
  59191. /**
  59192. * Class containing static functions to help procedurally build meshes
  59193. */
  59194. export class IcoSphereBuilder {
  59195. /**
  59196. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59197. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59198. * * 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`)
  59199. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59200. * * 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
  59201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59202. * * 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
  59203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59204. * @param name defines the name of the mesh
  59205. * @param options defines the options used to create the mesh
  59206. * @param scene defines the hosting scene
  59207. * @returns the icosahedron mesh
  59208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59209. */
  59210. static CreateIcoSphere(name: string, options: {
  59211. radius?: number;
  59212. radiusX?: number;
  59213. radiusY?: number;
  59214. radiusZ?: number;
  59215. flat?: boolean;
  59216. subdivisions?: number;
  59217. sideOrientation?: number;
  59218. frontUVs?: Vector4;
  59219. backUVs?: Vector4;
  59220. updatable?: boolean;
  59221. }, scene?: Nullable<Scene>): Mesh;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Class containing static functions to help procedurally build meshes
  59227. */
  59228. export class DecalBuilder {
  59229. /**
  59230. * Creates a decal mesh.
  59231. * 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
  59232. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59233. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59234. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59235. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59236. * @param name defines the name of the mesh
  59237. * @param sourceMesh defines the mesh where the decal must be applied
  59238. * @param options defines the options used to create the mesh
  59239. * @param scene defines the hosting scene
  59240. * @returns the decal mesh
  59241. * @see https://doc.babylonjs.com/how_to/decals
  59242. */
  59243. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59244. position?: Vector3;
  59245. normal?: Vector3;
  59246. size?: Vector3;
  59247. angle?: number;
  59248. }): Mesh;
  59249. }
  59250. }
  59251. declare module BABYLON {
  59252. /**
  59253. * Class containing static functions to help procedurally build meshes
  59254. */
  59255. export class MeshBuilder {
  59256. /**
  59257. * Creates a box mesh
  59258. * * The parameter `size` sets the size (float) of each box side (default 1)
  59259. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59260. * * 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)
  59261. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59263. * * 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
  59264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59265. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59266. * @param name defines the name of the mesh
  59267. * @param options defines the options used to create the mesh
  59268. * @param scene defines the hosting scene
  59269. * @returns the box mesh
  59270. */
  59271. static CreateBox(name: string, options: {
  59272. size?: number;
  59273. width?: number;
  59274. height?: number;
  59275. depth?: number;
  59276. faceUV?: Vector4[];
  59277. faceColors?: Color4[];
  59278. sideOrientation?: number;
  59279. frontUVs?: Vector4;
  59280. backUVs?: Vector4;
  59281. updatable?: boolean;
  59282. }, scene?: Nullable<Scene>): Mesh;
  59283. /**
  59284. * Creates a tiled box mesh
  59285. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59287. * @param name defines the name of the mesh
  59288. * @param options defines the options used to create the mesh
  59289. * @param scene defines the hosting scene
  59290. * @returns the tiled box mesh
  59291. */
  59292. static CreateTiledBox(name: string, options: {
  59293. pattern?: number;
  59294. size?: number;
  59295. width?: number;
  59296. height?: number;
  59297. depth: number;
  59298. tileSize?: number;
  59299. tileWidth?: number;
  59300. tileHeight?: number;
  59301. faceUV?: Vector4[];
  59302. faceColors?: Color4[];
  59303. alignHorizontal?: number;
  59304. alignVertical?: number;
  59305. sideOrientation?: number;
  59306. updatable?: boolean;
  59307. }, scene?: Nullable<Scene>): Mesh;
  59308. /**
  59309. * Creates a sphere mesh
  59310. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59311. * * 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`)
  59312. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59313. * * 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
  59314. * * 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)
  59315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59316. * * 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
  59317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59318. * @param name defines the name of the mesh
  59319. * @param options defines the options used to create the mesh
  59320. * @param scene defines the hosting scene
  59321. * @returns the sphere mesh
  59322. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59323. */
  59324. static CreateSphere(name: string, options: {
  59325. segments?: number;
  59326. diameter?: number;
  59327. diameterX?: number;
  59328. diameterY?: number;
  59329. diameterZ?: number;
  59330. arc?: number;
  59331. slice?: number;
  59332. sideOrientation?: number;
  59333. frontUVs?: Vector4;
  59334. backUVs?: Vector4;
  59335. updatable?: boolean;
  59336. }, scene?: Nullable<Scene>): Mesh;
  59337. /**
  59338. * Creates a plane polygonal mesh. By default, this is a disc
  59339. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59340. * * 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
  59341. * * 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
  59342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59343. * * 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
  59344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59345. * @param name defines the name of the mesh
  59346. * @param options defines the options used to create the mesh
  59347. * @param scene defines the hosting scene
  59348. * @returns the plane polygonal mesh
  59349. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59350. */
  59351. static CreateDisc(name: string, options: {
  59352. radius?: number;
  59353. tessellation?: number;
  59354. arc?: number;
  59355. updatable?: boolean;
  59356. sideOrientation?: number;
  59357. frontUVs?: Vector4;
  59358. backUVs?: Vector4;
  59359. }, scene?: Nullable<Scene>): Mesh;
  59360. /**
  59361. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59362. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59363. * * 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`)
  59364. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59365. * * 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
  59366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59367. * * 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
  59368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59369. * @param name defines the name of the mesh
  59370. * @param options defines the options used to create the mesh
  59371. * @param scene defines the hosting scene
  59372. * @returns the icosahedron mesh
  59373. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59374. */
  59375. static CreateIcoSphere(name: string, options: {
  59376. radius?: number;
  59377. radiusX?: number;
  59378. radiusY?: number;
  59379. radiusZ?: number;
  59380. flat?: boolean;
  59381. subdivisions?: number;
  59382. sideOrientation?: number;
  59383. frontUVs?: Vector4;
  59384. backUVs?: Vector4;
  59385. updatable?: boolean;
  59386. }, scene?: Nullable<Scene>): Mesh;
  59387. /**
  59388. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59389. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59390. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59391. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59392. * * 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
  59393. * * 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
  59394. * * 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
  59395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59396. * * 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
  59397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59398. * * 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
  59399. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59400. * * 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
  59401. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59403. * @param name defines the name of the mesh
  59404. * @param options defines the options used to create the mesh
  59405. * @param scene defines the hosting scene
  59406. * @returns the ribbon mesh
  59407. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59409. */
  59410. static CreateRibbon(name: string, options: {
  59411. pathArray: Vector3[][];
  59412. closeArray?: boolean;
  59413. closePath?: boolean;
  59414. offset?: number;
  59415. updatable?: boolean;
  59416. sideOrientation?: number;
  59417. frontUVs?: Vector4;
  59418. backUVs?: Vector4;
  59419. instance?: Mesh;
  59420. invertUV?: boolean;
  59421. uvs?: Vector2[];
  59422. colors?: Color4[];
  59423. }, scene?: Nullable<Scene>): Mesh;
  59424. /**
  59425. * Creates a cylinder or a cone mesh
  59426. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59427. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59428. * * 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.
  59429. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59430. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59431. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59432. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59433. * * 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).
  59434. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59435. * * 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).
  59436. * * 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
  59437. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59438. * * 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
  59439. * * 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.
  59440. * * If `enclose` is false, a ring surface is one element.
  59441. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59442. * * 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
  59443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59444. * * 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
  59445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59446. * @param name defines the name of the mesh
  59447. * @param options defines the options used to create the mesh
  59448. * @param scene defines the hosting scene
  59449. * @returns the cylinder mesh
  59450. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59451. */
  59452. static CreateCylinder(name: string, options: {
  59453. height?: number;
  59454. diameterTop?: number;
  59455. diameterBottom?: number;
  59456. diameter?: number;
  59457. tessellation?: number;
  59458. subdivisions?: number;
  59459. arc?: number;
  59460. faceColors?: Color4[];
  59461. faceUV?: Vector4[];
  59462. updatable?: boolean;
  59463. hasRings?: boolean;
  59464. enclose?: boolean;
  59465. cap?: number;
  59466. sideOrientation?: number;
  59467. frontUVs?: Vector4;
  59468. backUVs?: Vector4;
  59469. }, scene?: Nullable<Scene>): Mesh;
  59470. /**
  59471. * Creates a torus mesh
  59472. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59473. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59474. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59476. * * 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
  59477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59478. * @param name defines the name of the mesh
  59479. * @param options defines the options used to create the mesh
  59480. * @param scene defines the hosting scene
  59481. * @returns the torus mesh
  59482. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59483. */
  59484. static CreateTorus(name: string, options: {
  59485. diameter?: number;
  59486. thickness?: number;
  59487. tessellation?: number;
  59488. updatable?: boolean;
  59489. sideOrientation?: number;
  59490. frontUVs?: Vector4;
  59491. backUVs?: Vector4;
  59492. }, scene?: Nullable<Scene>): Mesh;
  59493. /**
  59494. * Creates a torus knot mesh
  59495. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59496. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59497. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59498. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59500. * * 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
  59501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59502. * @param name defines the name of the mesh
  59503. * @param options defines the options used to create the mesh
  59504. * @param scene defines the hosting scene
  59505. * @returns the torus knot mesh
  59506. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59507. */
  59508. static CreateTorusKnot(name: string, options: {
  59509. radius?: number;
  59510. tube?: number;
  59511. radialSegments?: number;
  59512. tubularSegments?: number;
  59513. p?: number;
  59514. q?: number;
  59515. updatable?: boolean;
  59516. sideOrientation?: number;
  59517. frontUVs?: Vector4;
  59518. backUVs?: Vector4;
  59519. }, scene?: Nullable<Scene>): Mesh;
  59520. /**
  59521. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59522. * * 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
  59523. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59524. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59525. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59526. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59527. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59528. * * 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
  59529. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59532. * @param name defines the name of the new line system
  59533. * @param options defines the options used to create the line system
  59534. * @param scene defines the hosting scene
  59535. * @returns a new line system mesh
  59536. */
  59537. static CreateLineSystem(name: string, options: {
  59538. lines: Vector3[][];
  59539. updatable?: boolean;
  59540. instance?: Nullable<LinesMesh>;
  59541. colors?: Nullable<Color4[][]>;
  59542. useVertexAlpha?: boolean;
  59543. }, scene: Nullable<Scene>): LinesMesh;
  59544. /**
  59545. * Creates a line mesh
  59546. * 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
  59547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59548. * * The parameter `points` is an array successive Vector3
  59549. * * 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
  59550. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59551. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59552. * * When updating an instance, remember that only point positions can change, not the number of points
  59553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59555. * @param name defines the name of the new line system
  59556. * @param options defines the options used to create the line system
  59557. * @param scene defines the hosting scene
  59558. * @returns a new line mesh
  59559. */
  59560. static CreateLines(name: string, options: {
  59561. points: Vector3[];
  59562. updatable?: boolean;
  59563. instance?: Nullable<LinesMesh>;
  59564. colors?: Color4[];
  59565. useVertexAlpha?: boolean;
  59566. }, scene?: Nullable<Scene>): LinesMesh;
  59567. /**
  59568. * Creates a dashed line mesh
  59569. * * 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
  59570. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59571. * * The parameter `points` is an array successive Vector3
  59572. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59573. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59574. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59575. * * 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
  59576. * * When updating an instance, remember that only point positions can change, not the number of points
  59577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59578. * @param name defines the name of the mesh
  59579. * @param options defines the options used to create the mesh
  59580. * @param scene defines the hosting scene
  59581. * @returns the dashed line mesh
  59582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59583. */
  59584. static CreateDashedLines(name: string, options: {
  59585. points: Vector3[];
  59586. dashSize?: number;
  59587. gapSize?: number;
  59588. dashNb?: number;
  59589. updatable?: boolean;
  59590. instance?: LinesMesh;
  59591. }, scene?: Nullable<Scene>): LinesMesh;
  59592. /**
  59593. * 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.
  59594. * * 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.
  59595. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59596. * * 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.
  59597. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59598. * * 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
  59599. * * 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
  59600. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59602. * * 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
  59603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59605. * @param name defines the name of the mesh
  59606. * @param options defines the options used to create the mesh
  59607. * @param scene defines the hosting scene
  59608. * @returns the extruded shape mesh
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59611. */
  59612. static ExtrudeShape(name: string, options: {
  59613. shape: Vector3[];
  59614. path: Vector3[];
  59615. scale?: number;
  59616. rotation?: number;
  59617. cap?: number;
  59618. updatable?: boolean;
  59619. sideOrientation?: number;
  59620. frontUVs?: Vector4;
  59621. backUVs?: Vector4;
  59622. instance?: Mesh;
  59623. invertUV?: boolean;
  59624. }, scene?: Nullable<Scene>): Mesh;
  59625. /**
  59626. * Creates an custom extruded shape mesh.
  59627. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59628. * * 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.
  59629. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59630. * * 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
  59631. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59632. * * 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
  59633. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59634. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59635. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59636. * * 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
  59637. * * 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
  59638. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59640. * * 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
  59641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59643. * @param name defines the name of the mesh
  59644. * @param options defines the options used to create the mesh
  59645. * @param scene defines the hosting scene
  59646. * @returns the custom extruded shape mesh
  59647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59650. */
  59651. static ExtrudeShapeCustom(name: string, options: {
  59652. shape: Vector3[];
  59653. path: Vector3[];
  59654. scaleFunction?: any;
  59655. rotationFunction?: any;
  59656. ribbonCloseArray?: boolean;
  59657. ribbonClosePath?: boolean;
  59658. cap?: number;
  59659. updatable?: boolean;
  59660. sideOrientation?: number;
  59661. frontUVs?: Vector4;
  59662. backUVs?: Vector4;
  59663. instance?: Mesh;
  59664. invertUV?: boolean;
  59665. }, scene?: Nullable<Scene>): Mesh;
  59666. /**
  59667. * Creates lathe mesh.
  59668. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59669. * * 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
  59670. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59671. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59672. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59673. * * 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
  59674. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59675. * * 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
  59676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59677. * * 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
  59678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59680. * @param name defines the name of the mesh
  59681. * @param options defines the options used to create the mesh
  59682. * @param scene defines the hosting scene
  59683. * @returns the lathe mesh
  59684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59685. */
  59686. static CreateLathe(name: string, options: {
  59687. shape: Vector3[];
  59688. radius?: number;
  59689. tessellation?: number;
  59690. clip?: number;
  59691. arc?: number;
  59692. closed?: boolean;
  59693. updatable?: boolean;
  59694. sideOrientation?: number;
  59695. frontUVs?: Vector4;
  59696. backUVs?: Vector4;
  59697. cap?: number;
  59698. invertUV?: boolean;
  59699. }, scene?: Nullable<Scene>): Mesh;
  59700. /**
  59701. * Creates a tiled plane mesh
  59702. * * You can set a limited pattern arrangement with the tiles
  59703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59704. * * 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
  59705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59706. * @param name defines the name of the mesh
  59707. * @param options defines the options used to create the mesh
  59708. * @param scene defines the hosting scene
  59709. * @returns the plane mesh
  59710. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59711. */
  59712. static CreateTiledPlane(name: string, options: {
  59713. pattern?: number;
  59714. tileSize?: number;
  59715. tileWidth?: number;
  59716. tileHeight?: number;
  59717. size?: number;
  59718. width?: number;
  59719. height?: number;
  59720. alignHorizontal?: number;
  59721. alignVertical?: number;
  59722. sideOrientation?: number;
  59723. frontUVs?: Vector4;
  59724. backUVs?: Vector4;
  59725. updatable?: boolean;
  59726. }, scene?: Nullable<Scene>): Mesh;
  59727. /**
  59728. * Creates a plane mesh
  59729. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59730. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59731. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59733. * * 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
  59734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59735. * @param name defines the name of the mesh
  59736. * @param options defines the options used to create the mesh
  59737. * @param scene defines the hosting scene
  59738. * @returns the plane mesh
  59739. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59740. */
  59741. static CreatePlane(name: string, options: {
  59742. size?: number;
  59743. width?: number;
  59744. height?: number;
  59745. sideOrientation?: number;
  59746. frontUVs?: Vector4;
  59747. backUVs?: Vector4;
  59748. updatable?: boolean;
  59749. sourcePlane?: Plane;
  59750. }, scene?: Nullable<Scene>): Mesh;
  59751. /**
  59752. * Creates a ground mesh
  59753. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59754. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59756. * @param name defines the name of the mesh
  59757. * @param options defines the options used to create the mesh
  59758. * @param scene defines the hosting scene
  59759. * @returns the ground mesh
  59760. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59761. */
  59762. static CreateGround(name: string, options: {
  59763. width?: number;
  59764. height?: number;
  59765. subdivisions?: number;
  59766. subdivisionsX?: number;
  59767. subdivisionsY?: number;
  59768. updatable?: boolean;
  59769. }, scene?: Nullable<Scene>): Mesh;
  59770. /**
  59771. * Creates a tiled ground mesh
  59772. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59773. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59774. * * 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
  59775. * * 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
  59776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59777. * @param name defines the name of the mesh
  59778. * @param options defines the options used to create the mesh
  59779. * @param scene defines the hosting scene
  59780. * @returns the tiled ground mesh
  59781. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59782. */
  59783. static CreateTiledGround(name: string, options: {
  59784. xmin: number;
  59785. zmin: number;
  59786. xmax: number;
  59787. zmax: number;
  59788. subdivisions?: {
  59789. w: number;
  59790. h: number;
  59791. };
  59792. precision?: {
  59793. w: number;
  59794. h: number;
  59795. };
  59796. updatable?: boolean;
  59797. }, scene?: Nullable<Scene>): Mesh;
  59798. /**
  59799. * Creates a ground mesh from a height map
  59800. * * The parameter `url` sets the URL of the height map image resource.
  59801. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59802. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59803. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59804. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59805. * * 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.
  59806. * * 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).
  59807. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59809. * @param name defines the name of the mesh
  59810. * @param url defines the url to the height map
  59811. * @param options defines the options used to create the mesh
  59812. * @param scene defines the hosting scene
  59813. * @returns the ground mesh
  59814. * @see https://doc.babylonjs.com/babylon101/height_map
  59815. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59816. */
  59817. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59818. width?: number;
  59819. height?: number;
  59820. subdivisions?: number;
  59821. minHeight?: number;
  59822. maxHeight?: number;
  59823. colorFilter?: Color3;
  59824. alphaFilter?: number;
  59825. updatable?: boolean;
  59826. onReady?: (mesh: GroundMesh) => void;
  59827. }, scene?: Nullable<Scene>): GroundMesh;
  59828. /**
  59829. * Creates a polygon mesh
  59830. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59831. * * 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
  59832. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59834. * * 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)
  59835. * * Remember you can only change the shape positions, not their number when updating a polygon
  59836. * @param name defines the name of the mesh
  59837. * @param options defines the options used to create the mesh
  59838. * @param scene defines the hosting scene
  59839. * @param earcutInjection can be used to inject your own earcut reference
  59840. * @returns the polygon mesh
  59841. */
  59842. static CreatePolygon(name: string, options: {
  59843. shape: Vector3[];
  59844. holes?: Vector3[][];
  59845. depth?: number;
  59846. faceUV?: Vector4[];
  59847. faceColors?: Color4[];
  59848. updatable?: boolean;
  59849. sideOrientation?: number;
  59850. frontUVs?: Vector4;
  59851. backUVs?: Vector4;
  59852. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59853. /**
  59854. * Creates an extruded polygon mesh, with depth in the Y direction.
  59855. * * 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)
  59856. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59857. * @param name defines the name of the mesh
  59858. * @param options defines the options used to create the mesh
  59859. * @param scene defines the hosting scene
  59860. * @param earcutInjection can be used to inject your own earcut reference
  59861. * @returns the polygon mesh
  59862. */
  59863. static ExtrudePolygon(name: string, options: {
  59864. shape: Vector3[];
  59865. holes?: Vector3[][];
  59866. depth?: number;
  59867. faceUV?: Vector4[];
  59868. faceColors?: Color4[];
  59869. updatable?: boolean;
  59870. sideOrientation?: number;
  59871. frontUVs?: Vector4;
  59872. backUVs?: Vector4;
  59873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59874. /**
  59875. * Creates a tube mesh.
  59876. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59877. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59878. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59879. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59880. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59881. * * 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)
  59882. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59883. * * 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
  59884. * * 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
  59885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59886. * * 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
  59887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59889. * @param name defines the name of the mesh
  59890. * @param options defines the options used to create the mesh
  59891. * @param scene defines the hosting scene
  59892. * @returns the tube mesh
  59893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59894. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59895. */
  59896. static CreateTube(name: string, options: {
  59897. path: Vector3[];
  59898. radius?: number;
  59899. tessellation?: number;
  59900. radiusFunction?: {
  59901. (i: number, distance: number): number;
  59902. };
  59903. cap?: number;
  59904. arc?: number;
  59905. updatable?: boolean;
  59906. sideOrientation?: number;
  59907. frontUVs?: Vector4;
  59908. backUVs?: Vector4;
  59909. instance?: Mesh;
  59910. invertUV?: boolean;
  59911. }, scene?: Nullable<Scene>): Mesh;
  59912. /**
  59913. * Creates a polyhedron mesh
  59914. * * 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
  59915. * * The parameter `size` (positive float, default 1) sets the polygon size
  59916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59917. * * 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`
  59918. * * 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
  59919. * * 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)`)
  59920. * * 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
  59921. * * 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
  59922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59923. * * 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
  59924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59925. * @param name defines the name of the mesh
  59926. * @param options defines the options used to create the mesh
  59927. * @param scene defines the hosting scene
  59928. * @returns the polyhedron mesh
  59929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59930. */
  59931. static CreatePolyhedron(name: string, options: {
  59932. type?: number;
  59933. size?: number;
  59934. sizeX?: number;
  59935. sizeY?: number;
  59936. sizeZ?: number;
  59937. custom?: any;
  59938. faceUV?: Vector4[];
  59939. faceColors?: Color4[];
  59940. flat?: boolean;
  59941. updatable?: boolean;
  59942. sideOrientation?: number;
  59943. frontUVs?: Vector4;
  59944. backUVs?: Vector4;
  59945. }, scene?: Nullable<Scene>): Mesh;
  59946. /**
  59947. * Creates a decal mesh.
  59948. * 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
  59949. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59950. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59951. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59952. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59953. * @param name defines the name of the mesh
  59954. * @param sourceMesh defines the mesh where the decal must be applied
  59955. * @param options defines the options used to create the mesh
  59956. * @param scene defines the hosting scene
  59957. * @returns the decal mesh
  59958. * @see https://doc.babylonjs.com/how_to/decals
  59959. */
  59960. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59961. position?: Vector3;
  59962. normal?: Vector3;
  59963. size?: Vector3;
  59964. angle?: number;
  59965. }): Mesh;
  59966. }
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * A simplifier interface for future simplification implementations
  59971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59972. */
  59973. export interface ISimplifier {
  59974. /**
  59975. * Simplification of a given mesh according to the given settings.
  59976. * Since this requires computation, it is assumed that the function runs async.
  59977. * @param settings The settings of the simplification, including quality and distance
  59978. * @param successCallback A callback that will be called after the mesh was simplified.
  59979. * @param errorCallback in case of an error, this callback will be called. optional.
  59980. */
  59981. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59982. }
  59983. /**
  59984. * Expected simplification settings.
  59985. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59986. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59987. */
  59988. export interface ISimplificationSettings {
  59989. /**
  59990. * Gets or sets the expected quality
  59991. */
  59992. quality: number;
  59993. /**
  59994. * Gets or sets the distance when this optimized version should be used
  59995. */
  59996. distance: number;
  59997. /**
  59998. * Gets an already optimized mesh
  59999. */
  60000. optimizeMesh?: boolean;
  60001. }
  60002. /**
  60003. * Class used to specify simplification options
  60004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60005. */
  60006. export class SimplificationSettings implements ISimplificationSettings {
  60007. /** expected quality */
  60008. quality: number;
  60009. /** distance when this optimized version should be used */
  60010. distance: number;
  60011. /** already optimized mesh */
  60012. optimizeMesh?: boolean | undefined;
  60013. /**
  60014. * Creates a SimplificationSettings
  60015. * @param quality expected quality
  60016. * @param distance distance when this optimized version should be used
  60017. * @param optimizeMesh already optimized mesh
  60018. */
  60019. constructor(
  60020. /** expected quality */
  60021. quality: number,
  60022. /** distance when this optimized version should be used */
  60023. distance: number,
  60024. /** already optimized mesh */
  60025. optimizeMesh?: boolean | undefined);
  60026. }
  60027. /**
  60028. * Interface used to define a simplification task
  60029. */
  60030. export interface ISimplificationTask {
  60031. /**
  60032. * Array of settings
  60033. */
  60034. settings: Array<ISimplificationSettings>;
  60035. /**
  60036. * Simplification type
  60037. */
  60038. simplificationType: SimplificationType;
  60039. /**
  60040. * Mesh to simplify
  60041. */
  60042. mesh: Mesh;
  60043. /**
  60044. * Callback called on success
  60045. */
  60046. successCallback?: () => void;
  60047. /**
  60048. * Defines if parallel processing can be used
  60049. */
  60050. parallelProcessing: boolean;
  60051. }
  60052. /**
  60053. * Queue used to order the simplification tasks
  60054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60055. */
  60056. export class SimplificationQueue {
  60057. private _simplificationArray;
  60058. /**
  60059. * Gets a boolean indicating that the process is still running
  60060. */
  60061. running: boolean;
  60062. /**
  60063. * Creates a new queue
  60064. */
  60065. constructor();
  60066. /**
  60067. * Adds a new simplification task
  60068. * @param task defines a task to add
  60069. */
  60070. addTask(task: ISimplificationTask): void;
  60071. /**
  60072. * Execute next task
  60073. */
  60074. executeNext(): void;
  60075. /**
  60076. * Execute a simplification task
  60077. * @param task defines the task to run
  60078. */
  60079. runSimplification(task: ISimplificationTask): void;
  60080. private getSimplifier;
  60081. }
  60082. /**
  60083. * The implemented types of simplification
  60084. * At the moment only Quadratic Error Decimation is implemented
  60085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60086. */
  60087. export enum SimplificationType {
  60088. /** Quadratic error decimation */
  60089. QUADRATIC = 0
  60090. }
  60091. }
  60092. declare module BABYLON {
  60093. interface Scene {
  60094. /** @hidden (Backing field) */
  60095. _simplificationQueue: SimplificationQueue;
  60096. /**
  60097. * Gets or sets the simplification queue attached to the scene
  60098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60099. */
  60100. simplificationQueue: SimplificationQueue;
  60101. }
  60102. interface Mesh {
  60103. /**
  60104. * Simplify the mesh according to the given array of settings.
  60105. * Function will return immediately and will simplify async
  60106. * @param settings a collection of simplification settings
  60107. * @param parallelProcessing should all levels calculate parallel or one after the other
  60108. * @param simplificationType the type of simplification to run
  60109. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60110. * @returns the current mesh
  60111. */
  60112. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60113. }
  60114. /**
  60115. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60116. * created in a scene
  60117. */
  60118. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60119. /**
  60120. * The component name helpfull to identify the component in the list of scene components.
  60121. */
  60122. readonly name: string;
  60123. /**
  60124. * The scene the component belongs to.
  60125. */
  60126. scene: Scene;
  60127. /**
  60128. * Creates a new instance of the component for the given scene
  60129. * @param scene Defines the scene to register the component in
  60130. */
  60131. constructor(scene: Scene);
  60132. /**
  60133. * Registers the component in a given scene
  60134. */
  60135. register(): void;
  60136. /**
  60137. * Rebuilds the elements related to this component in case of
  60138. * context lost for instance.
  60139. */
  60140. rebuild(): void;
  60141. /**
  60142. * Disposes the component and the associated ressources
  60143. */
  60144. dispose(): void;
  60145. private _beforeCameraUpdate;
  60146. }
  60147. }
  60148. declare module BABYLON {
  60149. /**
  60150. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60151. */
  60152. export interface INavigationEnginePlugin {
  60153. /**
  60154. * plugin name
  60155. */
  60156. name: string;
  60157. /**
  60158. * Creates a navigation mesh
  60159. * @param meshes array of all the geometry used to compute the navigatio mesh
  60160. * @param parameters bunch of parameters used to filter geometry
  60161. */
  60162. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60163. /**
  60164. * Create a navigation mesh debug mesh
  60165. * @param scene is where the mesh will be added
  60166. * @returns debug display mesh
  60167. */
  60168. createDebugNavMesh(scene: Scene): Mesh;
  60169. /**
  60170. * Get a navigation mesh constrained position, closest to the parameter position
  60171. * @param position world position
  60172. * @returns the closest point to position constrained by the navigation mesh
  60173. */
  60174. getClosestPoint(position: Vector3): Vector3;
  60175. /**
  60176. * Get a navigation mesh constrained position, within a particular radius
  60177. * @param position world position
  60178. * @param maxRadius the maximum distance to the constrained world position
  60179. * @returns the closest point to position constrained by the navigation mesh
  60180. */
  60181. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60182. /**
  60183. * Compute the final position from a segment made of destination-position
  60184. * @param position world position
  60185. * @param destination world position
  60186. * @returns the resulting point along the navmesh
  60187. */
  60188. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60189. /**
  60190. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60191. * @param start world position
  60192. * @param end world position
  60193. * @returns array containing world position composing the path
  60194. */
  60195. computePath(start: Vector3, end: Vector3): Vector3[];
  60196. /**
  60197. * If this plugin is supported
  60198. * @returns true if plugin is supported
  60199. */
  60200. isSupported(): boolean;
  60201. /**
  60202. * Create a new Crowd so you can add agents
  60203. * @param maxAgents the maximum agent count in the crowd
  60204. * @param maxAgentRadius the maximum radius an agent can have
  60205. * @param scene to attach the crowd to
  60206. * @returns the crowd you can add agents to
  60207. */
  60208. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60209. /**
  60210. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60211. * The queries will try to find a solution within those bounds
  60212. * default is (1,1,1)
  60213. * @param extent x,y,z value that define the extent around the queries point of reference
  60214. */
  60215. setDefaultQueryExtent(extent: Vector3): void;
  60216. /**
  60217. * Get the Bounding box extent specified by setDefaultQueryExtent
  60218. * @returns the box extent values
  60219. */
  60220. getDefaultQueryExtent(): Vector3;
  60221. /**
  60222. * Release all resources
  60223. */
  60224. dispose(): void;
  60225. }
  60226. /**
  60227. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60228. */
  60229. export interface ICrowd {
  60230. /**
  60231. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60232. * You can attach anything to that node. The node position is updated in the scene update tick.
  60233. * @param pos world position that will be constrained by the navigation mesh
  60234. * @param parameters agent parameters
  60235. * @param transform hooked to the agent that will be update by the scene
  60236. * @returns agent index
  60237. */
  60238. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60239. /**
  60240. * Returns the agent position in world space
  60241. * @param index agent index returned by addAgent
  60242. * @returns world space position
  60243. */
  60244. getAgentPosition(index: number): Vector3;
  60245. /**
  60246. * Gets the agent velocity in world space
  60247. * @param index agent index returned by addAgent
  60248. * @returns world space velocity
  60249. */
  60250. getAgentVelocity(index: number): Vector3;
  60251. /**
  60252. * remove a particular agent previously created
  60253. * @param index agent index returned by addAgent
  60254. */
  60255. removeAgent(index: number): void;
  60256. /**
  60257. * get the list of all agents attached to this crowd
  60258. * @returns list of agent indices
  60259. */
  60260. getAgents(): number[];
  60261. /**
  60262. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60263. * @param deltaTime in seconds
  60264. */
  60265. update(deltaTime: number): void;
  60266. /**
  60267. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60268. * @param index agent index returned by addAgent
  60269. * @param destination targeted world position
  60270. */
  60271. agentGoto(index: number, destination: Vector3): void;
  60272. /**
  60273. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60274. * The queries will try to find a solution within those bounds
  60275. * default is (1,1,1)
  60276. * @param extent x,y,z value that define the extent around the queries point of reference
  60277. */
  60278. setDefaultQueryExtent(extent: Vector3): void;
  60279. /**
  60280. * Get the Bounding box extent specified by setDefaultQueryExtent
  60281. * @returns the box extent values
  60282. */
  60283. getDefaultQueryExtent(): Vector3;
  60284. /**
  60285. * Release all resources
  60286. */
  60287. dispose(): void;
  60288. }
  60289. /**
  60290. * Configures an agent
  60291. */
  60292. export interface IAgentParameters {
  60293. /**
  60294. * Agent radius. [Limit: >= 0]
  60295. */
  60296. radius: number;
  60297. /**
  60298. * Agent height. [Limit: > 0]
  60299. */
  60300. height: number;
  60301. /**
  60302. * Maximum allowed acceleration. [Limit: >= 0]
  60303. */
  60304. maxAcceleration: number;
  60305. /**
  60306. * Maximum allowed speed. [Limit: >= 0]
  60307. */
  60308. maxSpeed: number;
  60309. /**
  60310. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60311. */
  60312. collisionQueryRange: number;
  60313. /**
  60314. * The path visibility optimization range. [Limit: > 0]
  60315. */
  60316. pathOptimizationRange: number;
  60317. /**
  60318. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60319. */
  60320. separationWeight: number;
  60321. }
  60322. /**
  60323. * Configures the navigation mesh creation
  60324. */
  60325. export interface INavMeshParameters {
  60326. /**
  60327. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60328. */
  60329. cs: number;
  60330. /**
  60331. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60332. */
  60333. ch: number;
  60334. /**
  60335. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60336. */
  60337. walkableSlopeAngle: number;
  60338. /**
  60339. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60340. * be considered walkable. [Limit: >= 3] [Units: vx]
  60341. */
  60342. walkableHeight: number;
  60343. /**
  60344. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60345. */
  60346. walkableClimb: number;
  60347. /**
  60348. * The distance to erode/shrink the walkable area of the heightfield away from
  60349. * obstructions. [Limit: >=0] [Units: vx]
  60350. */
  60351. walkableRadius: number;
  60352. /**
  60353. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60354. */
  60355. maxEdgeLen: number;
  60356. /**
  60357. * The maximum distance a simplfied contour's border edges should deviate
  60358. * the original raw contour. [Limit: >=0] [Units: vx]
  60359. */
  60360. maxSimplificationError: number;
  60361. /**
  60362. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60363. */
  60364. minRegionArea: number;
  60365. /**
  60366. * Any regions with a span count smaller than this value will, if possible,
  60367. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60368. */
  60369. mergeRegionArea: number;
  60370. /**
  60371. * The maximum number of vertices allowed for polygons generated during the
  60372. * contour to polygon conversion process. [Limit: >= 3]
  60373. */
  60374. maxVertsPerPoly: number;
  60375. /**
  60376. * Sets the sampling distance to use when generating the detail mesh.
  60377. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60378. */
  60379. detailSampleDist: number;
  60380. /**
  60381. * The maximum distance the detail mesh surface should deviate from heightfield
  60382. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60383. */
  60384. detailSampleMaxError: number;
  60385. }
  60386. }
  60387. declare module BABYLON {
  60388. /**
  60389. * RecastJS navigation plugin
  60390. */
  60391. export class RecastJSPlugin implements INavigationEnginePlugin {
  60392. /**
  60393. * Reference to the Recast library
  60394. */
  60395. bjsRECAST: any;
  60396. /**
  60397. * plugin name
  60398. */
  60399. name: string;
  60400. /**
  60401. * the first navmesh created. We might extend this to support multiple navmeshes
  60402. */
  60403. navMesh: any;
  60404. /**
  60405. * Initializes the recastJS plugin
  60406. * @param recastInjection can be used to inject your own recast reference
  60407. */
  60408. constructor(recastInjection?: any);
  60409. /**
  60410. * Creates a navigation mesh
  60411. * @param meshes array of all the geometry used to compute the navigatio mesh
  60412. * @param parameters bunch of parameters used to filter geometry
  60413. */
  60414. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60415. /**
  60416. * Create a navigation mesh debug mesh
  60417. * @param scene is where the mesh will be added
  60418. * @returns debug display mesh
  60419. */
  60420. createDebugNavMesh(scene: Scene): Mesh;
  60421. /**
  60422. * Get a navigation mesh constrained position, closest to the parameter position
  60423. * @param position world position
  60424. * @returns the closest point to position constrained by the navigation mesh
  60425. */
  60426. getClosestPoint(position: Vector3): Vector3;
  60427. /**
  60428. * Get a navigation mesh constrained position, within a particular radius
  60429. * @param position world position
  60430. * @param maxRadius the maximum distance to the constrained world position
  60431. * @returns the closest point to position constrained by the navigation mesh
  60432. */
  60433. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60434. /**
  60435. * Compute the final position from a segment made of destination-position
  60436. * @param position world position
  60437. * @param destination world position
  60438. * @returns the resulting point along the navmesh
  60439. */
  60440. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60441. /**
  60442. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60443. * @param start world position
  60444. * @param end world position
  60445. * @returns array containing world position composing the path
  60446. */
  60447. computePath(start: Vector3, end: Vector3): Vector3[];
  60448. /**
  60449. * Create a new Crowd so you can add agents
  60450. * @param maxAgents the maximum agent count in the crowd
  60451. * @param maxAgentRadius the maximum radius an agent can have
  60452. * @param scene to attach the crowd to
  60453. * @returns the crowd you can add agents to
  60454. */
  60455. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60456. /**
  60457. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60458. * The queries will try to find a solution within those bounds
  60459. * default is (1,1,1)
  60460. * @param extent x,y,z value that define the extent around the queries point of reference
  60461. */
  60462. setDefaultQueryExtent(extent: Vector3): void;
  60463. /**
  60464. * Get the Bounding box extent specified by setDefaultQueryExtent
  60465. * @returns the box extent values
  60466. */
  60467. getDefaultQueryExtent(): Vector3;
  60468. /**
  60469. * Disposes
  60470. */
  60471. dispose(): void;
  60472. /**
  60473. * If this plugin is supported
  60474. * @returns true if plugin is supported
  60475. */
  60476. isSupported(): boolean;
  60477. }
  60478. /**
  60479. * Recast detour crowd implementation
  60480. */
  60481. export class RecastJSCrowd implements ICrowd {
  60482. /**
  60483. * Recast/detour plugin
  60484. */
  60485. bjsRECASTPlugin: RecastJSPlugin;
  60486. /**
  60487. * Link to the detour crowd
  60488. */
  60489. recastCrowd: any;
  60490. /**
  60491. * One transform per agent
  60492. */
  60493. transforms: TransformNode[];
  60494. /**
  60495. * All agents created
  60496. */
  60497. agents: number[];
  60498. /**
  60499. * Link to the scene is kept to unregister the crowd from the scene
  60500. */
  60501. private _scene;
  60502. /**
  60503. * Observer for crowd updates
  60504. */
  60505. private _onBeforeAnimationsObserver;
  60506. /**
  60507. * Constructor
  60508. * @param plugin recastJS plugin
  60509. * @param maxAgents the maximum agent count in the crowd
  60510. * @param maxAgentRadius the maximum radius an agent can have
  60511. * @param scene to attach the crowd to
  60512. * @returns the crowd you can add agents to
  60513. */
  60514. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60515. /**
  60516. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60517. * You can attach anything to that node. The node position is updated in the scene update tick.
  60518. * @param pos world position that will be constrained by the navigation mesh
  60519. * @param parameters agent parameters
  60520. * @param transform hooked to the agent that will be update by the scene
  60521. * @returns agent index
  60522. */
  60523. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60524. /**
  60525. * Returns the agent position in world space
  60526. * @param index agent index returned by addAgent
  60527. * @returns world space position
  60528. */
  60529. getAgentPosition(index: number): Vector3;
  60530. /**
  60531. * Returns the agent velocity in world space
  60532. * @param index agent index returned by addAgent
  60533. * @returns world space velocity
  60534. */
  60535. getAgentVelocity(index: number): Vector3;
  60536. /**
  60537. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60538. * @param index agent index returned by addAgent
  60539. * @param destination targeted world position
  60540. */
  60541. agentGoto(index: number, destination: Vector3): void;
  60542. /**
  60543. * remove a particular agent previously created
  60544. * @param index agent index returned by addAgent
  60545. */
  60546. removeAgent(index: number): void;
  60547. /**
  60548. * get the list of all agents attached to this crowd
  60549. * @returns list of agent indices
  60550. */
  60551. getAgents(): number[];
  60552. /**
  60553. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60554. * @param deltaTime in seconds
  60555. */
  60556. update(deltaTime: number): void;
  60557. /**
  60558. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60559. * The queries will try to find a solution within those bounds
  60560. * default is (1,1,1)
  60561. * @param extent x,y,z value that define the extent around the queries point of reference
  60562. */
  60563. setDefaultQueryExtent(extent: Vector3): void;
  60564. /**
  60565. * Get the Bounding box extent specified by setDefaultQueryExtent
  60566. * @returns the box extent values
  60567. */
  60568. getDefaultQueryExtent(): Vector3;
  60569. /**
  60570. * Release all resources
  60571. */
  60572. dispose(): void;
  60573. }
  60574. }
  60575. declare module BABYLON {
  60576. /**
  60577. * Class used to enable access to IndexedDB
  60578. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60579. */
  60580. export class Database implements IOfflineProvider {
  60581. private _callbackManifestChecked;
  60582. private _currentSceneUrl;
  60583. private _db;
  60584. private _enableSceneOffline;
  60585. private _enableTexturesOffline;
  60586. private _manifestVersionFound;
  60587. private _mustUpdateRessources;
  60588. private _hasReachedQuota;
  60589. private _isSupported;
  60590. private _idbFactory;
  60591. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60592. private static IsUASupportingBlobStorage;
  60593. /**
  60594. * Gets a boolean indicating if Database storate is enabled (off by default)
  60595. */
  60596. static IDBStorageEnabled: boolean;
  60597. /**
  60598. * Gets a boolean indicating if scene must be saved in the database
  60599. */
  60600. get enableSceneOffline(): boolean;
  60601. /**
  60602. * Gets a boolean indicating if textures must be saved in the database
  60603. */
  60604. get enableTexturesOffline(): boolean;
  60605. /**
  60606. * Creates a new Database
  60607. * @param urlToScene defines the url to load the scene
  60608. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60609. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60610. */
  60611. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60612. private static _ParseURL;
  60613. private static _ReturnFullUrlLocation;
  60614. private _checkManifestFile;
  60615. /**
  60616. * Open the database and make it available
  60617. * @param successCallback defines the callback to call on success
  60618. * @param errorCallback defines the callback to call on error
  60619. */
  60620. open(successCallback: () => void, errorCallback: () => void): void;
  60621. /**
  60622. * Loads an image from the database
  60623. * @param url defines the url to load from
  60624. * @param image defines the target DOM image
  60625. */
  60626. loadImage(url: string, image: HTMLImageElement): void;
  60627. private _loadImageFromDBAsync;
  60628. private _saveImageIntoDBAsync;
  60629. private _checkVersionFromDB;
  60630. private _loadVersionFromDBAsync;
  60631. private _saveVersionIntoDBAsync;
  60632. /**
  60633. * Loads a file from database
  60634. * @param url defines the URL to load from
  60635. * @param sceneLoaded defines a callback to call on success
  60636. * @param progressCallBack defines a callback to call when progress changed
  60637. * @param errorCallback defines a callback to call on error
  60638. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60639. */
  60640. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60641. private _loadFileAsync;
  60642. private _saveFileAsync;
  60643. /**
  60644. * Validates if xhr data is correct
  60645. * @param xhr defines the request to validate
  60646. * @param dataType defines the expected data type
  60647. * @returns true if data is correct
  60648. */
  60649. private static _ValidateXHRData;
  60650. }
  60651. }
  60652. declare module BABYLON {
  60653. /** @hidden */
  60654. export var gpuUpdateParticlesPixelShader: {
  60655. name: string;
  60656. shader: string;
  60657. };
  60658. }
  60659. declare module BABYLON {
  60660. /** @hidden */
  60661. export var gpuUpdateParticlesVertexShader: {
  60662. name: string;
  60663. shader: string;
  60664. };
  60665. }
  60666. declare module BABYLON {
  60667. /** @hidden */
  60668. export var clipPlaneFragmentDeclaration2: {
  60669. name: string;
  60670. shader: string;
  60671. };
  60672. }
  60673. declare module BABYLON {
  60674. /** @hidden */
  60675. export var gpuRenderParticlesPixelShader: {
  60676. name: string;
  60677. shader: string;
  60678. };
  60679. }
  60680. declare module BABYLON {
  60681. /** @hidden */
  60682. export var clipPlaneVertexDeclaration2: {
  60683. name: string;
  60684. shader: string;
  60685. };
  60686. }
  60687. declare module BABYLON {
  60688. /** @hidden */
  60689. export var gpuRenderParticlesVertexShader: {
  60690. name: string;
  60691. shader: string;
  60692. };
  60693. }
  60694. declare module BABYLON {
  60695. /**
  60696. * This represents a GPU particle system in Babylon
  60697. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60698. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60699. */
  60700. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60701. /**
  60702. * The layer mask we are rendering the particles through.
  60703. */
  60704. layerMask: number;
  60705. private _capacity;
  60706. private _activeCount;
  60707. private _currentActiveCount;
  60708. private _accumulatedCount;
  60709. private _renderEffect;
  60710. private _updateEffect;
  60711. private _buffer0;
  60712. private _buffer1;
  60713. private _spriteBuffer;
  60714. private _updateVAO;
  60715. private _renderVAO;
  60716. private _targetIndex;
  60717. private _sourceBuffer;
  60718. private _targetBuffer;
  60719. private _engine;
  60720. private _currentRenderId;
  60721. private _started;
  60722. private _stopped;
  60723. private _timeDelta;
  60724. private _randomTexture;
  60725. private _randomTexture2;
  60726. private _attributesStrideSize;
  60727. private _updateEffectOptions;
  60728. private _randomTextureSize;
  60729. private _actualFrame;
  60730. private readonly _rawTextureWidth;
  60731. /**
  60732. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60733. */
  60734. static get IsSupported(): boolean;
  60735. /**
  60736. * An event triggered when the system is disposed.
  60737. */
  60738. onDisposeObservable: Observable<GPUParticleSystem>;
  60739. /**
  60740. * Gets the maximum number of particles active at the same time.
  60741. * @returns The max number of active particles.
  60742. */
  60743. getCapacity(): number;
  60744. /**
  60745. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60746. * to override the particles.
  60747. */
  60748. forceDepthWrite: boolean;
  60749. /**
  60750. * Gets or set the number of active particles
  60751. */
  60752. get activeParticleCount(): number;
  60753. set activeParticleCount(value: number);
  60754. private _preWarmDone;
  60755. /**
  60756. * Is this system ready to be used/rendered
  60757. * @return true if the system is ready
  60758. */
  60759. isReady(): boolean;
  60760. /**
  60761. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60762. * @returns True if it has been started, otherwise false.
  60763. */
  60764. isStarted(): boolean;
  60765. /**
  60766. * Starts the particle system and begins to emit
  60767. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60768. */
  60769. start(delay?: number): void;
  60770. /**
  60771. * Stops the particle system.
  60772. */
  60773. stop(): void;
  60774. /**
  60775. * Remove all active particles
  60776. */
  60777. reset(): void;
  60778. /**
  60779. * Returns the string "GPUParticleSystem"
  60780. * @returns a string containing the class name
  60781. */
  60782. getClassName(): string;
  60783. private _colorGradientsTexture;
  60784. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60785. /**
  60786. * Adds a new color gradient
  60787. * @param gradient defines the gradient to use (between 0 and 1)
  60788. * @param color1 defines the color to affect to the specified gradient
  60789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60790. * @returns the current particle system
  60791. */
  60792. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60793. /**
  60794. * Remove a specific color gradient
  60795. * @param gradient defines the gradient to remove
  60796. * @returns the current particle system
  60797. */
  60798. removeColorGradient(gradient: number): GPUParticleSystem;
  60799. private _angularSpeedGradientsTexture;
  60800. private _sizeGradientsTexture;
  60801. private _velocityGradientsTexture;
  60802. private _limitVelocityGradientsTexture;
  60803. private _dragGradientsTexture;
  60804. private _addFactorGradient;
  60805. /**
  60806. * Adds a new size gradient
  60807. * @param gradient defines the gradient to use (between 0 and 1)
  60808. * @param factor defines the size factor to affect to the specified gradient
  60809. * @returns the current particle system
  60810. */
  60811. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60812. /**
  60813. * Remove a specific size gradient
  60814. * @param gradient defines the gradient to remove
  60815. * @returns the current particle system
  60816. */
  60817. removeSizeGradient(gradient: number): GPUParticleSystem;
  60818. /**
  60819. * Adds a new angular speed gradient
  60820. * @param gradient defines the gradient to use (between 0 and 1)
  60821. * @param factor defines the angular speed to affect to the specified gradient
  60822. * @returns the current particle system
  60823. */
  60824. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60825. /**
  60826. * Remove a specific angular speed gradient
  60827. * @param gradient defines the gradient to remove
  60828. * @returns the current particle system
  60829. */
  60830. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60831. /**
  60832. * Adds a new velocity gradient
  60833. * @param gradient defines the gradient to use (between 0 and 1)
  60834. * @param factor defines the velocity to affect to the specified gradient
  60835. * @returns the current particle system
  60836. */
  60837. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60838. /**
  60839. * Remove a specific velocity gradient
  60840. * @param gradient defines the gradient to remove
  60841. * @returns the current particle system
  60842. */
  60843. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60844. /**
  60845. * Adds a new limit velocity gradient
  60846. * @param gradient defines the gradient to use (between 0 and 1)
  60847. * @param factor defines the limit velocity value to affect to the specified gradient
  60848. * @returns the current particle system
  60849. */
  60850. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60851. /**
  60852. * Remove a specific limit velocity gradient
  60853. * @param gradient defines the gradient to remove
  60854. * @returns the current particle system
  60855. */
  60856. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60857. /**
  60858. * Adds a new drag gradient
  60859. * @param gradient defines the gradient to use (between 0 and 1)
  60860. * @param factor defines the drag value to affect to the specified gradient
  60861. * @returns the current particle system
  60862. */
  60863. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60864. /**
  60865. * Remove a specific drag gradient
  60866. * @param gradient defines the gradient to remove
  60867. * @returns the current particle system
  60868. */
  60869. removeDragGradient(gradient: number): GPUParticleSystem;
  60870. /**
  60871. * Not supported by GPUParticleSystem
  60872. * @param gradient defines the gradient to use (between 0 and 1)
  60873. * @param factor defines the emit rate value to affect to the specified gradient
  60874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60875. * @returns the current particle system
  60876. */
  60877. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60878. /**
  60879. * Not supported by GPUParticleSystem
  60880. * @param gradient defines the gradient to remove
  60881. * @returns the current particle system
  60882. */
  60883. removeEmitRateGradient(gradient: number): IParticleSystem;
  60884. /**
  60885. * Not supported by GPUParticleSystem
  60886. * @param gradient defines the gradient to use (between 0 and 1)
  60887. * @param factor defines the start size value to affect to the specified gradient
  60888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60889. * @returns the current particle system
  60890. */
  60891. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60892. /**
  60893. * Not supported by GPUParticleSystem
  60894. * @param gradient defines the gradient to remove
  60895. * @returns the current particle system
  60896. */
  60897. removeStartSizeGradient(gradient: number): IParticleSystem;
  60898. /**
  60899. * Not supported by GPUParticleSystem
  60900. * @param gradient defines the gradient to use (between 0 and 1)
  60901. * @param min defines the color remap minimal range
  60902. * @param max defines the color remap maximal range
  60903. * @returns the current particle system
  60904. */
  60905. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60906. /**
  60907. * Not supported by GPUParticleSystem
  60908. * @param gradient defines the gradient to remove
  60909. * @returns the current particle system
  60910. */
  60911. removeColorRemapGradient(): IParticleSystem;
  60912. /**
  60913. * Not supported by GPUParticleSystem
  60914. * @param gradient defines the gradient to use (between 0 and 1)
  60915. * @param min defines the alpha remap minimal range
  60916. * @param max defines the alpha remap maximal range
  60917. * @returns the current particle system
  60918. */
  60919. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60920. /**
  60921. * Not supported by GPUParticleSystem
  60922. * @param gradient defines the gradient to remove
  60923. * @returns the current particle system
  60924. */
  60925. removeAlphaRemapGradient(): IParticleSystem;
  60926. /**
  60927. * Not supported by GPUParticleSystem
  60928. * @param gradient defines the gradient to use (between 0 and 1)
  60929. * @param color defines the color to affect to the specified gradient
  60930. * @returns the current particle system
  60931. */
  60932. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60933. /**
  60934. * Not supported by GPUParticleSystem
  60935. * @param gradient defines the gradient to remove
  60936. * @returns the current particle system
  60937. */
  60938. removeRampGradient(): IParticleSystem;
  60939. /**
  60940. * Not supported by GPUParticleSystem
  60941. * @returns the list of ramp gradients
  60942. */
  60943. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60944. /**
  60945. * Not supported by GPUParticleSystem
  60946. * Gets or sets a boolean indicating that ramp gradients must be used
  60947. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60948. */
  60949. get useRampGradients(): boolean;
  60950. set useRampGradients(value: boolean);
  60951. /**
  60952. * Not supported by GPUParticleSystem
  60953. * @param gradient defines the gradient to use (between 0 and 1)
  60954. * @param factor defines the life time factor to affect to the specified gradient
  60955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60956. * @returns the current particle system
  60957. */
  60958. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60959. /**
  60960. * Not supported by GPUParticleSystem
  60961. * @param gradient defines the gradient to remove
  60962. * @returns the current particle system
  60963. */
  60964. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60965. /**
  60966. * Instantiates a GPU particle system.
  60967. * 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.
  60968. * @param name The name of the particle system
  60969. * @param options The options used to create the system
  60970. * @param scene The scene the particle system belongs to
  60971. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60972. */
  60973. constructor(name: string, options: Partial<{
  60974. capacity: number;
  60975. randomTextureSize: number;
  60976. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60977. protected _reset(): void;
  60978. private _createUpdateVAO;
  60979. private _createRenderVAO;
  60980. private _initialize;
  60981. /** @hidden */
  60982. _recreateUpdateEffect(): void;
  60983. /** @hidden */
  60984. _recreateRenderEffect(): void;
  60985. /**
  60986. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60987. * @param preWarm defines if we are in the pre-warmimg phase
  60988. */
  60989. animate(preWarm?: boolean): void;
  60990. private _createFactorGradientTexture;
  60991. private _createSizeGradientTexture;
  60992. private _createAngularSpeedGradientTexture;
  60993. private _createVelocityGradientTexture;
  60994. private _createLimitVelocityGradientTexture;
  60995. private _createDragGradientTexture;
  60996. private _createColorGradientTexture;
  60997. /**
  60998. * Renders the particle system in its current state
  60999. * @param preWarm defines if the system should only update the particles but not render them
  61000. * @returns the current number of particles
  61001. */
  61002. render(preWarm?: boolean): number;
  61003. /**
  61004. * Rebuilds the particle system
  61005. */
  61006. rebuild(): void;
  61007. private _releaseBuffers;
  61008. private _releaseVAOs;
  61009. /**
  61010. * Disposes the particle system and free the associated resources
  61011. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61012. */
  61013. dispose(disposeTexture?: boolean): void;
  61014. /**
  61015. * Clones the particle system.
  61016. * @param name The name of the cloned object
  61017. * @param newEmitter The new emitter to use
  61018. * @returns the cloned particle system
  61019. */
  61020. clone(name: string, newEmitter: any): GPUParticleSystem;
  61021. /**
  61022. * Serializes the particle system to a JSON object.
  61023. * @returns the JSON object
  61024. */
  61025. serialize(): any;
  61026. /**
  61027. * Parses a JSON object to create a GPU particle system.
  61028. * @param parsedParticleSystem The JSON object to parse
  61029. * @param scene The scene to create the particle system in
  61030. * @param rootUrl The root url to use to load external dependencies like texture
  61031. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61032. * @returns the parsed GPU particle system
  61033. */
  61034. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61035. }
  61036. }
  61037. declare module BABYLON {
  61038. /**
  61039. * Represents a set of particle systems working together to create a specific effect
  61040. */
  61041. export class ParticleSystemSet implements IDisposable {
  61042. /**
  61043. * Gets or sets base Assets URL
  61044. */
  61045. static BaseAssetsUrl: string;
  61046. private _emitterCreationOptions;
  61047. private _emitterNode;
  61048. /**
  61049. * Gets the particle system list
  61050. */
  61051. systems: IParticleSystem[];
  61052. /**
  61053. * Gets the emitter node used with this set
  61054. */
  61055. get emitterNode(): Nullable<TransformNode>;
  61056. /**
  61057. * Creates a new emitter mesh as a sphere
  61058. * @param options defines the options used to create the sphere
  61059. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61060. * @param scene defines the hosting scene
  61061. */
  61062. setEmitterAsSphere(options: {
  61063. diameter: number;
  61064. segments: number;
  61065. color: Color3;
  61066. }, renderingGroupId: number, scene: Scene): void;
  61067. /**
  61068. * Starts all particle systems of the set
  61069. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61070. */
  61071. start(emitter?: AbstractMesh): void;
  61072. /**
  61073. * Release all associated resources
  61074. */
  61075. dispose(): void;
  61076. /**
  61077. * Serialize the set into a JSON compatible object
  61078. * @returns a JSON compatible representation of the set
  61079. */
  61080. serialize(): any;
  61081. /**
  61082. * Parse a new ParticleSystemSet from a serialized source
  61083. * @param data defines a JSON compatible representation of the set
  61084. * @param scene defines the hosting scene
  61085. * @param gpu defines if we want GPU particles or CPU particles
  61086. * @returns a new ParticleSystemSet
  61087. */
  61088. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61089. }
  61090. }
  61091. declare module BABYLON {
  61092. /**
  61093. * This class is made for on one-liner static method to help creating particle system set.
  61094. */
  61095. export class ParticleHelper {
  61096. /**
  61097. * Gets or sets base Assets URL
  61098. */
  61099. static BaseAssetsUrl: string;
  61100. /**
  61101. * Create a default particle system that you can tweak
  61102. * @param emitter defines the emitter to use
  61103. * @param capacity defines the system capacity (default is 500 particles)
  61104. * @param scene defines the hosting scene
  61105. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61106. * @returns the new Particle system
  61107. */
  61108. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61109. /**
  61110. * This is the main static method (one-liner) of this helper to create different particle systems
  61111. * @param type This string represents the type to the particle system to create
  61112. * @param scene The scene where the particle system should live
  61113. * @param gpu If the system will use gpu
  61114. * @returns the ParticleSystemSet created
  61115. */
  61116. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61117. /**
  61118. * Static function used to export a particle system to a ParticleSystemSet variable.
  61119. * Please note that the emitter shape is not exported
  61120. * @param systems defines the particle systems to export
  61121. * @returns the created particle system set
  61122. */
  61123. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61124. }
  61125. }
  61126. declare module BABYLON {
  61127. interface Engine {
  61128. /**
  61129. * Create an effect to use with particle systems.
  61130. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61131. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61132. * @param uniformsNames defines a list of attribute names
  61133. * @param samplers defines an array of string used to represent textures
  61134. * @param defines defines the string containing the defines to use to compile the shaders
  61135. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61136. * @param onCompiled defines a function to call when the effect creation is successful
  61137. * @param onError defines a function to call when the effect creation has failed
  61138. * @returns the new Effect
  61139. */
  61140. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61141. }
  61142. interface Mesh {
  61143. /**
  61144. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61145. * @returns an array of IParticleSystem
  61146. */
  61147. getEmittedParticleSystems(): IParticleSystem[];
  61148. /**
  61149. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61150. * @returns an array of IParticleSystem
  61151. */
  61152. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61153. }
  61154. /**
  61155. * @hidden
  61156. */
  61157. export var _IDoNeedToBeInTheBuild: number;
  61158. }
  61159. declare module BABYLON {
  61160. /** Defines the 4 color options */
  61161. export enum PointColor {
  61162. /** color value */
  61163. Color = 2,
  61164. /** uv value */
  61165. UV = 1,
  61166. /** random value */
  61167. Random = 0,
  61168. /** stated value */
  61169. Stated = 3
  61170. }
  61171. /**
  61172. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61173. * 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.
  61174. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61175. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61176. *
  61177. * Full documentation here : TO BE ENTERED
  61178. */
  61179. export class PointsCloudSystem implements IDisposable {
  61180. /**
  61181. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61182. * Example : var p = SPS.particles[i];
  61183. */
  61184. particles: CloudPoint[];
  61185. /**
  61186. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61187. */
  61188. nbParticles: number;
  61189. /**
  61190. * This a counter for your own usage. It's not set by any SPS functions.
  61191. */
  61192. counter: number;
  61193. /**
  61194. * The PCS name. This name is also given to the underlying mesh.
  61195. */
  61196. name: string;
  61197. /**
  61198. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61199. */
  61200. mesh: Mesh;
  61201. /**
  61202. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61203. * Please read :
  61204. */
  61205. vars: any;
  61206. /**
  61207. * @hidden
  61208. */
  61209. _size: number;
  61210. private _scene;
  61211. private _promises;
  61212. private _positions;
  61213. private _indices;
  61214. private _normals;
  61215. private _colors;
  61216. private _uvs;
  61217. private _indices32;
  61218. private _positions32;
  61219. private _colors32;
  61220. private _uvs32;
  61221. private _updatable;
  61222. private _isVisibilityBoxLocked;
  61223. private _alwaysVisible;
  61224. private _groups;
  61225. private _groupCounter;
  61226. private _computeParticleColor;
  61227. private _computeParticleTexture;
  61228. private _computeParticleRotation;
  61229. private _computeBoundingBox;
  61230. private _isReady;
  61231. /**
  61232. * Creates a PCS (Points Cloud System) object
  61233. * @param name (String) is the PCS name, this will be the underlying mesh name
  61234. * @param pointSize (number) is the size for each point
  61235. * @param scene (Scene) is the scene in which the PCS is added
  61236. * @param options defines the options of the PCS e.g.
  61237. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61238. */
  61239. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61240. updatable?: boolean;
  61241. });
  61242. /**
  61243. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61244. * If no points were added to the PCS, the returned mesh is just a single point.
  61245. * @returns a promise for the created mesh
  61246. */
  61247. buildMeshAsync(): Promise<Mesh>;
  61248. /**
  61249. * @hidden
  61250. */
  61251. private _buildMesh;
  61252. private _addParticle;
  61253. private _randomUnitVector;
  61254. private _getColorIndicesForCoord;
  61255. private _setPointsColorOrUV;
  61256. private _colorFromTexture;
  61257. private _calculateDensity;
  61258. /**
  61259. * Adds points to the PCS in random positions within a unit sphere
  61260. * @param nb (positive integer) the number of particles to be created from this model
  61261. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61262. * @returns the number of groups in the system
  61263. */
  61264. addPoints(nb: number, pointFunction?: any): number;
  61265. /**
  61266. * Adds points to the PCS from the surface of the model shape
  61267. * @param mesh is any Mesh object that will be used as a surface model for the points
  61268. * @param nb (positive integer) the number of particles to be created from this model
  61269. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61270. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61271. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61272. * @returns the number of groups in the system
  61273. */
  61274. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61275. /**
  61276. * Adds points to the PCS inside the model shape
  61277. * @param mesh is any Mesh object that will be used as a surface model for the points
  61278. * @param nb (positive integer) the number of particles to be created from this model
  61279. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61280. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61281. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61282. * @returns the number of groups in the system
  61283. */
  61284. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61285. /**
  61286. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61287. * This method calls `updateParticle()` for each particle of the SPS.
  61288. * For an animated SPS, it is usually called within the render loop.
  61289. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61290. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61291. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61292. * @returns the PCS.
  61293. */
  61294. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61295. /**
  61296. * Disposes the PCS.
  61297. */
  61298. dispose(): void;
  61299. /**
  61300. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61301. * doc :
  61302. * @returns the PCS.
  61303. */
  61304. refreshVisibleSize(): PointsCloudSystem;
  61305. /**
  61306. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61307. * @param size the size (float) of the visibility box
  61308. * note : this doesn't lock the PCS mesh bounding box.
  61309. * doc :
  61310. */
  61311. setVisibilityBox(size: number): void;
  61312. /**
  61313. * Gets whether the PCS is always visible or not
  61314. * doc :
  61315. */
  61316. get isAlwaysVisible(): boolean;
  61317. /**
  61318. * Sets the PCS as always visible or not
  61319. * doc :
  61320. */
  61321. set isAlwaysVisible(val: boolean);
  61322. /**
  61323. * Tells to `setParticles()` to compute the particle rotations or not
  61324. * Default value : false. The PCS is faster when it's set to false
  61325. * Note : particle rotations are only applied to parent particles
  61326. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61327. */
  61328. set computeParticleRotation(val: boolean);
  61329. /**
  61330. * Tells to `setParticles()` to compute the particle colors or not.
  61331. * Default value : true. The PCS is faster when it's set to false.
  61332. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61333. */
  61334. set computeParticleColor(val: boolean);
  61335. set computeParticleTexture(val: boolean);
  61336. /**
  61337. * Gets if `setParticles()` computes the particle colors or not.
  61338. * Default value : false. The PCS is faster when it's set to false.
  61339. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61340. */
  61341. get computeParticleColor(): boolean;
  61342. /**
  61343. * Gets if `setParticles()` computes the particle textures or not.
  61344. * Default value : false. The PCS is faster when it's set to false.
  61345. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61346. */
  61347. get computeParticleTexture(): boolean;
  61348. /**
  61349. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61350. */
  61351. set computeBoundingBox(val: boolean);
  61352. /**
  61353. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61354. */
  61355. get computeBoundingBox(): boolean;
  61356. /**
  61357. * This function does nothing. It may be overwritten to set all the particle first values.
  61358. * The PCS doesn't call this function, you may have to call it by your own.
  61359. * doc :
  61360. */
  61361. initParticles(): void;
  61362. /**
  61363. * This function does nothing. It may be overwritten to recycle a particle
  61364. * The PCS doesn't call this function, you can to call it
  61365. * doc :
  61366. * @param particle The particle to recycle
  61367. * @returns the recycled particle
  61368. */
  61369. recycleParticle(particle: CloudPoint): CloudPoint;
  61370. /**
  61371. * Updates a particle : this function should be overwritten by the user.
  61372. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61373. * doc :
  61374. * @example : just set a particle position or velocity and recycle conditions
  61375. * @param particle The particle to update
  61376. * @returns the updated particle
  61377. */
  61378. updateParticle(particle: CloudPoint): CloudPoint;
  61379. /**
  61380. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61381. * This does nothing and may be overwritten by the user.
  61382. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61383. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61384. * @param update the boolean update value actually passed to setParticles()
  61385. */
  61386. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61387. /**
  61388. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61389. * This will be passed three parameters.
  61390. * This does nothing and may be overwritten by the user.
  61391. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61392. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61393. * @param update the boolean update value actually passed to setParticles()
  61394. */
  61395. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61396. }
  61397. }
  61398. declare module BABYLON {
  61399. /**
  61400. * Represents one particle of a points cloud system.
  61401. */
  61402. export class CloudPoint {
  61403. /**
  61404. * particle global index
  61405. */
  61406. idx: number;
  61407. /**
  61408. * The color of the particle
  61409. */
  61410. color: Nullable<Color4>;
  61411. /**
  61412. * The world space position of the particle.
  61413. */
  61414. position: Vector3;
  61415. /**
  61416. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61417. */
  61418. rotation: Vector3;
  61419. /**
  61420. * The world space rotation quaternion of the particle.
  61421. */
  61422. rotationQuaternion: Nullable<Quaternion>;
  61423. /**
  61424. * The uv of the particle.
  61425. */
  61426. uv: Nullable<Vector2>;
  61427. /**
  61428. * The current speed of the particle.
  61429. */
  61430. velocity: Vector3;
  61431. /**
  61432. * The pivot point in the particle local space.
  61433. */
  61434. pivot: Vector3;
  61435. /**
  61436. * Must the particle be translated from its pivot point in its local space ?
  61437. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61438. * Default : false
  61439. */
  61440. translateFromPivot: boolean;
  61441. /**
  61442. * Index of this particle in the global "positions" array (Internal use)
  61443. * @hidden
  61444. */
  61445. _pos: number;
  61446. /**
  61447. * @hidden Index of this particle in the global "indices" array (Internal use)
  61448. */
  61449. _ind: number;
  61450. /**
  61451. * Group this particle belongs to
  61452. */
  61453. _group: PointsGroup;
  61454. /**
  61455. * Group id of this particle
  61456. */
  61457. groupId: number;
  61458. /**
  61459. * Index of the particle in its group id (Internal use)
  61460. */
  61461. idxInGroup: number;
  61462. /**
  61463. * @hidden Particle BoundingInfo object (Internal use)
  61464. */
  61465. _boundingInfo: BoundingInfo;
  61466. /**
  61467. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61468. */
  61469. _pcs: PointsCloudSystem;
  61470. /**
  61471. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61472. */
  61473. _stillInvisible: boolean;
  61474. /**
  61475. * @hidden Last computed particle rotation matrix
  61476. */
  61477. _rotationMatrix: number[];
  61478. /**
  61479. * Parent particle Id, if any.
  61480. * Default null.
  61481. */
  61482. parentId: Nullable<number>;
  61483. /**
  61484. * @hidden Internal global position in the PCS.
  61485. */
  61486. _globalPosition: Vector3;
  61487. /**
  61488. * Creates a Point Cloud object.
  61489. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61490. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61491. * @param group (PointsGroup) is the group the particle belongs to
  61492. * @param groupId (integer) is the group identifier in the PCS.
  61493. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61494. * @param pcs defines the PCS it is associated to
  61495. */
  61496. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61497. /**
  61498. * get point size
  61499. */
  61500. get size(): Vector3;
  61501. /**
  61502. * Set point size
  61503. */
  61504. set size(scale: Vector3);
  61505. /**
  61506. * Legacy support, changed quaternion to rotationQuaternion
  61507. */
  61508. get quaternion(): Nullable<Quaternion>;
  61509. /**
  61510. * Legacy support, changed quaternion to rotationQuaternion
  61511. */
  61512. set quaternion(q: Nullable<Quaternion>);
  61513. /**
  61514. * Returns a boolean. True if the particle intersects a mesh, else false
  61515. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61516. * @param target is the object (point or mesh) what the intersection is computed against
  61517. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61518. * @returns true if it intersects
  61519. */
  61520. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61521. /**
  61522. * get the rotation matrix of the particle
  61523. * @hidden
  61524. */
  61525. getRotationMatrix(m: Matrix): void;
  61526. }
  61527. /**
  61528. * Represents a group of points in a points cloud system
  61529. * * PCS internal tool, don't use it manually.
  61530. */
  61531. export class PointsGroup {
  61532. /**
  61533. * The group id
  61534. * @hidden
  61535. */
  61536. groupID: number;
  61537. /**
  61538. * image data for group (internal use)
  61539. * @hidden
  61540. */
  61541. _groupImageData: Nullable<ArrayBufferView>;
  61542. /**
  61543. * Image Width (internal use)
  61544. * @hidden
  61545. */
  61546. _groupImgWidth: number;
  61547. /**
  61548. * Image Height (internal use)
  61549. * @hidden
  61550. */
  61551. _groupImgHeight: number;
  61552. /**
  61553. * Custom position function (internal use)
  61554. * @hidden
  61555. */
  61556. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61557. /**
  61558. * density per facet for surface points
  61559. * @hidden
  61560. */
  61561. _groupDensity: number[];
  61562. /**
  61563. * Only when points are colored by texture carries pointer to texture list array
  61564. * @hidden
  61565. */
  61566. _textureNb: number;
  61567. /**
  61568. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61569. * PCS internal tool, don't use it manually.
  61570. * @hidden
  61571. */
  61572. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61573. }
  61574. }
  61575. declare module BABYLON {
  61576. interface Scene {
  61577. /** @hidden (Backing field) */
  61578. _physicsEngine: Nullable<IPhysicsEngine>;
  61579. /** @hidden */
  61580. _physicsTimeAccumulator: number;
  61581. /**
  61582. * Gets the current physics engine
  61583. * @returns a IPhysicsEngine or null if none attached
  61584. */
  61585. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61586. /**
  61587. * Enables physics to the current scene
  61588. * @param gravity defines the scene's gravity for the physics engine
  61589. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61590. * @return a boolean indicating if the physics engine was initialized
  61591. */
  61592. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61593. /**
  61594. * Disables and disposes the physics engine associated with the scene
  61595. */
  61596. disablePhysicsEngine(): void;
  61597. /**
  61598. * Gets a boolean indicating if there is an active physics engine
  61599. * @returns a boolean indicating if there is an active physics engine
  61600. */
  61601. isPhysicsEnabled(): boolean;
  61602. /**
  61603. * Deletes a physics compound impostor
  61604. * @param compound defines the compound to delete
  61605. */
  61606. deleteCompoundImpostor(compound: any): void;
  61607. /**
  61608. * An event triggered when physic simulation is about to be run
  61609. */
  61610. onBeforePhysicsObservable: Observable<Scene>;
  61611. /**
  61612. * An event triggered when physic simulation has been done
  61613. */
  61614. onAfterPhysicsObservable: Observable<Scene>;
  61615. }
  61616. interface AbstractMesh {
  61617. /** @hidden */
  61618. _physicsImpostor: Nullable<PhysicsImpostor>;
  61619. /**
  61620. * Gets or sets impostor used for physic simulation
  61621. * @see http://doc.babylonjs.com/features/physics_engine
  61622. */
  61623. physicsImpostor: Nullable<PhysicsImpostor>;
  61624. /**
  61625. * Gets the current physics impostor
  61626. * @see http://doc.babylonjs.com/features/physics_engine
  61627. * @returns a physics impostor or null
  61628. */
  61629. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61630. /** Apply a physic impulse to the mesh
  61631. * @param force defines the force to apply
  61632. * @param contactPoint defines where to apply the force
  61633. * @returns the current mesh
  61634. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61635. */
  61636. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61637. /**
  61638. * Creates a physic joint between two meshes
  61639. * @param otherMesh defines the other mesh to use
  61640. * @param pivot1 defines the pivot to use on this mesh
  61641. * @param pivot2 defines the pivot to use on the other mesh
  61642. * @param options defines additional options (can be plugin dependent)
  61643. * @returns the current mesh
  61644. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61645. */
  61646. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61647. /** @hidden */
  61648. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61649. }
  61650. /**
  61651. * Defines the physics engine scene component responsible to manage a physics engine
  61652. */
  61653. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61654. /**
  61655. * The component name helpful to identify the component in the list of scene components.
  61656. */
  61657. readonly name: string;
  61658. /**
  61659. * The scene the component belongs to.
  61660. */
  61661. scene: Scene;
  61662. /**
  61663. * Creates a new instance of the component for the given scene
  61664. * @param scene Defines the scene to register the component in
  61665. */
  61666. constructor(scene: Scene);
  61667. /**
  61668. * Registers the component in a given scene
  61669. */
  61670. register(): void;
  61671. /**
  61672. * Rebuilds the elements related to this component in case of
  61673. * context lost for instance.
  61674. */
  61675. rebuild(): void;
  61676. /**
  61677. * Disposes the component and the associated ressources
  61678. */
  61679. dispose(): void;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. /**
  61684. * A helper for physics simulations
  61685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61686. */
  61687. export class PhysicsHelper {
  61688. private _scene;
  61689. private _physicsEngine;
  61690. /**
  61691. * Initializes the Physics helper
  61692. * @param scene Babylon.js scene
  61693. */
  61694. constructor(scene: Scene);
  61695. /**
  61696. * Applies a radial explosion impulse
  61697. * @param origin the origin of the explosion
  61698. * @param radiusOrEventOptions the radius or the options of radial explosion
  61699. * @param strength the explosion strength
  61700. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61701. * @returns A physics radial explosion event, or null
  61702. */
  61703. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61704. /**
  61705. * Applies a radial explosion force
  61706. * @param origin the origin of the explosion
  61707. * @param radiusOrEventOptions the radius or the options of radial explosion
  61708. * @param strength the explosion strength
  61709. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61710. * @returns A physics radial explosion event, or null
  61711. */
  61712. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61713. /**
  61714. * Creates a gravitational field
  61715. * @param origin the origin of the explosion
  61716. * @param radiusOrEventOptions the radius or the options of radial explosion
  61717. * @param strength the explosion strength
  61718. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61719. * @returns A physics gravitational field event, or null
  61720. */
  61721. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61722. /**
  61723. * Creates a physics updraft event
  61724. * @param origin the origin of the updraft
  61725. * @param radiusOrEventOptions the radius or the options of the updraft
  61726. * @param strength the strength of the updraft
  61727. * @param height the height of the updraft
  61728. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61729. * @returns A physics updraft event, or null
  61730. */
  61731. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61732. /**
  61733. * Creates a physics vortex event
  61734. * @param origin the of the vortex
  61735. * @param radiusOrEventOptions the radius or the options of the vortex
  61736. * @param strength the strength of the vortex
  61737. * @param height the height of the vortex
  61738. * @returns a Physics vortex event, or null
  61739. * A physics vortex event or null
  61740. */
  61741. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61742. }
  61743. /**
  61744. * Represents a physics radial explosion event
  61745. */
  61746. class PhysicsRadialExplosionEvent {
  61747. private _scene;
  61748. private _options;
  61749. private _sphere;
  61750. private _dataFetched;
  61751. /**
  61752. * Initializes a radial explosioin event
  61753. * @param _scene BabylonJS scene
  61754. * @param _options The options for the vortex event
  61755. */
  61756. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61757. /**
  61758. * Returns the data related to the radial explosion event (sphere).
  61759. * @returns The radial explosion event data
  61760. */
  61761. getData(): PhysicsRadialExplosionEventData;
  61762. /**
  61763. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61764. * @param impostor A physics imposter
  61765. * @param origin the origin of the explosion
  61766. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61767. */
  61768. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61769. /**
  61770. * Triggers affecterd impostors callbacks
  61771. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61772. */
  61773. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61774. /**
  61775. * Disposes the sphere.
  61776. * @param force Specifies if the sphere should be disposed by force
  61777. */
  61778. dispose(force?: boolean): void;
  61779. /*** Helpers ***/
  61780. private _prepareSphere;
  61781. private _intersectsWithSphere;
  61782. }
  61783. /**
  61784. * Represents a gravitational field event
  61785. */
  61786. class PhysicsGravitationalFieldEvent {
  61787. private _physicsHelper;
  61788. private _scene;
  61789. private _origin;
  61790. private _options;
  61791. private _tickCallback;
  61792. private _sphere;
  61793. private _dataFetched;
  61794. /**
  61795. * Initializes the physics gravitational field event
  61796. * @param _physicsHelper A physics helper
  61797. * @param _scene BabylonJS scene
  61798. * @param _origin The origin position of the gravitational field event
  61799. * @param _options The options for the vortex event
  61800. */
  61801. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61802. /**
  61803. * Returns the data related to the gravitational field event (sphere).
  61804. * @returns A gravitational field event
  61805. */
  61806. getData(): PhysicsGravitationalFieldEventData;
  61807. /**
  61808. * Enables the gravitational field.
  61809. */
  61810. enable(): void;
  61811. /**
  61812. * Disables the gravitational field.
  61813. */
  61814. disable(): void;
  61815. /**
  61816. * Disposes the sphere.
  61817. * @param force The force to dispose from the gravitational field event
  61818. */
  61819. dispose(force?: boolean): void;
  61820. private _tick;
  61821. }
  61822. /**
  61823. * Represents a physics updraft event
  61824. */
  61825. class PhysicsUpdraftEvent {
  61826. private _scene;
  61827. private _origin;
  61828. private _options;
  61829. private _physicsEngine;
  61830. private _originTop;
  61831. private _originDirection;
  61832. private _tickCallback;
  61833. private _cylinder;
  61834. private _cylinderPosition;
  61835. private _dataFetched;
  61836. /**
  61837. * Initializes the physics updraft event
  61838. * @param _scene BabylonJS scene
  61839. * @param _origin The origin position of the updraft
  61840. * @param _options The options for the updraft event
  61841. */
  61842. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61843. /**
  61844. * Returns the data related to the updraft event (cylinder).
  61845. * @returns A physics updraft event
  61846. */
  61847. getData(): PhysicsUpdraftEventData;
  61848. /**
  61849. * Enables the updraft.
  61850. */
  61851. enable(): void;
  61852. /**
  61853. * Disables the updraft.
  61854. */
  61855. disable(): void;
  61856. /**
  61857. * Disposes the cylinder.
  61858. * @param force Specifies if the updraft should be disposed by force
  61859. */
  61860. dispose(force?: boolean): void;
  61861. private getImpostorHitData;
  61862. private _tick;
  61863. /*** Helpers ***/
  61864. private _prepareCylinder;
  61865. private _intersectsWithCylinder;
  61866. }
  61867. /**
  61868. * Represents a physics vortex event
  61869. */
  61870. class PhysicsVortexEvent {
  61871. private _scene;
  61872. private _origin;
  61873. private _options;
  61874. private _physicsEngine;
  61875. private _originTop;
  61876. private _tickCallback;
  61877. private _cylinder;
  61878. private _cylinderPosition;
  61879. private _dataFetched;
  61880. /**
  61881. * Initializes the physics vortex event
  61882. * @param _scene The BabylonJS scene
  61883. * @param _origin The origin position of the vortex
  61884. * @param _options The options for the vortex event
  61885. */
  61886. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61887. /**
  61888. * Returns the data related to the vortex event (cylinder).
  61889. * @returns The physics vortex event data
  61890. */
  61891. getData(): PhysicsVortexEventData;
  61892. /**
  61893. * Enables the vortex.
  61894. */
  61895. enable(): void;
  61896. /**
  61897. * Disables the cortex.
  61898. */
  61899. disable(): void;
  61900. /**
  61901. * Disposes the sphere.
  61902. * @param force
  61903. */
  61904. dispose(force?: boolean): void;
  61905. private getImpostorHitData;
  61906. private _tick;
  61907. /*** Helpers ***/
  61908. private _prepareCylinder;
  61909. private _intersectsWithCylinder;
  61910. }
  61911. /**
  61912. * Options fot the radial explosion event
  61913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61914. */
  61915. export class PhysicsRadialExplosionEventOptions {
  61916. /**
  61917. * The radius of the sphere for the radial explosion.
  61918. */
  61919. radius: number;
  61920. /**
  61921. * The strenth of the explosion.
  61922. */
  61923. strength: number;
  61924. /**
  61925. * The strenght of the force in correspondence to the distance of the affected object
  61926. */
  61927. falloff: PhysicsRadialImpulseFalloff;
  61928. /**
  61929. * Sphere options for the radial explosion.
  61930. */
  61931. sphere: {
  61932. segments: number;
  61933. diameter: number;
  61934. };
  61935. /**
  61936. * Sphere options for the radial explosion.
  61937. */
  61938. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61939. }
  61940. /**
  61941. * Options fot the updraft event
  61942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61943. */
  61944. export class PhysicsUpdraftEventOptions {
  61945. /**
  61946. * The radius of the cylinder for the vortex
  61947. */
  61948. radius: number;
  61949. /**
  61950. * The strenth of the updraft.
  61951. */
  61952. strength: number;
  61953. /**
  61954. * The height of the cylinder for the updraft.
  61955. */
  61956. height: number;
  61957. /**
  61958. * The mode for the the updraft.
  61959. */
  61960. updraftMode: PhysicsUpdraftMode;
  61961. }
  61962. /**
  61963. * Options fot the vortex event
  61964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61965. */
  61966. export class PhysicsVortexEventOptions {
  61967. /**
  61968. * The radius of the cylinder for the vortex
  61969. */
  61970. radius: number;
  61971. /**
  61972. * The strenth of the vortex.
  61973. */
  61974. strength: number;
  61975. /**
  61976. * The height of the cylinder for the vortex.
  61977. */
  61978. height: number;
  61979. /**
  61980. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61981. */
  61982. centripetalForceThreshold: number;
  61983. /**
  61984. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61985. */
  61986. centripetalForceMultiplier: number;
  61987. /**
  61988. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61989. */
  61990. centrifugalForceMultiplier: number;
  61991. /**
  61992. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61993. */
  61994. updraftForceMultiplier: number;
  61995. }
  61996. /**
  61997. * The strenght of the force in correspondence to the distance of the affected object
  61998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61999. */
  62000. export enum PhysicsRadialImpulseFalloff {
  62001. /** Defines that impulse is constant in strength across it's whole radius */
  62002. Constant = 0,
  62003. /** Defines that impulse gets weaker if it's further from the origin */
  62004. Linear = 1
  62005. }
  62006. /**
  62007. * The strength of the force in correspondence to the distance of the affected object
  62008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62009. */
  62010. export enum PhysicsUpdraftMode {
  62011. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62012. Center = 0,
  62013. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62014. Perpendicular = 1
  62015. }
  62016. /**
  62017. * Interface for a physics hit data
  62018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62019. */
  62020. export interface PhysicsHitData {
  62021. /**
  62022. * The force applied at the contact point
  62023. */
  62024. force: Vector3;
  62025. /**
  62026. * The contact point
  62027. */
  62028. contactPoint: Vector3;
  62029. /**
  62030. * The distance from the origin to the contact point
  62031. */
  62032. distanceFromOrigin: number;
  62033. }
  62034. /**
  62035. * Interface for radial explosion event data
  62036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62037. */
  62038. export interface PhysicsRadialExplosionEventData {
  62039. /**
  62040. * A sphere used for the radial explosion event
  62041. */
  62042. sphere: Mesh;
  62043. }
  62044. /**
  62045. * Interface for gravitational field event data
  62046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62047. */
  62048. export interface PhysicsGravitationalFieldEventData {
  62049. /**
  62050. * A sphere mesh used for the gravitational field event
  62051. */
  62052. sphere: Mesh;
  62053. }
  62054. /**
  62055. * Interface for updraft event data
  62056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62057. */
  62058. export interface PhysicsUpdraftEventData {
  62059. /**
  62060. * A cylinder used for the updraft event
  62061. */
  62062. cylinder: Mesh;
  62063. }
  62064. /**
  62065. * Interface for vortex event data
  62066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62067. */
  62068. export interface PhysicsVortexEventData {
  62069. /**
  62070. * A cylinder used for the vortex event
  62071. */
  62072. cylinder: Mesh;
  62073. }
  62074. /**
  62075. * Interface for an affected physics impostor
  62076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62077. */
  62078. export interface PhysicsAffectedImpostorWithData {
  62079. /**
  62080. * The impostor affected by the effect
  62081. */
  62082. impostor: PhysicsImpostor;
  62083. /**
  62084. * The data about the hit/horce from the explosion
  62085. */
  62086. hitData: PhysicsHitData;
  62087. }
  62088. }
  62089. declare module BABYLON {
  62090. /** @hidden */
  62091. export var blackAndWhitePixelShader: {
  62092. name: string;
  62093. shader: string;
  62094. };
  62095. }
  62096. declare module BABYLON {
  62097. /**
  62098. * Post process used to render in black and white
  62099. */
  62100. export class BlackAndWhitePostProcess extends PostProcess {
  62101. /**
  62102. * Linear about to convert he result to black and white (default: 1)
  62103. */
  62104. degree: number;
  62105. /**
  62106. * Creates a black and white post process
  62107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62108. * @param name The name of the effect.
  62109. * @param options The required width/height ratio to downsize to before computing the render pass.
  62110. * @param camera The camera to apply the render pass to.
  62111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62112. * @param engine The engine which the post process will be applied. (default: current engine)
  62113. * @param reusable If the post process can be reused on the same frame. (default: false)
  62114. */
  62115. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * This represents a set of one or more post processes in Babylon.
  62121. * A post process can be used to apply a shader to a texture after it is rendered.
  62122. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62123. */
  62124. export class PostProcessRenderEffect {
  62125. private _postProcesses;
  62126. private _getPostProcesses;
  62127. private _singleInstance;
  62128. private _cameras;
  62129. private _indicesForCamera;
  62130. /**
  62131. * Name of the effect
  62132. * @hidden
  62133. */
  62134. _name: string;
  62135. /**
  62136. * Instantiates a post process render effect.
  62137. * A post process can be used to apply a shader to a texture after it is rendered.
  62138. * @param engine The engine the effect is tied to
  62139. * @param name The name of the effect
  62140. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62141. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62142. */
  62143. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62144. /**
  62145. * Checks if all the post processes in the effect are supported.
  62146. */
  62147. get isSupported(): boolean;
  62148. /**
  62149. * Updates the current state of the effect
  62150. * @hidden
  62151. */
  62152. _update(): void;
  62153. /**
  62154. * Attaches the effect on cameras
  62155. * @param cameras The camera to attach to.
  62156. * @hidden
  62157. */
  62158. _attachCameras(cameras: Camera): void;
  62159. /**
  62160. * Attaches the effect on cameras
  62161. * @param cameras The camera to attach to.
  62162. * @hidden
  62163. */
  62164. _attachCameras(cameras: Camera[]): void;
  62165. /**
  62166. * Detaches the effect on cameras
  62167. * @param cameras The camera to detatch from.
  62168. * @hidden
  62169. */
  62170. _detachCameras(cameras: Camera): void;
  62171. /**
  62172. * Detatches the effect on cameras
  62173. * @param cameras The camera to detatch from.
  62174. * @hidden
  62175. */
  62176. _detachCameras(cameras: Camera[]): void;
  62177. /**
  62178. * Enables the effect on given cameras
  62179. * @param cameras The camera to enable.
  62180. * @hidden
  62181. */
  62182. _enable(cameras: Camera): void;
  62183. /**
  62184. * Enables the effect on given cameras
  62185. * @param cameras The camera to enable.
  62186. * @hidden
  62187. */
  62188. _enable(cameras: Nullable<Camera[]>): void;
  62189. /**
  62190. * Disables the effect on the given cameras
  62191. * @param cameras The camera to disable.
  62192. * @hidden
  62193. */
  62194. _disable(cameras: Camera): void;
  62195. /**
  62196. * Disables the effect on the given cameras
  62197. * @param cameras The camera to disable.
  62198. * @hidden
  62199. */
  62200. _disable(cameras: Nullable<Camera[]>): void;
  62201. /**
  62202. * Gets a list of the post processes contained in the effect.
  62203. * @param camera The camera to get the post processes on.
  62204. * @returns The list of the post processes in the effect.
  62205. */
  62206. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62207. }
  62208. }
  62209. declare module BABYLON {
  62210. /** @hidden */
  62211. export var extractHighlightsPixelShader: {
  62212. name: string;
  62213. shader: string;
  62214. };
  62215. }
  62216. declare module BABYLON {
  62217. /**
  62218. * 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.
  62219. */
  62220. export class ExtractHighlightsPostProcess extends PostProcess {
  62221. /**
  62222. * The luminance threshold, pixels below this value will be set to black.
  62223. */
  62224. threshold: number;
  62225. /** @hidden */
  62226. _exposure: number;
  62227. /**
  62228. * Post process which has the input texture to be used when performing highlight extraction
  62229. * @hidden
  62230. */
  62231. _inputPostProcess: Nullable<PostProcess>;
  62232. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62233. }
  62234. }
  62235. declare module BABYLON {
  62236. /** @hidden */
  62237. export var bloomMergePixelShader: {
  62238. name: string;
  62239. shader: string;
  62240. };
  62241. }
  62242. declare module BABYLON {
  62243. /**
  62244. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62245. */
  62246. export class BloomMergePostProcess extends PostProcess {
  62247. /** Weight of the bloom to be added to the original input. */
  62248. weight: number;
  62249. /**
  62250. * Creates a new instance of @see BloomMergePostProcess
  62251. * @param name The name of the effect.
  62252. * @param originalFromInput Post process which's input will be used for the merge.
  62253. * @param blurred Blurred highlights post process which's output will be used.
  62254. * @param weight Weight of the bloom to be added to the original input.
  62255. * @param options The required width/height ratio to downsize to before computing the render pass.
  62256. * @param camera The camera to apply the render pass to.
  62257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62258. * @param engine The engine which the post process will be applied. (default: current engine)
  62259. * @param reusable If the post process can be reused on the same frame. (default: false)
  62260. * @param textureType Type of textures used when performing the post process. (default: 0)
  62261. * @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)
  62262. */
  62263. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62264. /** Weight of the bloom to be added to the original input. */
  62265. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. /**
  62270. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62271. */
  62272. export class BloomEffect extends PostProcessRenderEffect {
  62273. private bloomScale;
  62274. /**
  62275. * @hidden Internal
  62276. */
  62277. _effects: Array<PostProcess>;
  62278. /**
  62279. * @hidden Internal
  62280. */
  62281. _downscale: ExtractHighlightsPostProcess;
  62282. private _blurX;
  62283. private _blurY;
  62284. private _merge;
  62285. /**
  62286. * The luminance threshold to find bright areas of the image to bloom.
  62287. */
  62288. get threshold(): number;
  62289. set threshold(value: number);
  62290. /**
  62291. * The strength of the bloom.
  62292. */
  62293. get weight(): number;
  62294. set weight(value: number);
  62295. /**
  62296. * Specifies the size of the bloom blur kernel, relative to the final output size
  62297. */
  62298. get kernel(): number;
  62299. set kernel(value: number);
  62300. /**
  62301. * Creates a new instance of @see BloomEffect
  62302. * @param scene The scene the effect belongs to.
  62303. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62304. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62305. * @param bloomWeight The the strength of bloom.
  62306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62307. * @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)
  62308. */
  62309. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62310. /**
  62311. * Disposes each of the internal effects for a given camera.
  62312. * @param camera The camera to dispose the effect on.
  62313. */
  62314. disposeEffects(camera: Camera): void;
  62315. /**
  62316. * @hidden Internal
  62317. */
  62318. _updateEffects(): void;
  62319. /**
  62320. * Internal
  62321. * @returns if all the contained post processes are ready.
  62322. * @hidden
  62323. */
  62324. _isReady(): boolean;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /** @hidden */
  62329. export var chromaticAberrationPixelShader: {
  62330. name: string;
  62331. shader: string;
  62332. };
  62333. }
  62334. declare module BABYLON {
  62335. /**
  62336. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62337. */
  62338. export class ChromaticAberrationPostProcess extends PostProcess {
  62339. /**
  62340. * The amount of seperation of rgb channels (default: 30)
  62341. */
  62342. aberrationAmount: number;
  62343. /**
  62344. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62345. */
  62346. radialIntensity: number;
  62347. /**
  62348. * 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))
  62349. */
  62350. direction: Vector2;
  62351. /**
  62352. * 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))
  62353. */
  62354. centerPosition: Vector2;
  62355. /**
  62356. * Creates a new instance ChromaticAberrationPostProcess
  62357. * @param name The name of the effect.
  62358. * @param screenWidth The width of the screen to apply the effect on.
  62359. * @param screenHeight The height of the screen to apply the effect on.
  62360. * @param options The required width/height ratio to downsize to before computing the render pass.
  62361. * @param camera The camera to apply the render pass to.
  62362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62363. * @param engine The engine which the post process will be applied. (default: current engine)
  62364. * @param reusable If the post process can be reused on the same frame. (default: false)
  62365. * @param textureType Type of textures used when performing the post process. (default: 0)
  62366. * @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)
  62367. */
  62368. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62369. }
  62370. }
  62371. declare module BABYLON {
  62372. /** @hidden */
  62373. export var circleOfConfusionPixelShader: {
  62374. name: string;
  62375. shader: string;
  62376. };
  62377. }
  62378. declare module BABYLON {
  62379. /**
  62380. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62381. */
  62382. export class CircleOfConfusionPostProcess extends PostProcess {
  62383. /**
  62384. * 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.
  62385. */
  62386. lensSize: number;
  62387. /**
  62388. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62389. */
  62390. fStop: number;
  62391. /**
  62392. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62393. */
  62394. focusDistance: number;
  62395. /**
  62396. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62397. */
  62398. focalLength: number;
  62399. private _depthTexture;
  62400. /**
  62401. * Creates a new instance CircleOfConfusionPostProcess
  62402. * @param name The name of the effect.
  62403. * @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.
  62404. * @param options The required width/height ratio to downsize to before computing the render pass.
  62405. * @param camera The camera to apply the render pass to.
  62406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62407. * @param engine The engine which the post process will be applied. (default: current engine)
  62408. * @param reusable If the post process can be reused on the same frame. (default: false)
  62409. * @param textureType Type of textures used when performing the post process. (default: 0)
  62410. * @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)
  62411. */
  62412. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62413. /**
  62414. * 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.
  62415. */
  62416. set depthTexture(value: RenderTargetTexture);
  62417. }
  62418. }
  62419. declare module BABYLON {
  62420. /** @hidden */
  62421. export var colorCorrectionPixelShader: {
  62422. name: string;
  62423. shader: string;
  62424. };
  62425. }
  62426. declare module BABYLON {
  62427. /**
  62428. *
  62429. * This post-process allows the modification of rendered colors by using
  62430. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62431. *
  62432. * The object needs to be provided an url to a texture containing the color
  62433. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62434. * Use an image editing software to tweak the LUT to match your needs.
  62435. *
  62436. * For an example of a color LUT, see here:
  62437. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62438. * For explanations on color grading, see here:
  62439. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62440. *
  62441. */
  62442. export class ColorCorrectionPostProcess extends PostProcess {
  62443. private _colorTableTexture;
  62444. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62445. }
  62446. }
  62447. declare module BABYLON {
  62448. /** @hidden */
  62449. export var convolutionPixelShader: {
  62450. name: string;
  62451. shader: string;
  62452. };
  62453. }
  62454. declare module BABYLON {
  62455. /**
  62456. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62457. * input texture to perform effects such as edge detection or sharpening
  62458. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62459. */
  62460. export class ConvolutionPostProcess extends PostProcess {
  62461. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62462. kernel: number[];
  62463. /**
  62464. * Creates a new instance ConvolutionPostProcess
  62465. * @param name The name of the effect.
  62466. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62467. * @param options The required width/height ratio to downsize to before computing the render pass.
  62468. * @param camera The camera to apply the render pass to.
  62469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62470. * @param engine The engine which the post process will be applied. (default: current engine)
  62471. * @param reusable If the post process can be reused on the same frame. (default: false)
  62472. * @param textureType Type of textures used when performing the post process. (default: 0)
  62473. */
  62474. constructor(name: string,
  62475. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62476. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62477. /**
  62478. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62479. */
  62480. static EdgeDetect0Kernel: number[];
  62481. /**
  62482. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62483. */
  62484. static EdgeDetect1Kernel: number[];
  62485. /**
  62486. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62487. */
  62488. static EdgeDetect2Kernel: number[];
  62489. /**
  62490. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62491. */
  62492. static SharpenKernel: number[];
  62493. /**
  62494. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62495. */
  62496. static EmbossKernel: number[];
  62497. /**
  62498. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62499. */
  62500. static GaussianKernel: number[];
  62501. }
  62502. }
  62503. declare module BABYLON {
  62504. /**
  62505. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62506. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62507. * based on samples that have a large difference in distance than the center pixel.
  62508. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62509. */
  62510. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62511. direction: Vector2;
  62512. /**
  62513. * Creates a new instance CircleOfConfusionPostProcess
  62514. * @param name The name of the effect.
  62515. * @param scene The scene the effect belongs to.
  62516. * @param direction The direction the blur should be applied.
  62517. * @param kernel The size of the kernel used to blur.
  62518. * @param options The required width/height ratio to downsize to before computing the render pass.
  62519. * @param camera The camera to apply the render pass to.
  62520. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62521. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62523. * @param engine The engine which the post process will be applied. (default: current engine)
  62524. * @param reusable If the post process can be reused on the same frame. (default: false)
  62525. * @param textureType Type of textures used when performing the post process. (default: 0)
  62526. * @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)
  62527. */
  62528. 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);
  62529. }
  62530. }
  62531. declare module BABYLON {
  62532. /** @hidden */
  62533. export var depthOfFieldMergePixelShader: {
  62534. name: string;
  62535. shader: string;
  62536. };
  62537. }
  62538. declare module BABYLON {
  62539. /**
  62540. * Options to be set when merging outputs from the default pipeline.
  62541. */
  62542. export class DepthOfFieldMergePostProcessOptions {
  62543. /**
  62544. * The original image to merge on top of
  62545. */
  62546. originalFromInput: PostProcess;
  62547. /**
  62548. * Parameters to perform the merge of the depth of field effect
  62549. */
  62550. depthOfField?: {
  62551. circleOfConfusion: PostProcess;
  62552. blurSteps: Array<PostProcess>;
  62553. };
  62554. /**
  62555. * Parameters to perform the merge of bloom effect
  62556. */
  62557. bloom?: {
  62558. blurred: PostProcess;
  62559. weight: number;
  62560. };
  62561. }
  62562. /**
  62563. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62564. */
  62565. export class DepthOfFieldMergePostProcess extends PostProcess {
  62566. private blurSteps;
  62567. /**
  62568. * Creates a new instance of DepthOfFieldMergePostProcess
  62569. * @param name The name of the effect.
  62570. * @param originalFromInput Post process which's input will be used for the merge.
  62571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62573. * @param options The required width/height ratio to downsize to before computing the render pass.
  62574. * @param camera The camera to apply the render pass to.
  62575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62576. * @param engine The engine which the post process will be applied. (default: current engine)
  62577. * @param reusable If the post process can be reused on the same frame. (default: false)
  62578. * @param textureType Type of textures used when performing the post process. (default: 0)
  62579. * @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)
  62580. */
  62581. 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);
  62582. /**
  62583. * Updates the effect with the current post process compile time values and recompiles the shader.
  62584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62587. * @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
  62588. * @param onCompiled Called when the shader has been compiled.
  62589. * @param onError Called if there is an error when compiling a shader.
  62590. */
  62591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. /**
  62596. * Specifies the level of max blur that should be applied when using the depth of field effect
  62597. */
  62598. export enum DepthOfFieldEffectBlurLevel {
  62599. /**
  62600. * Subtle blur
  62601. */
  62602. Low = 0,
  62603. /**
  62604. * Medium blur
  62605. */
  62606. Medium = 1,
  62607. /**
  62608. * Large blur
  62609. */
  62610. High = 2
  62611. }
  62612. /**
  62613. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62614. */
  62615. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62616. private _circleOfConfusion;
  62617. /**
  62618. * @hidden Internal, blurs from high to low
  62619. */
  62620. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62621. private _depthOfFieldBlurY;
  62622. private _dofMerge;
  62623. /**
  62624. * @hidden Internal post processes in depth of field effect
  62625. */
  62626. _effects: Array<PostProcess>;
  62627. /**
  62628. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62629. */
  62630. set focalLength(value: number);
  62631. get focalLength(): number;
  62632. /**
  62633. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62634. */
  62635. set fStop(value: number);
  62636. get fStop(): number;
  62637. /**
  62638. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62639. */
  62640. set focusDistance(value: number);
  62641. get focusDistance(): number;
  62642. /**
  62643. * 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.
  62644. */
  62645. set lensSize(value: number);
  62646. get lensSize(): number;
  62647. /**
  62648. * Creates a new instance DepthOfFieldEffect
  62649. * @param scene The scene the effect belongs to.
  62650. * @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.
  62651. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62652. * @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)
  62653. */
  62654. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62655. /**
  62656. * Get the current class name of the current effet
  62657. * @returns "DepthOfFieldEffect"
  62658. */
  62659. getClassName(): string;
  62660. /**
  62661. * 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.
  62662. */
  62663. set depthTexture(value: RenderTargetTexture);
  62664. /**
  62665. * Disposes each of the internal effects for a given camera.
  62666. * @param camera The camera to dispose the effect on.
  62667. */
  62668. disposeEffects(camera: Camera): void;
  62669. /**
  62670. * @hidden Internal
  62671. */
  62672. _updateEffects(): void;
  62673. /**
  62674. * Internal
  62675. * @returns if all the contained post processes are ready.
  62676. * @hidden
  62677. */
  62678. _isReady(): boolean;
  62679. }
  62680. }
  62681. declare module BABYLON {
  62682. /** @hidden */
  62683. export var displayPassPixelShader: {
  62684. name: string;
  62685. shader: string;
  62686. };
  62687. }
  62688. declare module BABYLON {
  62689. /**
  62690. * DisplayPassPostProcess which produces an output the same as it's input
  62691. */
  62692. export class DisplayPassPostProcess extends PostProcess {
  62693. /**
  62694. * Creates the DisplayPassPostProcess
  62695. * @param name The name of the effect.
  62696. * @param options The required width/height ratio to downsize to before computing the render pass.
  62697. * @param camera The camera to apply the render pass to.
  62698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62699. * @param engine The engine which the post process will be applied. (default: current engine)
  62700. * @param reusable If the post process can be reused on the same frame. (default: false)
  62701. */
  62702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62703. }
  62704. }
  62705. declare module BABYLON {
  62706. /** @hidden */
  62707. export var filterPixelShader: {
  62708. name: string;
  62709. shader: string;
  62710. };
  62711. }
  62712. declare module BABYLON {
  62713. /**
  62714. * Applies a kernel filter to the image
  62715. */
  62716. export class FilterPostProcess extends PostProcess {
  62717. /** The matrix to be applied to the image */
  62718. kernelMatrix: Matrix;
  62719. /**
  62720. *
  62721. * @param name The name of the effect.
  62722. * @param kernelMatrix The matrix to be applied to the image
  62723. * @param options The required width/height ratio to downsize to before computing the render pass.
  62724. * @param camera The camera to apply the render pass to.
  62725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62726. * @param engine The engine which the post process will be applied. (default: current engine)
  62727. * @param reusable If the post process can be reused on the same frame. (default: false)
  62728. */
  62729. constructor(name: string,
  62730. /** The matrix to be applied to the image */
  62731. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62732. }
  62733. }
  62734. declare module BABYLON {
  62735. /** @hidden */
  62736. export var fxaaPixelShader: {
  62737. name: string;
  62738. shader: string;
  62739. };
  62740. }
  62741. declare module BABYLON {
  62742. /** @hidden */
  62743. export var fxaaVertexShader: {
  62744. name: string;
  62745. shader: string;
  62746. };
  62747. }
  62748. declare module BABYLON {
  62749. /**
  62750. * Fxaa post process
  62751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62752. */
  62753. export class FxaaPostProcess extends PostProcess {
  62754. /** @hidden */
  62755. texelWidth: number;
  62756. /** @hidden */
  62757. texelHeight: number;
  62758. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62759. private _getDefines;
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /** @hidden */
  62764. export var grainPixelShader: {
  62765. name: string;
  62766. shader: string;
  62767. };
  62768. }
  62769. declare module BABYLON {
  62770. /**
  62771. * The GrainPostProcess adds noise to the image at mid luminance levels
  62772. */
  62773. export class GrainPostProcess extends PostProcess {
  62774. /**
  62775. * The intensity of the grain added (default: 30)
  62776. */
  62777. intensity: number;
  62778. /**
  62779. * If the grain should be randomized on every frame
  62780. */
  62781. animated: boolean;
  62782. /**
  62783. * Creates a new instance of @see GrainPostProcess
  62784. * @param name The name of the effect.
  62785. * @param options The required width/height ratio to downsize to before computing the render pass.
  62786. * @param camera The camera to apply the render pass to.
  62787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62788. * @param engine The engine which the post process will be applied. (default: current engine)
  62789. * @param reusable If the post process can be reused on the same frame. (default: false)
  62790. * @param textureType Type of textures used when performing the post process. (default: 0)
  62791. * @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)
  62792. */
  62793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62794. }
  62795. }
  62796. declare module BABYLON {
  62797. /** @hidden */
  62798. export var highlightsPixelShader: {
  62799. name: string;
  62800. shader: string;
  62801. };
  62802. }
  62803. declare module BABYLON {
  62804. /**
  62805. * Extracts highlights from the image
  62806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62807. */
  62808. export class HighlightsPostProcess extends PostProcess {
  62809. /**
  62810. * Extracts highlights from the image
  62811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62812. * @param name The name of the effect.
  62813. * @param options The required width/height ratio to downsize to before computing the render pass.
  62814. * @param camera The camera to apply the render pass to.
  62815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62816. * @param engine The engine which the post process will be applied. (default: current engine)
  62817. * @param reusable If the post process can be reused on the same frame. (default: false)
  62818. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62819. */
  62820. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62821. }
  62822. }
  62823. declare module BABYLON {
  62824. /** @hidden */
  62825. export var mrtFragmentDeclaration: {
  62826. name: string;
  62827. shader: string;
  62828. };
  62829. }
  62830. declare module BABYLON {
  62831. /** @hidden */
  62832. export var geometryPixelShader: {
  62833. name: string;
  62834. shader: string;
  62835. };
  62836. }
  62837. declare module BABYLON {
  62838. /** @hidden */
  62839. export var geometryVertexShader: {
  62840. name: string;
  62841. shader: string;
  62842. };
  62843. }
  62844. declare module BABYLON {
  62845. /** @hidden */
  62846. interface ISavedTransformationMatrix {
  62847. world: Matrix;
  62848. viewProjection: Matrix;
  62849. }
  62850. /**
  62851. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62852. */
  62853. export class GeometryBufferRenderer {
  62854. /**
  62855. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62856. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62857. */
  62858. static readonly POSITION_TEXTURE_TYPE: number;
  62859. /**
  62860. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62861. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62862. */
  62863. static readonly VELOCITY_TEXTURE_TYPE: number;
  62864. /**
  62865. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62866. * in order to compute objects velocities when enableVelocity is set to "true"
  62867. * @hidden
  62868. */
  62869. _previousTransformationMatrices: {
  62870. [index: number]: ISavedTransformationMatrix;
  62871. };
  62872. /**
  62873. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62874. * in order to compute objects velocities when enableVelocity is set to "true"
  62875. * @hidden
  62876. */
  62877. _previousBonesTransformationMatrices: {
  62878. [index: number]: Float32Array;
  62879. };
  62880. /**
  62881. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62882. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62883. */
  62884. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62885. private _scene;
  62886. private _multiRenderTarget;
  62887. private _ratio;
  62888. private _enablePosition;
  62889. private _enableVelocity;
  62890. private _positionIndex;
  62891. private _velocityIndex;
  62892. protected _effect: Effect;
  62893. protected _cachedDefines: string;
  62894. /**
  62895. * Set the render list (meshes to be rendered) used in the G buffer.
  62896. */
  62897. set renderList(meshes: Mesh[]);
  62898. /**
  62899. * Gets wether or not G buffer are supported by the running hardware.
  62900. * This requires draw buffer supports
  62901. */
  62902. get isSupported(): boolean;
  62903. /**
  62904. * Returns the index of the given texture type in the G-Buffer textures array
  62905. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62906. * @returns the index of the given texture type in the G-Buffer textures array
  62907. */
  62908. getTextureIndex(textureType: number): number;
  62909. /**
  62910. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62911. */
  62912. get enablePosition(): boolean;
  62913. /**
  62914. * Sets whether or not objects positions are enabled for the G buffer.
  62915. */
  62916. set enablePosition(enable: boolean);
  62917. /**
  62918. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62919. */
  62920. get enableVelocity(): boolean;
  62921. /**
  62922. * Sets wether or not objects velocities are enabled for the G buffer.
  62923. */
  62924. set enableVelocity(enable: boolean);
  62925. /**
  62926. * Gets the scene associated with the buffer.
  62927. */
  62928. get scene(): Scene;
  62929. /**
  62930. * Gets the ratio used by the buffer during its creation.
  62931. * How big is the buffer related to the main canvas.
  62932. */
  62933. get ratio(): number;
  62934. /** @hidden */
  62935. static _SceneComponentInitialization: (scene: Scene) => void;
  62936. /**
  62937. * Creates a new G Buffer for the scene
  62938. * @param scene The scene the buffer belongs to
  62939. * @param ratio How big is the buffer related to the main canvas.
  62940. */
  62941. constructor(scene: Scene, ratio?: number);
  62942. /**
  62943. * Checks wether everything is ready to render a submesh to the G buffer.
  62944. * @param subMesh the submesh to check readiness for
  62945. * @param useInstances is the mesh drawn using instance or not
  62946. * @returns true if ready otherwise false
  62947. */
  62948. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62949. /**
  62950. * Gets the current underlying G Buffer.
  62951. * @returns the buffer
  62952. */
  62953. getGBuffer(): MultiRenderTarget;
  62954. /**
  62955. * Gets the number of samples used to render the buffer (anti aliasing).
  62956. */
  62957. get samples(): number;
  62958. /**
  62959. * Sets the number of samples used to render the buffer (anti aliasing).
  62960. */
  62961. set samples(value: number);
  62962. /**
  62963. * Disposes the renderer and frees up associated resources.
  62964. */
  62965. dispose(): void;
  62966. protected _createRenderTargets(): void;
  62967. private _copyBonesTransformationMatrices;
  62968. }
  62969. }
  62970. declare module BABYLON {
  62971. interface Scene {
  62972. /** @hidden (Backing field) */
  62973. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62974. /**
  62975. * Gets or Sets the current geometry buffer associated to the scene.
  62976. */
  62977. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62978. /**
  62979. * Enables a GeometryBufferRender and associates it with the scene
  62980. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62981. * @returns the GeometryBufferRenderer
  62982. */
  62983. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62984. /**
  62985. * Disables the GeometryBufferRender associated with the scene
  62986. */
  62987. disableGeometryBufferRenderer(): void;
  62988. }
  62989. /**
  62990. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62991. * in several rendering techniques.
  62992. */
  62993. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62994. /**
  62995. * The component name helpful to identify the component in the list of scene components.
  62996. */
  62997. readonly name: string;
  62998. /**
  62999. * The scene the component belongs to.
  63000. */
  63001. scene: Scene;
  63002. /**
  63003. * Creates a new instance of the component for the given scene
  63004. * @param scene Defines the scene to register the component in
  63005. */
  63006. constructor(scene: Scene);
  63007. /**
  63008. * Registers the component in a given scene
  63009. */
  63010. register(): void;
  63011. /**
  63012. * Rebuilds the elements related to this component in case of
  63013. * context lost for instance.
  63014. */
  63015. rebuild(): void;
  63016. /**
  63017. * Disposes the component and the associated ressources
  63018. */
  63019. dispose(): void;
  63020. private _gatherRenderTargets;
  63021. }
  63022. }
  63023. declare module BABYLON {
  63024. /** @hidden */
  63025. export var motionBlurPixelShader: {
  63026. name: string;
  63027. shader: string;
  63028. };
  63029. }
  63030. declare module BABYLON {
  63031. /**
  63032. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63033. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63034. * As an example, all you have to do is to create the post-process:
  63035. * var mb = new BABYLON.MotionBlurPostProcess(
  63036. * 'mb', // The name of the effect.
  63037. * scene, // The scene containing the objects to blur according to their velocity.
  63038. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63039. * camera // The camera to apply the render pass to.
  63040. * );
  63041. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63042. */
  63043. export class MotionBlurPostProcess extends PostProcess {
  63044. /**
  63045. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63046. */
  63047. motionStrength: number;
  63048. /**
  63049. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63050. */
  63051. get motionBlurSamples(): number;
  63052. /**
  63053. * Sets the number of iterations to be used for motion blur quality
  63054. */
  63055. set motionBlurSamples(samples: number);
  63056. private _motionBlurSamples;
  63057. private _geometryBufferRenderer;
  63058. /**
  63059. * Creates a new instance MotionBlurPostProcess
  63060. * @param name The name of the effect.
  63061. * @param scene The scene containing the objects to blur according to their velocity.
  63062. * @param options The required width/height ratio to downsize to before computing the render pass.
  63063. * @param camera The camera to apply the render pass to.
  63064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63065. * @param engine The engine which the post process will be applied. (default: current engine)
  63066. * @param reusable If the post process can be reused on the same frame. (default: false)
  63067. * @param textureType Type of textures used when performing the post process. (default: 0)
  63068. * @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)
  63069. */
  63070. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63071. /**
  63072. * Excludes the given skinned mesh from computing bones velocities.
  63073. * 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.
  63074. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63075. */
  63076. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63077. /**
  63078. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63079. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63080. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63081. */
  63082. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63083. /**
  63084. * Disposes the post process.
  63085. * @param camera The camera to dispose the post process on.
  63086. */
  63087. dispose(camera?: Camera): void;
  63088. }
  63089. }
  63090. declare module BABYLON {
  63091. /** @hidden */
  63092. export var refractionPixelShader: {
  63093. name: string;
  63094. shader: string;
  63095. };
  63096. }
  63097. declare module BABYLON {
  63098. /**
  63099. * Post process which applies a refractin texture
  63100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63101. */
  63102. export class RefractionPostProcess extends PostProcess {
  63103. /** the base color of the refraction (used to taint the rendering) */
  63104. color: Color3;
  63105. /** simulated refraction depth */
  63106. depth: number;
  63107. /** the coefficient of the base color (0 to remove base color tainting) */
  63108. colorLevel: number;
  63109. private _refTexture;
  63110. private _ownRefractionTexture;
  63111. /**
  63112. * Gets or sets the refraction texture
  63113. * Please note that you are responsible for disposing the texture if you set it manually
  63114. */
  63115. get refractionTexture(): Texture;
  63116. set refractionTexture(value: Texture);
  63117. /**
  63118. * Initializes the RefractionPostProcess
  63119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63120. * @param name The name of the effect.
  63121. * @param refractionTextureUrl Url of the refraction texture to use
  63122. * @param color the base color of the refraction (used to taint the rendering)
  63123. * @param depth simulated refraction depth
  63124. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63125. * @param camera The camera to apply the render pass to.
  63126. * @param options The required width/height ratio to downsize to before computing the render pass.
  63127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63128. * @param engine The engine which the post process will be applied. (default: current engine)
  63129. * @param reusable If the post process can be reused on the same frame. (default: false)
  63130. */
  63131. constructor(name: string, refractionTextureUrl: string,
  63132. /** the base color of the refraction (used to taint the rendering) */
  63133. color: Color3,
  63134. /** simulated refraction depth */
  63135. depth: number,
  63136. /** the coefficient of the base color (0 to remove base color tainting) */
  63137. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63138. /**
  63139. * Disposes of the post process
  63140. * @param camera Camera to dispose post process on
  63141. */
  63142. dispose(camera: Camera): void;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /** @hidden */
  63147. export var sharpenPixelShader: {
  63148. name: string;
  63149. shader: string;
  63150. };
  63151. }
  63152. declare module BABYLON {
  63153. /**
  63154. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63155. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63156. */
  63157. export class SharpenPostProcess extends PostProcess {
  63158. /**
  63159. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63160. */
  63161. colorAmount: number;
  63162. /**
  63163. * How much sharpness should be applied (default: 0.3)
  63164. */
  63165. edgeAmount: number;
  63166. /**
  63167. * Creates a new instance ConvolutionPostProcess
  63168. * @param name The name of the effect.
  63169. * @param options The required width/height ratio to downsize to before computing the render pass.
  63170. * @param camera The camera to apply the render pass to.
  63171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63172. * @param engine The engine which the post process will be applied. (default: current engine)
  63173. * @param reusable If the post process can be reused on the same frame. (default: false)
  63174. * @param textureType Type of textures used when performing the post process. (default: 0)
  63175. * @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)
  63176. */
  63177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63178. }
  63179. }
  63180. declare module BABYLON {
  63181. /**
  63182. * PostProcessRenderPipeline
  63183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63184. */
  63185. export class PostProcessRenderPipeline {
  63186. private engine;
  63187. private _renderEffects;
  63188. private _renderEffectsForIsolatedPass;
  63189. /**
  63190. * List of inspectable custom properties (used by the Inspector)
  63191. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63192. */
  63193. inspectableCustomProperties: IInspectable[];
  63194. /**
  63195. * @hidden
  63196. */
  63197. protected _cameras: Camera[];
  63198. /** @hidden */
  63199. _name: string;
  63200. /**
  63201. * Gets pipeline name
  63202. */
  63203. get name(): string;
  63204. /** Gets the list of attached cameras */
  63205. get cameras(): Camera[];
  63206. /**
  63207. * Initializes a PostProcessRenderPipeline
  63208. * @param engine engine to add the pipeline to
  63209. * @param name name of the pipeline
  63210. */
  63211. constructor(engine: Engine, name: string);
  63212. /**
  63213. * Gets the class name
  63214. * @returns "PostProcessRenderPipeline"
  63215. */
  63216. getClassName(): string;
  63217. /**
  63218. * If all the render effects in the pipeline are supported
  63219. */
  63220. get isSupported(): boolean;
  63221. /**
  63222. * Adds an effect to the pipeline
  63223. * @param renderEffect the effect to add
  63224. */
  63225. addEffect(renderEffect: PostProcessRenderEffect): void;
  63226. /** @hidden */
  63227. _rebuild(): void;
  63228. /** @hidden */
  63229. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63230. /** @hidden */
  63231. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63232. /** @hidden */
  63233. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63234. /** @hidden */
  63235. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63236. /** @hidden */
  63237. _attachCameras(cameras: Camera, unique: boolean): void;
  63238. /** @hidden */
  63239. _attachCameras(cameras: Camera[], unique: boolean): void;
  63240. /** @hidden */
  63241. _detachCameras(cameras: Camera): void;
  63242. /** @hidden */
  63243. _detachCameras(cameras: Nullable<Camera[]>): void;
  63244. /** @hidden */
  63245. _update(): void;
  63246. /** @hidden */
  63247. _reset(): void;
  63248. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63249. /**
  63250. * Disposes of the pipeline
  63251. */
  63252. dispose(): void;
  63253. }
  63254. }
  63255. declare module BABYLON {
  63256. /**
  63257. * PostProcessRenderPipelineManager class
  63258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63259. */
  63260. export class PostProcessRenderPipelineManager {
  63261. private _renderPipelines;
  63262. /**
  63263. * Initializes a PostProcessRenderPipelineManager
  63264. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63265. */
  63266. constructor();
  63267. /**
  63268. * Gets the list of supported render pipelines
  63269. */
  63270. get supportedPipelines(): PostProcessRenderPipeline[];
  63271. /**
  63272. * Adds a pipeline to the manager
  63273. * @param renderPipeline The pipeline to add
  63274. */
  63275. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63276. /**
  63277. * Attaches a camera to the pipeline
  63278. * @param renderPipelineName The name of the pipeline to attach to
  63279. * @param cameras the camera to attach
  63280. * @param unique if the camera can be attached multiple times to the pipeline
  63281. */
  63282. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63283. /**
  63284. * Detaches a camera from the pipeline
  63285. * @param renderPipelineName The name of the pipeline to detach from
  63286. * @param cameras the camera to detach
  63287. */
  63288. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63289. /**
  63290. * Enables an effect by name on a pipeline
  63291. * @param renderPipelineName the name of the pipeline to enable the effect in
  63292. * @param renderEffectName the name of the effect to enable
  63293. * @param cameras the cameras that the effect should be enabled on
  63294. */
  63295. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63296. /**
  63297. * Disables an effect by name on a pipeline
  63298. * @param renderPipelineName the name of the pipeline to disable the effect in
  63299. * @param renderEffectName the name of the effect to disable
  63300. * @param cameras the cameras that the effect should be disabled on
  63301. */
  63302. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63303. /**
  63304. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63305. */
  63306. update(): void;
  63307. /** @hidden */
  63308. _rebuild(): void;
  63309. /**
  63310. * Disposes of the manager and pipelines
  63311. */
  63312. dispose(): void;
  63313. }
  63314. }
  63315. declare module BABYLON {
  63316. interface Scene {
  63317. /** @hidden (Backing field) */
  63318. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63319. /**
  63320. * Gets the postprocess render pipeline manager
  63321. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63322. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63323. */
  63324. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63325. }
  63326. /**
  63327. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63328. */
  63329. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63330. /**
  63331. * The component name helpfull to identify the component in the list of scene components.
  63332. */
  63333. readonly name: string;
  63334. /**
  63335. * The scene the component belongs to.
  63336. */
  63337. scene: Scene;
  63338. /**
  63339. * Creates a new instance of the component for the given scene
  63340. * @param scene Defines the scene to register the component in
  63341. */
  63342. constructor(scene: Scene);
  63343. /**
  63344. * Registers the component in a given scene
  63345. */
  63346. register(): void;
  63347. /**
  63348. * Rebuilds the elements related to this component in case of
  63349. * context lost for instance.
  63350. */
  63351. rebuild(): void;
  63352. /**
  63353. * Disposes the component and the associated ressources
  63354. */
  63355. dispose(): void;
  63356. private _gatherRenderTargets;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63362. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63363. */
  63364. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63365. private _scene;
  63366. private _camerasToBeAttached;
  63367. /**
  63368. * ID of the sharpen post process,
  63369. */
  63370. private readonly SharpenPostProcessId;
  63371. /**
  63372. * @ignore
  63373. * ID of the image processing post process;
  63374. */
  63375. readonly ImageProcessingPostProcessId: string;
  63376. /**
  63377. * @ignore
  63378. * ID of the Fast Approximate Anti-Aliasing post process;
  63379. */
  63380. readonly FxaaPostProcessId: string;
  63381. /**
  63382. * ID of the chromatic aberration post process,
  63383. */
  63384. private readonly ChromaticAberrationPostProcessId;
  63385. /**
  63386. * ID of the grain post process
  63387. */
  63388. private readonly GrainPostProcessId;
  63389. /**
  63390. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63391. */
  63392. sharpen: SharpenPostProcess;
  63393. private _sharpenEffect;
  63394. private bloom;
  63395. /**
  63396. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63397. */
  63398. depthOfField: DepthOfFieldEffect;
  63399. /**
  63400. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63401. */
  63402. fxaa: FxaaPostProcess;
  63403. /**
  63404. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63405. */
  63406. imageProcessing: ImageProcessingPostProcess;
  63407. /**
  63408. * Chromatic aberration post process which will shift rgb colors in the image
  63409. */
  63410. chromaticAberration: ChromaticAberrationPostProcess;
  63411. private _chromaticAberrationEffect;
  63412. /**
  63413. * Grain post process which add noise to the image
  63414. */
  63415. grain: GrainPostProcess;
  63416. private _grainEffect;
  63417. /**
  63418. * Glow post process which adds a glow to emissive areas of the image
  63419. */
  63420. private _glowLayer;
  63421. /**
  63422. * Animations which can be used to tweak settings over a period of time
  63423. */
  63424. animations: Animation[];
  63425. private _imageProcessingConfigurationObserver;
  63426. private _sharpenEnabled;
  63427. private _bloomEnabled;
  63428. private _depthOfFieldEnabled;
  63429. private _depthOfFieldBlurLevel;
  63430. private _fxaaEnabled;
  63431. private _imageProcessingEnabled;
  63432. private _defaultPipelineTextureType;
  63433. private _bloomScale;
  63434. private _chromaticAberrationEnabled;
  63435. private _grainEnabled;
  63436. private _buildAllowed;
  63437. /**
  63438. * Gets active scene
  63439. */
  63440. get scene(): Scene;
  63441. /**
  63442. * Enable or disable the sharpen process from the pipeline
  63443. */
  63444. set sharpenEnabled(enabled: boolean);
  63445. get sharpenEnabled(): boolean;
  63446. private _resizeObserver;
  63447. private _hardwareScaleLevel;
  63448. private _bloomKernel;
  63449. /**
  63450. * Specifies the size of the bloom blur kernel, relative to the final output size
  63451. */
  63452. get bloomKernel(): number;
  63453. set bloomKernel(value: number);
  63454. /**
  63455. * Specifies the weight of the bloom in the final rendering
  63456. */
  63457. private _bloomWeight;
  63458. /**
  63459. * Specifies the luma threshold for the area that will be blurred by the bloom
  63460. */
  63461. private _bloomThreshold;
  63462. private _hdr;
  63463. /**
  63464. * The strength of the bloom.
  63465. */
  63466. set bloomWeight(value: number);
  63467. get bloomWeight(): number;
  63468. /**
  63469. * The strength of the bloom.
  63470. */
  63471. set bloomThreshold(value: number);
  63472. get bloomThreshold(): number;
  63473. /**
  63474. * The scale of the bloom, lower value will provide better performance.
  63475. */
  63476. set bloomScale(value: number);
  63477. get bloomScale(): number;
  63478. /**
  63479. * Enable or disable the bloom from the pipeline
  63480. */
  63481. set bloomEnabled(enabled: boolean);
  63482. get bloomEnabled(): boolean;
  63483. private _rebuildBloom;
  63484. /**
  63485. * If the depth of field is enabled.
  63486. */
  63487. get depthOfFieldEnabled(): boolean;
  63488. set depthOfFieldEnabled(enabled: boolean);
  63489. /**
  63490. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63491. */
  63492. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63493. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63494. /**
  63495. * If the anti aliasing is enabled.
  63496. */
  63497. set fxaaEnabled(enabled: boolean);
  63498. get fxaaEnabled(): boolean;
  63499. private _samples;
  63500. /**
  63501. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63502. */
  63503. set samples(sampleCount: number);
  63504. get samples(): number;
  63505. /**
  63506. * If image processing is enabled.
  63507. */
  63508. set imageProcessingEnabled(enabled: boolean);
  63509. get imageProcessingEnabled(): boolean;
  63510. /**
  63511. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63512. */
  63513. set glowLayerEnabled(enabled: boolean);
  63514. get glowLayerEnabled(): boolean;
  63515. /**
  63516. * Gets the glow layer (or null if not defined)
  63517. */
  63518. get glowLayer(): Nullable<GlowLayer>;
  63519. /**
  63520. * Enable or disable the chromaticAberration process from the pipeline
  63521. */
  63522. set chromaticAberrationEnabled(enabled: boolean);
  63523. get chromaticAberrationEnabled(): boolean;
  63524. /**
  63525. * Enable or disable the grain process from the pipeline
  63526. */
  63527. set grainEnabled(enabled: boolean);
  63528. get grainEnabled(): boolean;
  63529. /**
  63530. * @constructor
  63531. * @param name - The rendering pipeline name (default: "")
  63532. * @param hdr - If high dynamic range textures should be used (default: true)
  63533. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63534. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63535. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63536. */
  63537. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63538. /**
  63539. * Get the class name
  63540. * @returns "DefaultRenderingPipeline"
  63541. */
  63542. getClassName(): string;
  63543. /**
  63544. * Force the compilation of the entire pipeline.
  63545. */
  63546. prepare(): void;
  63547. private _hasCleared;
  63548. private _prevPostProcess;
  63549. private _prevPrevPostProcess;
  63550. private _setAutoClearAndTextureSharing;
  63551. private _depthOfFieldSceneObserver;
  63552. private _buildPipeline;
  63553. private _disposePostProcesses;
  63554. /**
  63555. * Adds a camera to the pipeline
  63556. * @param camera the camera to be added
  63557. */
  63558. addCamera(camera: Camera): void;
  63559. /**
  63560. * Removes a camera from the pipeline
  63561. * @param camera the camera to remove
  63562. */
  63563. removeCamera(camera: Camera): void;
  63564. /**
  63565. * Dispose of the pipeline and stop all post processes
  63566. */
  63567. dispose(): void;
  63568. /**
  63569. * Serialize the rendering pipeline (Used when exporting)
  63570. * @returns the serialized object
  63571. */
  63572. serialize(): any;
  63573. /**
  63574. * Parse the serialized pipeline
  63575. * @param source Source pipeline.
  63576. * @param scene The scene to load the pipeline to.
  63577. * @param rootUrl The URL of the serialized pipeline.
  63578. * @returns An instantiated pipeline from the serialized object.
  63579. */
  63580. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63581. }
  63582. }
  63583. declare module BABYLON {
  63584. /** @hidden */
  63585. export var lensHighlightsPixelShader: {
  63586. name: string;
  63587. shader: string;
  63588. };
  63589. }
  63590. declare module BABYLON {
  63591. /** @hidden */
  63592. export var depthOfFieldPixelShader: {
  63593. name: string;
  63594. shader: string;
  63595. };
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * BABYLON.JS Chromatic Aberration GLSL Shader
  63600. * Author: Olivier Guyot
  63601. * Separates very slightly R, G and B colors on the edges of the screen
  63602. * Inspired by Francois Tarlier & Martins Upitis
  63603. */
  63604. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63605. /**
  63606. * @ignore
  63607. * The chromatic aberration PostProcess id in the pipeline
  63608. */
  63609. LensChromaticAberrationEffect: string;
  63610. /**
  63611. * @ignore
  63612. * The highlights enhancing PostProcess id in the pipeline
  63613. */
  63614. HighlightsEnhancingEffect: string;
  63615. /**
  63616. * @ignore
  63617. * The depth-of-field PostProcess id in the pipeline
  63618. */
  63619. LensDepthOfFieldEffect: string;
  63620. private _scene;
  63621. private _depthTexture;
  63622. private _grainTexture;
  63623. private _chromaticAberrationPostProcess;
  63624. private _highlightsPostProcess;
  63625. private _depthOfFieldPostProcess;
  63626. private _edgeBlur;
  63627. private _grainAmount;
  63628. private _chromaticAberration;
  63629. private _distortion;
  63630. private _highlightsGain;
  63631. private _highlightsThreshold;
  63632. private _dofDistance;
  63633. private _dofAperture;
  63634. private _dofDarken;
  63635. private _dofPentagon;
  63636. private _blurNoise;
  63637. /**
  63638. * @constructor
  63639. *
  63640. * Effect parameters are as follow:
  63641. * {
  63642. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63643. * edge_blur: number; // from 0 to x (1 for realism)
  63644. * distortion: number; // from 0 to x (1 for realism)
  63645. * grain_amount: number; // from 0 to 1
  63646. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63647. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63648. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63649. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63650. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63651. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63652. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63653. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63654. * }
  63655. * Note: if an effect parameter is unset, effect is disabled
  63656. *
  63657. * @param name The rendering pipeline name
  63658. * @param parameters - An object containing all parameters (see above)
  63659. * @param scene The scene linked to this pipeline
  63660. * @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)
  63661. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63662. */
  63663. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63664. /**
  63665. * Get the class name
  63666. * @returns "LensRenderingPipeline"
  63667. */
  63668. getClassName(): string;
  63669. /**
  63670. * Gets associated scene
  63671. */
  63672. get scene(): Scene;
  63673. /**
  63674. * Gets or sets the edge blur
  63675. */
  63676. get edgeBlur(): number;
  63677. set edgeBlur(value: number);
  63678. /**
  63679. * Gets or sets the grain amount
  63680. */
  63681. get grainAmount(): number;
  63682. set grainAmount(value: number);
  63683. /**
  63684. * Gets or sets the chromatic aberration amount
  63685. */
  63686. get chromaticAberration(): number;
  63687. set chromaticAberration(value: number);
  63688. /**
  63689. * Gets or sets the depth of field aperture
  63690. */
  63691. get dofAperture(): number;
  63692. set dofAperture(value: number);
  63693. /**
  63694. * Gets or sets the edge distortion
  63695. */
  63696. get edgeDistortion(): number;
  63697. set edgeDistortion(value: number);
  63698. /**
  63699. * Gets or sets the depth of field distortion
  63700. */
  63701. get dofDistortion(): number;
  63702. set dofDistortion(value: number);
  63703. /**
  63704. * Gets or sets the darken out of focus amount
  63705. */
  63706. get darkenOutOfFocus(): number;
  63707. set darkenOutOfFocus(value: number);
  63708. /**
  63709. * Gets or sets a boolean indicating if blur noise is enabled
  63710. */
  63711. get blurNoise(): boolean;
  63712. set blurNoise(value: boolean);
  63713. /**
  63714. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63715. */
  63716. get pentagonBokeh(): boolean;
  63717. set pentagonBokeh(value: boolean);
  63718. /**
  63719. * Gets or sets the highlight grain amount
  63720. */
  63721. get highlightsGain(): number;
  63722. set highlightsGain(value: number);
  63723. /**
  63724. * Gets or sets the highlight threshold
  63725. */
  63726. get highlightsThreshold(): number;
  63727. set highlightsThreshold(value: number);
  63728. /**
  63729. * Sets the amount of blur at the edges
  63730. * @param amount blur amount
  63731. */
  63732. setEdgeBlur(amount: number): void;
  63733. /**
  63734. * Sets edge blur to 0
  63735. */
  63736. disableEdgeBlur(): void;
  63737. /**
  63738. * Sets the amout of grain
  63739. * @param amount Amount of grain
  63740. */
  63741. setGrainAmount(amount: number): void;
  63742. /**
  63743. * Set grain amount to 0
  63744. */
  63745. disableGrain(): void;
  63746. /**
  63747. * Sets the chromatic aberration amount
  63748. * @param amount amount of chromatic aberration
  63749. */
  63750. setChromaticAberration(amount: number): void;
  63751. /**
  63752. * Sets chromatic aberration amount to 0
  63753. */
  63754. disableChromaticAberration(): void;
  63755. /**
  63756. * Sets the EdgeDistortion amount
  63757. * @param amount amount of EdgeDistortion
  63758. */
  63759. setEdgeDistortion(amount: number): void;
  63760. /**
  63761. * Sets edge distortion to 0
  63762. */
  63763. disableEdgeDistortion(): void;
  63764. /**
  63765. * Sets the FocusDistance amount
  63766. * @param amount amount of FocusDistance
  63767. */
  63768. setFocusDistance(amount: number): void;
  63769. /**
  63770. * Disables depth of field
  63771. */
  63772. disableDepthOfField(): void;
  63773. /**
  63774. * Sets the Aperture amount
  63775. * @param amount amount of Aperture
  63776. */
  63777. setAperture(amount: number): void;
  63778. /**
  63779. * Sets the DarkenOutOfFocus amount
  63780. * @param amount amount of DarkenOutOfFocus
  63781. */
  63782. setDarkenOutOfFocus(amount: number): void;
  63783. private _pentagonBokehIsEnabled;
  63784. /**
  63785. * Creates a pentagon bokeh effect
  63786. */
  63787. enablePentagonBokeh(): void;
  63788. /**
  63789. * Disables the pentagon bokeh effect
  63790. */
  63791. disablePentagonBokeh(): void;
  63792. /**
  63793. * Enables noise blur
  63794. */
  63795. enableNoiseBlur(): void;
  63796. /**
  63797. * Disables noise blur
  63798. */
  63799. disableNoiseBlur(): void;
  63800. /**
  63801. * Sets the HighlightsGain amount
  63802. * @param amount amount of HighlightsGain
  63803. */
  63804. setHighlightsGain(amount: number): void;
  63805. /**
  63806. * Sets the HighlightsThreshold amount
  63807. * @param amount amount of HighlightsThreshold
  63808. */
  63809. setHighlightsThreshold(amount: number): void;
  63810. /**
  63811. * Disables highlights
  63812. */
  63813. disableHighlights(): void;
  63814. /**
  63815. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63816. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63817. */
  63818. dispose(disableDepthRender?: boolean): void;
  63819. private _createChromaticAberrationPostProcess;
  63820. private _createHighlightsPostProcess;
  63821. private _createDepthOfFieldPostProcess;
  63822. private _createGrainTexture;
  63823. }
  63824. }
  63825. declare module BABYLON {
  63826. /** @hidden */
  63827. export var ssao2PixelShader: {
  63828. name: string;
  63829. shader: string;
  63830. };
  63831. }
  63832. declare module BABYLON {
  63833. /** @hidden */
  63834. export var ssaoCombinePixelShader: {
  63835. name: string;
  63836. shader: string;
  63837. };
  63838. }
  63839. declare module BABYLON {
  63840. /**
  63841. * Render pipeline to produce ssao effect
  63842. */
  63843. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63844. /**
  63845. * @ignore
  63846. * The PassPostProcess id in the pipeline that contains the original scene color
  63847. */
  63848. SSAOOriginalSceneColorEffect: string;
  63849. /**
  63850. * @ignore
  63851. * The SSAO PostProcess id in the pipeline
  63852. */
  63853. SSAORenderEffect: string;
  63854. /**
  63855. * @ignore
  63856. * The horizontal blur PostProcess id in the pipeline
  63857. */
  63858. SSAOBlurHRenderEffect: string;
  63859. /**
  63860. * @ignore
  63861. * The vertical blur PostProcess id in the pipeline
  63862. */
  63863. SSAOBlurVRenderEffect: string;
  63864. /**
  63865. * @ignore
  63866. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63867. */
  63868. SSAOCombineRenderEffect: string;
  63869. /**
  63870. * The output strength of the SSAO post-process. Default value is 1.0.
  63871. */
  63872. totalStrength: number;
  63873. /**
  63874. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63875. */
  63876. maxZ: number;
  63877. /**
  63878. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63879. */
  63880. minZAspect: number;
  63881. private _samples;
  63882. /**
  63883. * Number of samples used for the SSAO calculations. Default value is 8
  63884. */
  63885. set samples(n: number);
  63886. get samples(): number;
  63887. private _textureSamples;
  63888. /**
  63889. * Number of samples to use for antialiasing
  63890. */
  63891. set textureSamples(n: number);
  63892. get textureSamples(): number;
  63893. /**
  63894. * Ratio object used for SSAO ratio and blur ratio
  63895. */
  63896. private _ratio;
  63897. /**
  63898. * Dynamically generated sphere sampler.
  63899. */
  63900. private _sampleSphere;
  63901. /**
  63902. * Blur filter offsets
  63903. */
  63904. private _samplerOffsets;
  63905. private _expensiveBlur;
  63906. /**
  63907. * If bilateral blur should be used
  63908. */
  63909. set expensiveBlur(b: boolean);
  63910. get expensiveBlur(): boolean;
  63911. /**
  63912. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63913. */
  63914. radius: number;
  63915. /**
  63916. * The base color of the SSAO post-process
  63917. * The final result is "base + ssao" between [0, 1]
  63918. */
  63919. base: number;
  63920. /**
  63921. * Support test.
  63922. */
  63923. static get IsSupported(): boolean;
  63924. private _scene;
  63925. private _depthTexture;
  63926. private _normalTexture;
  63927. private _randomTexture;
  63928. private _originalColorPostProcess;
  63929. private _ssaoPostProcess;
  63930. private _blurHPostProcess;
  63931. private _blurVPostProcess;
  63932. private _ssaoCombinePostProcess;
  63933. /**
  63934. * Gets active scene
  63935. */
  63936. get scene(): Scene;
  63937. /**
  63938. * @constructor
  63939. * @param name The rendering pipeline name
  63940. * @param scene The scene linked to this pipeline
  63941. * @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 }
  63942. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63943. */
  63944. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63945. /**
  63946. * Get the class name
  63947. * @returns "SSAO2RenderingPipeline"
  63948. */
  63949. getClassName(): string;
  63950. /**
  63951. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63952. */
  63953. dispose(disableGeometryBufferRenderer?: boolean): void;
  63954. private _createBlurPostProcess;
  63955. /** @hidden */
  63956. _rebuild(): void;
  63957. private _bits;
  63958. private _radicalInverse_VdC;
  63959. private _hammersley;
  63960. private _hemisphereSample_uniform;
  63961. private _generateHemisphere;
  63962. private _createSSAOPostProcess;
  63963. private _createSSAOCombinePostProcess;
  63964. private _createRandomTexture;
  63965. /**
  63966. * Serialize the rendering pipeline (Used when exporting)
  63967. * @returns the serialized object
  63968. */
  63969. serialize(): any;
  63970. /**
  63971. * Parse the serialized pipeline
  63972. * @param source Source pipeline.
  63973. * @param scene The scene to load the pipeline to.
  63974. * @param rootUrl The URL of the serialized pipeline.
  63975. * @returns An instantiated pipeline from the serialized object.
  63976. */
  63977. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63978. }
  63979. }
  63980. declare module BABYLON {
  63981. /** @hidden */
  63982. export var ssaoPixelShader: {
  63983. name: string;
  63984. shader: string;
  63985. };
  63986. }
  63987. declare module BABYLON {
  63988. /**
  63989. * Render pipeline to produce ssao effect
  63990. */
  63991. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63992. /**
  63993. * @ignore
  63994. * The PassPostProcess id in the pipeline that contains the original scene color
  63995. */
  63996. SSAOOriginalSceneColorEffect: string;
  63997. /**
  63998. * @ignore
  63999. * The SSAO PostProcess id in the pipeline
  64000. */
  64001. SSAORenderEffect: string;
  64002. /**
  64003. * @ignore
  64004. * The horizontal blur PostProcess id in the pipeline
  64005. */
  64006. SSAOBlurHRenderEffect: string;
  64007. /**
  64008. * @ignore
  64009. * The vertical blur PostProcess id in the pipeline
  64010. */
  64011. SSAOBlurVRenderEffect: string;
  64012. /**
  64013. * @ignore
  64014. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64015. */
  64016. SSAOCombineRenderEffect: string;
  64017. /**
  64018. * The output strength of the SSAO post-process. Default value is 1.0.
  64019. */
  64020. totalStrength: number;
  64021. /**
  64022. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64023. */
  64024. radius: number;
  64025. /**
  64026. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64027. * Must not be equal to fallOff and superior to fallOff.
  64028. * Default value is 0.0075
  64029. */
  64030. area: number;
  64031. /**
  64032. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64033. * Must not be equal to area and inferior to area.
  64034. * Default value is 0.000001
  64035. */
  64036. fallOff: number;
  64037. /**
  64038. * The base color of the SSAO post-process
  64039. * The final result is "base + ssao" between [0, 1]
  64040. */
  64041. base: number;
  64042. private _scene;
  64043. private _depthTexture;
  64044. private _randomTexture;
  64045. private _originalColorPostProcess;
  64046. private _ssaoPostProcess;
  64047. private _blurHPostProcess;
  64048. private _blurVPostProcess;
  64049. private _ssaoCombinePostProcess;
  64050. private _firstUpdate;
  64051. /**
  64052. * Gets active scene
  64053. */
  64054. get scene(): Scene;
  64055. /**
  64056. * @constructor
  64057. * @param name - The rendering pipeline name
  64058. * @param scene - The scene linked to this pipeline
  64059. * @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 }
  64060. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64061. */
  64062. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64063. /**
  64064. * Get the class name
  64065. * @returns "SSAORenderingPipeline"
  64066. */
  64067. getClassName(): string;
  64068. /**
  64069. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64070. */
  64071. dispose(disableDepthRender?: boolean): void;
  64072. private _createBlurPostProcess;
  64073. /** @hidden */
  64074. _rebuild(): void;
  64075. private _createSSAOPostProcess;
  64076. private _createSSAOCombinePostProcess;
  64077. private _createRandomTexture;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /** @hidden */
  64082. export var standardPixelShader: {
  64083. name: string;
  64084. shader: string;
  64085. };
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * Standard rendering pipeline
  64090. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64091. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64092. */
  64093. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64094. /**
  64095. * Public members
  64096. */
  64097. /**
  64098. * Post-process which contains the original scene color before the pipeline applies all the effects
  64099. */
  64100. originalPostProcess: Nullable<PostProcess>;
  64101. /**
  64102. * Post-process used to down scale an image x4
  64103. */
  64104. downSampleX4PostProcess: Nullable<PostProcess>;
  64105. /**
  64106. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64107. */
  64108. brightPassPostProcess: Nullable<PostProcess>;
  64109. /**
  64110. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64111. */
  64112. blurHPostProcesses: PostProcess[];
  64113. /**
  64114. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64115. */
  64116. blurVPostProcesses: PostProcess[];
  64117. /**
  64118. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64119. */
  64120. textureAdderPostProcess: Nullable<PostProcess>;
  64121. /**
  64122. * Post-process used to create volumetric lighting effect
  64123. */
  64124. volumetricLightPostProcess: Nullable<PostProcess>;
  64125. /**
  64126. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64127. */
  64128. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64129. /**
  64130. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64131. */
  64132. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64133. /**
  64134. * Post-process used to merge the volumetric light effect and the real scene color
  64135. */
  64136. volumetricLightMergePostProces: Nullable<PostProcess>;
  64137. /**
  64138. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64139. */
  64140. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64141. /**
  64142. * Base post-process used to calculate the average luminance of the final image for HDR
  64143. */
  64144. luminancePostProcess: Nullable<PostProcess>;
  64145. /**
  64146. * Post-processes used to create down sample post-processes in order to get
  64147. * the average luminance of the final image for HDR
  64148. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64149. */
  64150. luminanceDownSamplePostProcesses: PostProcess[];
  64151. /**
  64152. * Post-process used to create a HDR effect (light adaptation)
  64153. */
  64154. hdrPostProcess: Nullable<PostProcess>;
  64155. /**
  64156. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64157. */
  64158. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64159. /**
  64160. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64161. */
  64162. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64163. /**
  64164. * Post-process used to merge the final HDR post-process and the real scene color
  64165. */
  64166. hdrFinalPostProcess: Nullable<PostProcess>;
  64167. /**
  64168. * Post-process used to create a lens flare effect
  64169. */
  64170. lensFlarePostProcess: Nullable<PostProcess>;
  64171. /**
  64172. * Post-process that merges the result of the lens flare post-process and the real scene color
  64173. */
  64174. lensFlareComposePostProcess: Nullable<PostProcess>;
  64175. /**
  64176. * Post-process used to create a motion blur effect
  64177. */
  64178. motionBlurPostProcess: Nullable<PostProcess>;
  64179. /**
  64180. * Post-process used to create a depth of field effect
  64181. */
  64182. depthOfFieldPostProcess: Nullable<PostProcess>;
  64183. /**
  64184. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64185. */
  64186. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64187. /**
  64188. * Represents the brightness threshold in order to configure the illuminated surfaces
  64189. */
  64190. brightThreshold: number;
  64191. /**
  64192. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64193. */
  64194. blurWidth: number;
  64195. /**
  64196. * Sets if the blur for highlighted surfaces must be only horizontal
  64197. */
  64198. horizontalBlur: boolean;
  64199. /**
  64200. * Gets the overall exposure used by the pipeline
  64201. */
  64202. get exposure(): number;
  64203. /**
  64204. * Sets the overall exposure used by the pipeline
  64205. */
  64206. set exposure(value: number);
  64207. /**
  64208. * Texture used typically to simulate "dirty" on camera lens
  64209. */
  64210. lensTexture: Nullable<Texture>;
  64211. /**
  64212. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64213. */
  64214. volumetricLightCoefficient: number;
  64215. /**
  64216. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64217. */
  64218. volumetricLightPower: number;
  64219. /**
  64220. * Used the set the blur intensity to smooth the volumetric lights
  64221. */
  64222. volumetricLightBlurScale: number;
  64223. /**
  64224. * Light (spot or directional) used to generate the volumetric lights rays
  64225. * The source light must have a shadow generate so the pipeline can get its
  64226. * depth map
  64227. */
  64228. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64229. /**
  64230. * For eye adaptation, represents the minimum luminance the eye can see
  64231. */
  64232. hdrMinimumLuminance: number;
  64233. /**
  64234. * For eye adaptation, represents the decrease luminance speed
  64235. */
  64236. hdrDecreaseRate: number;
  64237. /**
  64238. * For eye adaptation, represents the increase luminance speed
  64239. */
  64240. hdrIncreaseRate: number;
  64241. /**
  64242. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64243. */
  64244. get hdrAutoExposure(): boolean;
  64245. /**
  64246. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64247. */
  64248. set hdrAutoExposure(value: boolean);
  64249. /**
  64250. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64251. */
  64252. lensColorTexture: Nullable<Texture>;
  64253. /**
  64254. * The overall strengh for the lens flare effect
  64255. */
  64256. lensFlareStrength: number;
  64257. /**
  64258. * Dispersion coefficient for lens flare ghosts
  64259. */
  64260. lensFlareGhostDispersal: number;
  64261. /**
  64262. * Main lens flare halo width
  64263. */
  64264. lensFlareHaloWidth: number;
  64265. /**
  64266. * Based on the lens distortion effect, defines how much the lens flare result
  64267. * is distorted
  64268. */
  64269. lensFlareDistortionStrength: number;
  64270. /**
  64271. * Configures the blur intensity used for for lens flare (halo)
  64272. */
  64273. lensFlareBlurWidth: number;
  64274. /**
  64275. * Lens star texture must be used to simulate rays on the flares and is available
  64276. * in the documentation
  64277. */
  64278. lensStarTexture: Nullable<Texture>;
  64279. /**
  64280. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64281. * flare effect by taking account of the dirt texture
  64282. */
  64283. lensFlareDirtTexture: Nullable<Texture>;
  64284. /**
  64285. * Represents the focal length for the depth of field effect
  64286. */
  64287. depthOfFieldDistance: number;
  64288. /**
  64289. * Represents the blur intensity for the blurred part of the depth of field effect
  64290. */
  64291. depthOfFieldBlurWidth: number;
  64292. /**
  64293. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64294. */
  64295. get motionStrength(): number;
  64296. /**
  64297. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64298. */
  64299. set motionStrength(strength: number);
  64300. /**
  64301. * Gets wether or not the motion blur post-process is object based or screen based.
  64302. */
  64303. get objectBasedMotionBlur(): boolean;
  64304. /**
  64305. * Sets wether or not the motion blur post-process should be object based or screen based
  64306. */
  64307. set objectBasedMotionBlur(value: boolean);
  64308. /**
  64309. * List of animations for the pipeline (IAnimatable implementation)
  64310. */
  64311. animations: Animation[];
  64312. /**
  64313. * Private members
  64314. */
  64315. private _scene;
  64316. private _currentDepthOfFieldSource;
  64317. private _basePostProcess;
  64318. private _fixedExposure;
  64319. private _currentExposure;
  64320. private _hdrAutoExposure;
  64321. private _hdrCurrentLuminance;
  64322. private _motionStrength;
  64323. private _isObjectBasedMotionBlur;
  64324. private _floatTextureType;
  64325. private _camerasToBeAttached;
  64326. private _ratio;
  64327. private _bloomEnabled;
  64328. private _depthOfFieldEnabled;
  64329. private _vlsEnabled;
  64330. private _lensFlareEnabled;
  64331. private _hdrEnabled;
  64332. private _motionBlurEnabled;
  64333. private _fxaaEnabled;
  64334. private _motionBlurSamples;
  64335. private _volumetricLightStepsCount;
  64336. private _samples;
  64337. /**
  64338. * @ignore
  64339. * Specifies if the bloom pipeline is enabled
  64340. */
  64341. get BloomEnabled(): boolean;
  64342. set BloomEnabled(enabled: boolean);
  64343. /**
  64344. * @ignore
  64345. * Specifies if the depth of field pipeline is enabed
  64346. */
  64347. get DepthOfFieldEnabled(): boolean;
  64348. set DepthOfFieldEnabled(enabled: boolean);
  64349. /**
  64350. * @ignore
  64351. * Specifies if the lens flare pipeline is enabed
  64352. */
  64353. get LensFlareEnabled(): boolean;
  64354. set LensFlareEnabled(enabled: boolean);
  64355. /**
  64356. * @ignore
  64357. * Specifies if the HDR pipeline is enabled
  64358. */
  64359. get HDREnabled(): boolean;
  64360. set HDREnabled(enabled: boolean);
  64361. /**
  64362. * @ignore
  64363. * Specifies if the volumetric lights scattering effect is enabled
  64364. */
  64365. get VLSEnabled(): boolean;
  64366. set VLSEnabled(enabled: boolean);
  64367. /**
  64368. * @ignore
  64369. * Specifies if the motion blur effect is enabled
  64370. */
  64371. get MotionBlurEnabled(): boolean;
  64372. set MotionBlurEnabled(enabled: boolean);
  64373. /**
  64374. * Specifies if anti-aliasing is enabled
  64375. */
  64376. get fxaaEnabled(): boolean;
  64377. set fxaaEnabled(enabled: boolean);
  64378. /**
  64379. * Specifies the number of steps used to calculate the volumetric lights
  64380. * Typically in interval [50, 200]
  64381. */
  64382. get volumetricLightStepsCount(): number;
  64383. set volumetricLightStepsCount(count: number);
  64384. /**
  64385. * Specifies the number of samples used for the motion blur effect
  64386. * Typically in interval [16, 64]
  64387. */
  64388. get motionBlurSamples(): number;
  64389. set motionBlurSamples(samples: number);
  64390. /**
  64391. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64392. */
  64393. get samples(): number;
  64394. set samples(sampleCount: number);
  64395. /**
  64396. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64397. * @constructor
  64398. * @param name The rendering pipeline name
  64399. * @param scene The scene linked to this pipeline
  64400. * @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)
  64401. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64402. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64403. */
  64404. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64405. private _buildPipeline;
  64406. private _createDownSampleX4PostProcess;
  64407. private _createBrightPassPostProcess;
  64408. private _createBlurPostProcesses;
  64409. private _createTextureAdderPostProcess;
  64410. private _createVolumetricLightPostProcess;
  64411. private _createLuminancePostProcesses;
  64412. private _createHdrPostProcess;
  64413. private _createLensFlarePostProcess;
  64414. private _createDepthOfFieldPostProcess;
  64415. private _createMotionBlurPostProcess;
  64416. private _getDepthTexture;
  64417. private _disposePostProcesses;
  64418. /**
  64419. * Dispose of the pipeline and stop all post processes
  64420. */
  64421. dispose(): void;
  64422. /**
  64423. * Serialize the rendering pipeline (Used when exporting)
  64424. * @returns the serialized object
  64425. */
  64426. serialize(): any;
  64427. /**
  64428. * Parse the serialized pipeline
  64429. * @param source Source pipeline.
  64430. * @param scene The scene to load the pipeline to.
  64431. * @param rootUrl The URL of the serialized pipeline.
  64432. * @returns An instantiated pipeline from the serialized object.
  64433. */
  64434. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64435. /**
  64436. * Luminance steps
  64437. */
  64438. static LuminanceSteps: number;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /** @hidden */
  64443. export var tonemapPixelShader: {
  64444. name: string;
  64445. shader: string;
  64446. };
  64447. }
  64448. declare module BABYLON {
  64449. /** Defines operator used for tonemapping */
  64450. export enum TonemappingOperator {
  64451. /** Hable */
  64452. Hable = 0,
  64453. /** Reinhard */
  64454. Reinhard = 1,
  64455. /** HejiDawson */
  64456. HejiDawson = 2,
  64457. /** Photographic */
  64458. Photographic = 3
  64459. }
  64460. /**
  64461. * Defines a post process to apply tone mapping
  64462. */
  64463. export class TonemapPostProcess extends PostProcess {
  64464. private _operator;
  64465. /** Defines the required exposure adjustement */
  64466. exposureAdjustment: number;
  64467. /**
  64468. * Creates a new TonemapPostProcess
  64469. * @param name defines the name of the postprocess
  64470. * @param _operator defines the operator to use
  64471. * @param exposureAdjustment defines the required exposure adjustement
  64472. * @param camera defines the camera to use (can be null)
  64473. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64474. * @param engine defines the hosting engine (can be ignore if camera is set)
  64475. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64476. */
  64477. constructor(name: string, _operator: TonemappingOperator,
  64478. /** Defines the required exposure adjustement */
  64479. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64480. }
  64481. }
  64482. declare module BABYLON {
  64483. /** @hidden */
  64484. export var depthVertexShader: {
  64485. name: string;
  64486. shader: string;
  64487. };
  64488. }
  64489. declare module BABYLON {
  64490. /** @hidden */
  64491. export var volumetricLightScatteringPixelShader: {
  64492. name: string;
  64493. shader: string;
  64494. };
  64495. }
  64496. declare module BABYLON {
  64497. /** @hidden */
  64498. export var volumetricLightScatteringPassVertexShader: {
  64499. name: string;
  64500. shader: string;
  64501. };
  64502. }
  64503. declare module BABYLON {
  64504. /** @hidden */
  64505. export var volumetricLightScatteringPassPixelShader: {
  64506. name: string;
  64507. shader: string;
  64508. };
  64509. }
  64510. declare module BABYLON {
  64511. /**
  64512. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64513. */
  64514. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64515. private _volumetricLightScatteringPass;
  64516. private _volumetricLightScatteringRTT;
  64517. private _viewPort;
  64518. private _screenCoordinates;
  64519. private _cachedDefines;
  64520. /**
  64521. * If not undefined, the mesh position is computed from the attached node position
  64522. */
  64523. attachedNode: {
  64524. position: Vector3;
  64525. };
  64526. /**
  64527. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64528. */
  64529. customMeshPosition: Vector3;
  64530. /**
  64531. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64532. */
  64533. useCustomMeshPosition: boolean;
  64534. /**
  64535. * If the post-process should inverse the light scattering direction
  64536. */
  64537. invert: boolean;
  64538. /**
  64539. * The internal mesh used by the post-process
  64540. */
  64541. mesh: Mesh;
  64542. /**
  64543. * @hidden
  64544. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64545. */
  64546. get useDiffuseColor(): boolean;
  64547. set useDiffuseColor(useDiffuseColor: boolean);
  64548. /**
  64549. * Array containing the excluded meshes not rendered in the internal pass
  64550. */
  64551. excludedMeshes: AbstractMesh[];
  64552. /**
  64553. * Controls the overall intensity of the post-process
  64554. */
  64555. exposure: number;
  64556. /**
  64557. * Dissipates each sample's contribution in range [0, 1]
  64558. */
  64559. decay: number;
  64560. /**
  64561. * Controls the overall intensity of each sample
  64562. */
  64563. weight: number;
  64564. /**
  64565. * Controls the density of each sample
  64566. */
  64567. density: number;
  64568. /**
  64569. * @constructor
  64570. * @param name The post-process name
  64571. * @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)
  64572. * @param camera The camera that the post-process will be attached to
  64573. * @param mesh The mesh used to create the light scattering
  64574. * @param samples The post-process quality, default 100
  64575. * @param samplingModeThe post-process filtering mode
  64576. * @param engine The babylon engine
  64577. * @param reusable If the post-process is reusable
  64578. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64579. */
  64580. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64581. /**
  64582. * Returns the string "VolumetricLightScatteringPostProcess"
  64583. * @returns "VolumetricLightScatteringPostProcess"
  64584. */
  64585. getClassName(): string;
  64586. private _isReady;
  64587. /**
  64588. * Sets the new light position for light scattering effect
  64589. * @param position The new custom light position
  64590. */
  64591. setCustomMeshPosition(position: Vector3): void;
  64592. /**
  64593. * Returns the light position for light scattering effect
  64594. * @return Vector3 The custom light position
  64595. */
  64596. getCustomMeshPosition(): Vector3;
  64597. /**
  64598. * Disposes the internal assets and detaches the post-process from the camera
  64599. */
  64600. dispose(camera: Camera): void;
  64601. /**
  64602. * Returns the render target texture used by the post-process
  64603. * @return the render target texture used by the post-process
  64604. */
  64605. getPass(): RenderTargetTexture;
  64606. private _meshExcluded;
  64607. private _createPass;
  64608. private _updateMeshScreenCoordinates;
  64609. /**
  64610. * Creates a default mesh for the Volumeric Light Scattering post-process
  64611. * @param name The mesh name
  64612. * @param scene The scene where to create the mesh
  64613. * @return the default mesh
  64614. */
  64615. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64616. }
  64617. }
  64618. declare module BABYLON {
  64619. interface Scene {
  64620. /** @hidden (Backing field) */
  64621. _boundingBoxRenderer: BoundingBoxRenderer;
  64622. /** @hidden (Backing field) */
  64623. _forceShowBoundingBoxes: boolean;
  64624. /**
  64625. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64626. */
  64627. forceShowBoundingBoxes: boolean;
  64628. /**
  64629. * Gets the bounding box renderer associated with the scene
  64630. * @returns a BoundingBoxRenderer
  64631. */
  64632. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64633. }
  64634. interface AbstractMesh {
  64635. /** @hidden (Backing field) */
  64636. _showBoundingBox: boolean;
  64637. /**
  64638. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64639. */
  64640. showBoundingBox: boolean;
  64641. }
  64642. /**
  64643. * Component responsible of rendering the bounding box of the meshes in a scene.
  64644. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64645. */
  64646. export class BoundingBoxRenderer implements ISceneComponent {
  64647. /**
  64648. * The component name helpfull to identify the component in the list of scene components.
  64649. */
  64650. readonly name: string;
  64651. /**
  64652. * The scene the component belongs to.
  64653. */
  64654. scene: Scene;
  64655. /**
  64656. * Color of the bounding box lines placed in front of an object
  64657. */
  64658. frontColor: Color3;
  64659. /**
  64660. * Color of the bounding box lines placed behind an object
  64661. */
  64662. backColor: Color3;
  64663. /**
  64664. * Defines if the renderer should show the back lines or not
  64665. */
  64666. showBackLines: boolean;
  64667. /**
  64668. * @hidden
  64669. */
  64670. renderList: SmartArray<BoundingBox>;
  64671. private _colorShader;
  64672. private _vertexBuffers;
  64673. private _indexBuffer;
  64674. private _fillIndexBuffer;
  64675. private _fillIndexData;
  64676. /**
  64677. * Instantiates a new bounding box renderer in a scene.
  64678. * @param scene the scene the renderer renders in
  64679. */
  64680. constructor(scene: Scene);
  64681. /**
  64682. * Registers the component in a given scene
  64683. */
  64684. register(): void;
  64685. private _evaluateSubMesh;
  64686. private _activeMesh;
  64687. private _prepareRessources;
  64688. private _createIndexBuffer;
  64689. /**
  64690. * Rebuilds the elements related to this component in case of
  64691. * context lost for instance.
  64692. */
  64693. rebuild(): void;
  64694. /**
  64695. * @hidden
  64696. */
  64697. reset(): void;
  64698. /**
  64699. * Render the bounding boxes of a specific rendering group
  64700. * @param renderingGroupId defines the rendering group to render
  64701. */
  64702. render(renderingGroupId: number): void;
  64703. /**
  64704. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64705. * @param mesh Define the mesh to render the occlusion bounding box for
  64706. */
  64707. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64708. /**
  64709. * Dispose and release the resources attached to this renderer.
  64710. */
  64711. dispose(): void;
  64712. }
  64713. }
  64714. declare module BABYLON {
  64715. /** @hidden */
  64716. export var depthPixelShader: {
  64717. name: string;
  64718. shader: string;
  64719. };
  64720. }
  64721. declare module BABYLON {
  64722. /**
  64723. * This represents a depth renderer in Babylon.
  64724. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64725. */
  64726. export class DepthRenderer {
  64727. private _scene;
  64728. private _depthMap;
  64729. private _effect;
  64730. private readonly _storeNonLinearDepth;
  64731. private readonly _clearColor;
  64732. /** Get if the depth renderer is using packed depth or not */
  64733. readonly isPacked: boolean;
  64734. private _cachedDefines;
  64735. private _camera;
  64736. /**
  64737. * Specifiess that the depth renderer will only be used within
  64738. * the camera it is created for.
  64739. * This can help forcing its rendering during the camera processing.
  64740. */
  64741. useOnlyInActiveCamera: boolean;
  64742. /** @hidden */
  64743. static _SceneComponentInitialization: (scene: Scene) => void;
  64744. /**
  64745. * Instantiates a depth renderer
  64746. * @param scene The scene the renderer belongs to
  64747. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64748. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64749. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64750. */
  64751. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64752. /**
  64753. * Creates the depth rendering effect and checks if the effect is ready.
  64754. * @param subMesh The submesh to be used to render the depth map of
  64755. * @param useInstances If multiple world instances should be used
  64756. * @returns if the depth renderer is ready to render the depth map
  64757. */
  64758. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64759. /**
  64760. * Gets the texture which the depth map will be written to.
  64761. * @returns The depth map texture
  64762. */
  64763. getDepthMap(): RenderTargetTexture;
  64764. /**
  64765. * Disposes of the depth renderer.
  64766. */
  64767. dispose(): void;
  64768. }
  64769. }
  64770. declare module BABYLON {
  64771. interface Scene {
  64772. /** @hidden (Backing field) */
  64773. _depthRenderer: {
  64774. [id: string]: DepthRenderer;
  64775. };
  64776. /**
  64777. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64778. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64779. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64780. * @returns the created depth renderer
  64781. */
  64782. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64783. /**
  64784. * Disables a depth renderer for a given camera
  64785. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64786. */
  64787. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64788. }
  64789. /**
  64790. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64791. * in several rendering techniques.
  64792. */
  64793. export class DepthRendererSceneComponent implements ISceneComponent {
  64794. /**
  64795. * The component name helpfull to identify the component in the list of scene components.
  64796. */
  64797. readonly name: string;
  64798. /**
  64799. * The scene the component belongs to.
  64800. */
  64801. scene: Scene;
  64802. /**
  64803. * Creates a new instance of the component for the given scene
  64804. * @param scene Defines the scene to register the component in
  64805. */
  64806. constructor(scene: Scene);
  64807. /**
  64808. * Registers the component in a given scene
  64809. */
  64810. register(): void;
  64811. /**
  64812. * Rebuilds the elements related to this component in case of
  64813. * context lost for instance.
  64814. */
  64815. rebuild(): void;
  64816. /**
  64817. * Disposes the component and the associated ressources
  64818. */
  64819. dispose(): void;
  64820. private _gatherRenderTargets;
  64821. private _gatherActiveCameraRenderTargets;
  64822. }
  64823. }
  64824. declare module BABYLON {
  64825. /** @hidden */
  64826. export var outlinePixelShader: {
  64827. name: string;
  64828. shader: string;
  64829. };
  64830. }
  64831. declare module BABYLON {
  64832. /** @hidden */
  64833. export var outlineVertexShader: {
  64834. name: string;
  64835. shader: string;
  64836. };
  64837. }
  64838. declare module BABYLON {
  64839. interface Scene {
  64840. /** @hidden */
  64841. _outlineRenderer: OutlineRenderer;
  64842. /**
  64843. * Gets the outline renderer associated with the scene
  64844. * @returns a OutlineRenderer
  64845. */
  64846. getOutlineRenderer(): OutlineRenderer;
  64847. }
  64848. interface AbstractMesh {
  64849. /** @hidden (Backing field) */
  64850. _renderOutline: boolean;
  64851. /**
  64852. * Gets or sets a boolean indicating if the outline must be rendered as well
  64853. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64854. */
  64855. renderOutline: boolean;
  64856. /** @hidden (Backing field) */
  64857. _renderOverlay: boolean;
  64858. /**
  64859. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64860. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64861. */
  64862. renderOverlay: boolean;
  64863. }
  64864. /**
  64865. * This class is responsible to draw bothe outline/overlay of meshes.
  64866. * It should not be used directly but through the available method on mesh.
  64867. */
  64868. export class OutlineRenderer implements ISceneComponent {
  64869. /**
  64870. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64871. */
  64872. private static _StencilReference;
  64873. /**
  64874. * The name of the component. Each component must have a unique name.
  64875. */
  64876. name: string;
  64877. /**
  64878. * The scene the component belongs to.
  64879. */
  64880. scene: Scene;
  64881. /**
  64882. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64883. */
  64884. zOffset: number;
  64885. private _engine;
  64886. private _effect;
  64887. private _cachedDefines;
  64888. private _savedDepthWrite;
  64889. /**
  64890. * Instantiates a new outline renderer. (There could be only one per scene).
  64891. * @param scene Defines the scene it belongs to
  64892. */
  64893. constructor(scene: Scene);
  64894. /**
  64895. * Register the component to one instance of a scene.
  64896. */
  64897. register(): void;
  64898. /**
  64899. * Rebuilds the elements related to this component in case of
  64900. * context lost for instance.
  64901. */
  64902. rebuild(): void;
  64903. /**
  64904. * Disposes the component and the associated ressources.
  64905. */
  64906. dispose(): void;
  64907. /**
  64908. * Renders the outline in the canvas.
  64909. * @param subMesh Defines the sumesh to render
  64910. * @param batch Defines the batch of meshes in case of instances
  64911. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64912. */
  64913. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64914. /**
  64915. * Returns whether or not the outline renderer is ready for a given submesh.
  64916. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64917. * @param subMesh Defines the submesh to check readyness for
  64918. * @param useInstances Defines wheter wee are trying to render instances or not
  64919. * @returns true if ready otherwise false
  64920. */
  64921. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64922. private _beforeRenderingMesh;
  64923. private _afterRenderingMesh;
  64924. }
  64925. }
  64926. declare module BABYLON {
  64927. /**
  64928. * Defines the basic options interface of a Sprite Frame Source Size.
  64929. */
  64930. export interface ISpriteJSONSpriteSourceSize {
  64931. /**
  64932. * number of the original width of the Frame
  64933. */
  64934. w: number;
  64935. /**
  64936. * number of the original height of the Frame
  64937. */
  64938. h: number;
  64939. }
  64940. /**
  64941. * Defines the basic options interface of a Sprite Frame Data.
  64942. */
  64943. export interface ISpriteJSONSpriteFrameData {
  64944. /**
  64945. * number of the x offset of the Frame
  64946. */
  64947. x: number;
  64948. /**
  64949. * number of the y offset of the Frame
  64950. */
  64951. y: number;
  64952. /**
  64953. * number of the width of the Frame
  64954. */
  64955. w: number;
  64956. /**
  64957. * number of the height of the Frame
  64958. */
  64959. h: number;
  64960. }
  64961. /**
  64962. * Defines the basic options interface of a JSON Sprite.
  64963. */
  64964. export interface ISpriteJSONSprite {
  64965. /**
  64966. * string name of the Frame
  64967. */
  64968. filename: string;
  64969. /**
  64970. * ISpriteJSONSpriteFrame basic object of the frame data
  64971. */
  64972. frame: ISpriteJSONSpriteFrameData;
  64973. /**
  64974. * boolean to flag is the frame was rotated.
  64975. */
  64976. rotated: boolean;
  64977. /**
  64978. * boolean to flag is the frame was trimmed.
  64979. */
  64980. trimmed: boolean;
  64981. /**
  64982. * ISpriteJSONSpriteFrame basic object of the source data
  64983. */
  64984. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64985. /**
  64986. * ISpriteJSONSpriteFrame basic object of the source data
  64987. */
  64988. sourceSize: ISpriteJSONSpriteSourceSize;
  64989. }
  64990. /**
  64991. * Defines the basic options interface of a JSON atlas.
  64992. */
  64993. export interface ISpriteJSONAtlas {
  64994. /**
  64995. * Array of objects that contain the frame data.
  64996. */
  64997. frames: Array<ISpriteJSONSprite>;
  64998. /**
  64999. * object basic object containing the sprite meta data.
  65000. */
  65001. meta?: object;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /** @hidden */
  65006. export var spriteMapPixelShader: {
  65007. name: string;
  65008. shader: string;
  65009. };
  65010. }
  65011. declare module BABYLON {
  65012. /** @hidden */
  65013. export var spriteMapVertexShader: {
  65014. name: string;
  65015. shader: string;
  65016. };
  65017. }
  65018. declare module BABYLON {
  65019. /**
  65020. * Defines the basic options interface of a SpriteMap
  65021. */
  65022. export interface ISpriteMapOptions {
  65023. /**
  65024. * Vector2 of the number of cells in the grid.
  65025. */
  65026. stageSize?: Vector2;
  65027. /**
  65028. * Vector2 of the size of the output plane in World Units.
  65029. */
  65030. outputSize?: Vector2;
  65031. /**
  65032. * Vector3 of the position of the output plane in World Units.
  65033. */
  65034. outputPosition?: Vector3;
  65035. /**
  65036. * Vector3 of the rotation of the output plane.
  65037. */
  65038. outputRotation?: Vector3;
  65039. /**
  65040. * number of layers that the system will reserve in resources.
  65041. */
  65042. layerCount?: number;
  65043. /**
  65044. * number of max animation frames a single cell will reserve in resources.
  65045. */
  65046. maxAnimationFrames?: number;
  65047. /**
  65048. * number cell index of the base tile when the system compiles.
  65049. */
  65050. baseTile?: number;
  65051. /**
  65052. * boolean flip the sprite after its been repositioned by the framing data.
  65053. */
  65054. flipU?: boolean;
  65055. /**
  65056. * Vector3 scalar of the global RGB values of the SpriteMap.
  65057. */
  65058. colorMultiply?: Vector3;
  65059. }
  65060. /**
  65061. * Defines the IDisposable interface in order to be cleanable from resources.
  65062. */
  65063. export interface ISpriteMap extends IDisposable {
  65064. /**
  65065. * String name of the SpriteMap.
  65066. */
  65067. name: string;
  65068. /**
  65069. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  65070. */
  65071. atlasJSON: ISpriteJSONAtlas;
  65072. /**
  65073. * Texture of the SpriteMap.
  65074. */
  65075. spriteSheet: Texture;
  65076. /**
  65077. * The parameters to initialize the SpriteMap with.
  65078. */
  65079. options: ISpriteMapOptions;
  65080. }
  65081. /**
  65082. * Class used to manage a grid restricted sprite deployment on an Output plane.
  65083. */
  65084. export class SpriteMap implements ISpriteMap {
  65085. /** The Name of the spriteMap */
  65086. name: string;
  65087. /** The JSON file with the frame and meta data */
  65088. atlasJSON: ISpriteJSONAtlas;
  65089. /** The systems Sprite Sheet Texture */
  65090. spriteSheet: Texture;
  65091. /** Arguments passed with the Constructor */
  65092. options: ISpriteMapOptions;
  65093. /** Public Sprite Storage array, parsed from atlasJSON */
  65094. sprites: Array<ISpriteJSONSprite>;
  65095. /** Returns the Number of Sprites in the System */
  65096. get spriteCount(): number;
  65097. /** Returns the Position of Output Plane*/
  65098. get position(): Vector3;
  65099. /** Returns the Position of Output Plane*/
  65100. set position(v: Vector3);
  65101. /** Returns the Rotation of Output Plane*/
  65102. get rotation(): Vector3;
  65103. /** Returns the Rotation of Output Plane*/
  65104. set rotation(v: Vector3);
  65105. /** Sets the AnimationMap*/
  65106. get animationMap(): RawTexture;
  65107. /** Sets the AnimationMap*/
  65108. set animationMap(v: RawTexture);
  65109. /** Scene that the SpriteMap was created in */
  65110. private _scene;
  65111. /** Texture Buffer of Float32 that holds tile frame data*/
  65112. private _frameMap;
  65113. /** Texture Buffers of Float32 that holds tileMap data*/
  65114. private _tileMaps;
  65115. /** Texture Buffer of Float32 that holds Animation Data*/
  65116. private _animationMap;
  65117. /** Custom ShaderMaterial Central to the System*/
  65118. private _material;
  65119. /** Custom ShaderMaterial Central to the System*/
  65120. private _output;
  65121. /** Systems Time Ticker*/
  65122. private _time;
  65123. /**
  65124. * Creates a new SpriteMap
  65125. * @param name defines the SpriteMaps Name
  65126. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65127. * @param spriteSheet is the Texture that the Sprites are on.
  65128. * @param options a basic deployment configuration
  65129. * @param scene The Scene that the map is deployed on
  65130. */
  65131. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65132. /**
  65133. * Returns tileID location
  65134. * @returns Vector2 the cell position ID
  65135. */
  65136. getTileID(): Vector2;
  65137. /**
  65138. * Gets the UV location of the mouse over the SpriteMap.
  65139. * @returns Vector2 the UV position of the mouse interaction
  65140. */
  65141. getMousePosition(): Vector2;
  65142. /**
  65143. * Creates the "frame" texture Buffer
  65144. * -------------------------------------
  65145. * Structure of frames
  65146. * "filename": "Falling-Water-2.png",
  65147. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65148. * "rotated": true,
  65149. * "trimmed": true,
  65150. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65151. * "sourceSize": {"w":32,"h":32}
  65152. * @returns RawTexture of the frameMap
  65153. */
  65154. private _createFrameBuffer;
  65155. /**
  65156. * Creates the tileMap texture Buffer
  65157. * @param buffer normally and array of numbers, or a false to generate from scratch
  65158. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65159. * @returns RawTexture of the tileMap
  65160. */
  65161. private _createTileBuffer;
  65162. /**
  65163. * Modifies the data of the tileMaps
  65164. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65165. * @param pos is the iVector2 Coordinates of the Tile
  65166. * @param tile The SpriteIndex of the new Tile
  65167. */
  65168. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65169. /**
  65170. * Creates the animationMap texture Buffer
  65171. * @param buffer normally and array of numbers, or a false to generate from scratch
  65172. * @returns RawTexture of the animationMap
  65173. */
  65174. private _createTileAnimationBuffer;
  65175. /**
  65176. * Modifies the data of the animationMap
  65177. * @param cellID is the Index of the Sprite
  65178. * @param _frame is the target Animation frame
  65179. * @param toCell is the Target Index of the next frame of the animation
  65180. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65181. * @param speed is a global scalar of the time variable on the map.
  65182. */
  65183. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65184. /**
  65185. * Exports the .tilemaps file
  65186. */
  65187. saveTileMaps(): void;
  65188. /**
  65189. * Imports the .tilemaps file
  65190. * @param url of the .tilemaps file
  65191. */
  65192. loadTileMaps(url: string): void;
  65193. /**
  65194. * Release associated resources
  65195. */
  65196. dispose(): void;
  65197. }
  65198. }
  65199. declare module BABYLON {
  65200. /**
  65201. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65202. * @see http://doc.babylonjs.com/babylon101/sprites
  65203. */
  65204. export class SpritePackedManager extends SpriteManager {
  65205. /** defines the packed manager's name */
  65206. name: string;
  65207. /**
  65208. * Creates a new sprite manager from a packed sprite sheet
  65209. * @param name defines the manager's name
  65210. * @param imgUrl defines the sprite sheet url
  65211. * @param capacity defines the maximum allowed number of sprites
  65212. * @param scene defines the hosting scene
  65213. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65214. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65215. * @param samplingMode defines the smapling mode to use with spritesheet
  65216. * @param fromPacked set to true; do not alter
  65217. */
  65218. constructor(
  65219. /** defines the packed manager's name */
  65220. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65221. }
  65222. }
  65223. declare module BABYLON {
  65224. /**
  65225. * Defines the list of states available for a task inside a AssetsManager
  65226. */
  65227. export enum AssetTaskState {
  65228. /**
  65229. * Initialization
  65230. */
  65231. INIT = 0,
  65232. /**
  65233. * Running
  65234. */
  65235. RUNNING = 1,
  65236. /**
  65237. * Done
  65238. */
  65239. DONE = 2,
  65240. /**
  65241. * Error
  65242. */
  65243. ERROR = 3
  65244. }
  65245. /**
  65246. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65247. */
  65248. export abstract class AbstractAssetTask {
  65249. /**
  65250. * Task name
  65251. */ name: string;
  65252. /**
  65253. * Callback called when the task is successful
  65254. */
  65255. onSuccess: (task: any) => void;
  65256. /**
  65257. * Callback called when the task is not successful
  65258. */
  65259. onError: (task: any, message?: string, exception?: any) => void;
  65260. /**
  65261. * Creates a new AssetsManager
  65262. * @param name defines the name of the task
  65263. */
  65264. constructor(
  65265. /**
  65266. * Task name
  65267. */ name: string);
  65268. private _isCompleted;
  65269. private _taskState;
  65270. private _errorObject;
  65271. /**
  65272. * Get if the task is completed
  65273. */
  65274. get isCompleted(): boolean;
  65275. /**
  65276. * Gets the current state of the task
  65277. */
  65278. get taskState(): AssetTaskState;
  65279. /**
  65280. * Gets the current error object (if task is in error)
  65281. */
  65282. get errorObject(): {
  65283. message?: string;
  65284. exception?: any;
  65285. };
  65286. /**
  65287. * Internal only
  65288. * @hidden
  65289. */
  65290. _setErrorObject(message?: string, exception?: any): void;
  65291. /**
  65292. * Execute the current task
  65293. * @param scene defines the scene where you want your assets to be loaded
  65294. * @param onSuccess is a callback called when the task is successfully executed
  65295. * @param onError is a callback called if an error occurs
  65296. */
  65297. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65298. /**
  65299. * Execute the current task
  65300. * @param scene defines the scene where you want your assets to be loaded
  65301. * @param onSuccess is a callback called when the task is successfully executed
  65302. * @param onError is a callback called if an error occurs
  65303. */
  65304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65305. /**
  65306. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65307. * This can be used with failed tasks that have the reason for failure fixed.
  65308. */
  65309. reset(): void;
  65310. private onErrorCallback;
  65311. private onDoneCallback;
  65312. }
  65313. /**
  65314. * Define the interface used by progress events raised during assets loading
  65315. */
  65316. export interface IAssetsProgressEvent {
  65317. /**
  65318. * Defines the number of remaining tasks to process
  65319. */
  65320. remainingCount: number;
  65321. /**
  65322. * Defines the total number of tasks
  65323. */
  65324. totalCount: number;
  65325. /**
  65326. * Defines the task that was just processed
  65327. */
  65328. task: AbstractAssetTask;
  65329. }
  65330. /**
  65331. * Class used to share progress information about assets loading
  65332. */
  65333. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65334. /**
  65335. * Defines the number of remaining tasks to process
  65336. */
  65337. remainingCount: number;
  65338. /**
  65339. * Defines the total number of tasks
  65340. */
  65341. totalCount: number;
  65342. /**
  65343. * Defines the task that was just processed
  65344. */
  65345. task: AbstractAssetTask;
  65346. /**
  65347. * Creates a AssetsProgressEvent
  65348. * @param remainingCount defines the number of remaining tasks to process
  65349. * @param totalCount defines the total number of tasks
  65350. * @param task defines the task that was just processed
  65351. */
  65352. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65353. }
  65354. /**
  65355. * Define a task used by AssetsManager to load meshes
  65356. */
  65357. export class MeshAssetTask extends AbstractAssetTask {
  65358. /**
  65359. * Defines the name of the task
  65360. */
  65361. name: string;
  65362. /**
  65363. * Defines the list of mesh's names you want to load
  65364. */
  65365. meshesNames: any;
  65366. /**
  65367. * Defines the root url to use as a base to load your meshes and associated resources
  65368. */
  65369. rootUrl: string;
  65370. /**
  65371. * Defines the filename of the scene to load from
  65372. */
  65373. sceneFilename: string;
  65374. /**
  65375. * Gets the list of loaded meshes
  65376. */
  65377. loadedMeshes: Array<AbstractMesh>;
  65378. /**
  65379. * Gets the list of loaded particle systems
  65380. */
  65381. loadedParticleSystems: Array<IParticleSystem>;
  65382. /**
  65383. * Gets the list of loaded skeletons
  65384. */
  65385. loadedSkeletons: Array<Skeleton>;
  65386. /**
  65387. * Gets the list of loaded animation groups
  65388. */
  65389. loadedAnimationGroups: Array<AnimationGroup>;
  65390. /**
  65391. * Callback called when the task is successful
  65392. */
  65393. onSuccess: (task: MeshAssetTask) => void;
  65394. /**
  65395. * Callback called when the task is successful
  65396. */
  65397. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65398. /**
  65399. * Creates a new MeshAssetTask
  65400. * @param name defines the name of the task
  65401. * @param meshesNames defines the list of mesh's names you want to load
  65402. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65403. * @param sceneFilename defines the filename of the scene to load from
  65404. */
  65405. constructor(
  65406. /**
  65407. * Defines the name of the task
  65408. */
  65409. name: string,
  65410. /**
  65411. * Defines the list of mesh's names you want to load
  65412. */
  65413. meshesNames: any,
  65414. /**
  65415. * Defines the root url to use as a base to load your meshes and associated resources
  65416. */
  65417. rootUrl: string,
  65418. /**
  65419. * Defines the filename of the scene to load from
  65420. */
  65421. sceneFilename: string);
  65422. /**
  65423. * Execute the current task
  65424. * @param scene defines the scene where you want your assets to be loaded
  65425. * @param onSuccess is a callback called when the task is successfully executed
  65426. * @param onError is a callback called if an error occurs
  65427. */
  65428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65429. }
  65430. /**
  65431. * Define a task used by AssetsManager to load text content
  65432. */
  65433. export class TextFileAssetTask extends AbstractAssetTask {
  65434. /**
  65435. * Defines the name of the task
  65436. */
  65437. name: string;
  65438. /**
  65439. * Defines the location of the file to load
  65440. */
  65441. url: string;
  65442. /**
  65443. * Gets the loaded text string
  65444. */
  65445. text: string;
  65446. /**
  65447. * Callback called when the task is successful
  65448. */
  65449. onSuccess: (task: TextFileAssetTask) => void;
  65450. /**
  65451. * Callback called when the task is successful
  65452. */
  65453. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65454. /**
  65455. * Creates a new TextFileAssetTask object
  65456. * @param name defines the name of the task
  65457. * @param url defines the location of the file to load
  65458. */
  65459. constructor(
  65460. /**
  65461. * Defines the name of the task
  65462. */
  65463. name: string,
  65464. /**
  65465. * Defines the location of the file to load
  65466. */
  65467. url: string);
  65468. /**
  65469. * Execute the current task
  65470. * @param scene defines the scene where you want your assets to be loaded
  65471. * @param onSuccess is a callback called when the task is successfully executed
  65472. * @param onError is a callback called if an error occurs
  65473. */
  65474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65475. }
  65476. /**
  65477. * Define a task used by AssetsManager to load binary data
  65478. */
  65479. export class BinaryFileAssetTask extends AbstractAssetTask {
  65480. /**
  65481. * Defines the name of the task
  65482. */
  65483. name: string;
  65484. /**
  65485. * Defines the location of the file to load
  65486. */
  65487. url: string;
  65488. /**
  65489. * Gets the lodaded data (as an array buffer)
  65490. */
  65491. data: ArrayBuffer;
  65492. /**
  65493. * Callback called when the task is successful
  65494. */
  65495. onSuccess: (task: BinaryFileAssetTask) => void;
  65496. /**
  65497. * Callback called when the task is successful
  65498. */
  65499. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65500. /**
  65501. * Creates a new BinaryFileAssetTask object
  65502. * @param name defines the name of the new task
  65503. * @param url defines the location of the file to load
  65504. */
  65505. constructor(
  65506. /**
  65507. * Defines the name of the task
  65508. */
  65509. name: string,
  65510. /**
  65511. * Defines the location of the file to load
  65512. */
  65513. url: string);
  65514. /**
  65515. * Execute the current task
  65516. * @param scene defines the scene where you want your assets to be loaded
  65517. * @param onSuccess is a callback called when the task is successfully executed
  65518. * @param onError is a callback called if an error occurs
  65519. */
  65520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65521. }
  65522. /**
  65523. * Define a task used by AssetsManager to load images
  65524. */
  65525. export class ImageAssetTask extends AbstractAssetTask {
  65526. /**
  65527. * Defines the name of the task
  65528. */
  65529. name: string;
  65530. /**
  65531. * Defines the location of the image to load
  65532. */
  65533. url: string;
  65534. /**
  65535. * Gets the loaded images
  65536. */
  65537. image: HTMLImageElement;
  65538. /**
  65539. * Callback called when the task is successful
  65540. */
  65541. onSuccess: (task: ImageAssetTask) => void;
  65542. /**
  65543. * Callback called when the task is successful
  65544. */
  65545. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65546. /**
  65547. * Creates a new ImageAssetTask
  65548. * @param name defines the name of the task
  65549. * @param url defines the location of the image to load
  65550. */
  65551. constructor(
  65552. /**
  65553. * Defines the name of the task
  65554. */
  65555. name: string,
  65556. /**
  65557. * Defines the location of the image to load
  65558. */
  65559. url: string);
  65560. /**
  65561. * Execute the current task
  65562. * @param scene defines the scene where you want your assets to be loaded
  65563. * @param onSuccess is a callback called when the task is successfully executed
  65564. * @param onError is a callback called if an error occurs
  65565. */
  65566. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65567. }
  65568. /**
  65569. * Defines the interface used by texture loading tasks
  65570. */
  65571. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65572. /**
  65573. * Gets the loaded texture
  65574. */
  65575. texture: TEX;
  65576. }
  65577. /**
  65578. * Define a task used by AssetsManager to load 2D textures
  65579. */
  65580. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65581. /**
  65582. * Defines the name of the task
  65583. */
  65584. name: string;
  65585. /**
  65586. * Defines the location of the file to load
  65587. */
  65588. url: string;
  65589. /**
  65590. * Defines if mipmap should not be generated (default is false)
  65591. */
  65592. noMipmap?: boolean | undefined;
  65593. /**
  65594. * Defines if texture must be inverted on Y axis (default is false)
  65595. */
  65596. invertY?: boolean | undefined;
  65597. /**
  65598. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65599. */
  65600. samplingMode: number;
  65601. /**
  65602. * Gets the loaded texture
  65603. */
  65604. texture: Texture;
  65605. /**
  65606. * Callback called when the task is successful
  65607. */
  65608. onSuccess: (task: TextureAssetTask) => void;
  65609. /**
  65610. * Callback called when the task is successful
  65611. */
  65612. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65613. /**
  65614. * Creates a new TextureAssetTask object
  65615. * @param name defines the name of the task
  65616. * @param url defines the location of the file to load
  65617. * @param noMipmap defines if mipmap should not be generated (default is false)
  65618. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65619. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65620. */
  65621. constructor(
  65622. /**
  65623. * Defines the name of the task
  65624. */
  65625. name: string,
  65626. /**
  65627. * Defines the location of the file to load
  65628. */
  65629. url: string,
  65630. /**
  65631. * Defines if mipmap should not be generated (default is false)
  65632. */
  65633. noMipmap?: boolean | undefined,
  65634. /**
  65635. * Defines if texture must be inverted on Y axis (default is false)
  65636. */
  65637. invertY?: boolean | undefined,
  65638. /**
  65639. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65640. */
  65641. samplingMode?: number);
  65642. /**
  65643. * Execute the current task
  65644. * @param scene defines the scene where you want your assets to be loaded
  65645. * @param onSuccess is a callback called when the task is successfully executed
  65646. * @param onError is a callback called if an error occurs
  65647. */
  65648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65649. }
  65650. /**
  65651. * Define a task used by AssetsManager to load cube textures
  65652. */
  65653. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65654. /**
  65655. * Defines the name of the task
  65656. */
  65657. name: string;
  65658. /**
  65659. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65660. */
  65661. url: string;
  65662. /**
  65663. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65664. */
  65665. extensions?: string[] | undefined;
  65666. /**
  65667. * Defines if mipmaps should not be generated (default is false)
  65668. */
  65669. noMipmap?: boolean | undefined;
  65670. /**
  65671. * Defines the explicit list of files (undefined by default)
  65672. */
  65673. files?: string[] | undefined;
  65674. /**
  65675. * Gets the loaded texture
  65676. */
  65677. texture: CubeTexture;
  65678. /**
  65679. * Callback called when the task is successful
  65680. */
  65681. onSuccess: (task: CubeTextureAssetTask) => void;
  65682. /**
  65683. * Callback called when the task is successful
  65684. */
  65685. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65686. /**
  65687. * Creates a new CubeTextureAssetTask
  65688. * @param name defines the name of the task
  65689. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65690. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65692. * @param files defines the explicit list of files (undefined by default)
  65693. */
  65694. constructor(
  65695. /**
  65696. * Defines the name of the task
  65697. */
  65698. name: string,
  65699. /**
  65700. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65701. */
  65702. url: string,
  65703. /**
  65704. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65705. */
  65706. extensions?: string[] | undefined,
  65707. /**
  65708. * Defines if mipmaps should not be generated (default is false)
  65709. */
  65710. noMipmap?: boolean | undefined,
  65711. /**
  65712. * Defines the explicit list of files (undefined by default)
  65713. */
  65714. files?: string[] | undefined);
  65715. /**
  65716. * Execute the current task
  65717. * @param scene defines the scene where you want your assets to be loaded
  65718. * @param onSuccess is a callback called when the task is successfully executed
  65719. * @param onError is a callback called if an error occurs
  65720. */
  65721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65722. }
  65723. /**
  65724. * Define a task used by AssetsManager to load HDR cube textures
  65725. */
  65726. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65727. /**
  65728. * Defines the name of the task
  65729. */
  65730. name: string;
  65731. /**
  65732. * Defines the location of the file to load
  65733. */
  65734. url: string;
  65735. /**
  65736. * Defines the desired size (the more it increases the longer the generation will be)
  65737. */
  65738. size: number;
  65739. /**
  65740. * Defines if mipmaps should not be generated (default is false)
  65741. */
  65742. noMipmap: boolean;
  65743. /**
  65744. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65745. */
  65746. generateHarmonics: boolean;
  65747. /**
  65748. * 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)
  65749. */
  65750. gammaSpace: boolean;
  65751. /**
  65752. * Internal Use Only
  65753. */
  65754. reserved: boolean;
  65755. /**
  65756. * Gets the loaded texture
  65757. */
  65758. texture: HDRCubeTexture;
  65759. /**
  65760. * Callback called when the task is successful
  65761. */
  65762. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65763. /**
  65764. * Callback called when the task is successful
  65765. */
  65766. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65767. /**
  65768. * Creates a new HDRCubeTextureAssetTask object
  65769. * @param name defines the name of the task
  65770. * @param url defines the location of the file to load
  65771. * @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.
  65772. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65773. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65774. * @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)
  65775. * @param reserved Internal use only
  65776. */
  65777. constructor(
  65778. /**
  65779. * Defines the name of the task
  65780. */
  65781. name: string,
  65782. /**
  65783. * Defines the location of the file to load
  65784. */
  65785. url: string,
  65786. /**
  65787. * Defines the desired size (the more it increases the longer the generation will be)
  65788. */
  65789. size: number,
  65790. /**
  65791. * Defines if mipmaps should not be generated (default is false)
  65792. */
  65793. noMipmap?: boolean,
  65794. /**
  65795. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65796. */
  65797. generateHarmonics?: boolean,
  65798. /**
  65799. * 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)
  65800. */
  65801. gammaSpace?: boolean,
  65802. /**
  65803. * Internal Use Only
  65804. */
  65805. reserved?: boolean);
  65806. /**
  65807. * Execute the current task
  65808. * @param scene defines the scene where you want your assets to be loaded
  65809. * @param onSuccess is a callback called when the task is successfully executed
  65810. * @param onError is a callback called if an error occurs
  65811. */
  65812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65813. }
  65814. /**
  65815. * Define a task used by AssetsManager to load Equirectangular cube textures
  65816. */
  65817. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65818. /**
  65819. * Defines the name of the task
  65820. */
  65821. name: string;
  65822. /**
  65823. * Defines the location of the file to load
  65824. */
  65825. url: string;
  65826. /**
  65827. * Defines the desired size (the more it increases the longer the generation will be)
  65828. */
  65829. size: number;
  65830. /**
  65831. * Defines if mipmaps should not be generated (default is false)
  65832. */
  65833. noMipmap: boolean;
  65834. /**
  65835. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65836. * but the standard material would require them in Gamma space) (default is true)
  65837. */
  65838. gammaSpace: boolean;
  65839. /**
  65840. * Gets the loaded texture
  65841. */
  65842. texture: EquiRectangularCubeTexture;
  65843. /**
  65844. * Callback called when the task is successful
  65845. */
  65846. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65847. /**
  65848. * Callback called when the task is successful
  65849. */
  65850. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65851. /**
  65852. * Creates a new EquiRectangularCubeTextureAssetTask object
  65853. * @param name defines the name of the task
  65854. * @param url defines the location of the file to load
  65855. * @param size defines the desired size (the more it increases the longer the generation will be)
  65856. * If the size is omitted this implies you are using a preprocessed cubemap.
  65857. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65858. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65859. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65860. * (default is true)
  65861. */
  65862. constructor(
  65863. /**
  65864. * Defines the name of the task
  65865. */
  65866. name: string,
  65867. /**
  65868. * Defines the location of the file to load
  65869. */
  65870. url: string,
  65871. /**
  65872. * Defines the desired size (the more it increases the longer the generation will be)
  65873. */
  65874. size: number,
  65875. /**
  65876. * Defines if mipmaps should not be generated (default is false)
  65877. */
  65878. noMipmap?: boolean,
  65879. /**
  65880. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65881. * but the standard material would require them in Gamma space) (default is true)
  65882. */
  65883. gammaSpace?: boolean);
  65884. /**
  65885. * Execute the current task
  65886. * @param scene defines the scene where you want your assets to be loaded
  65887. * @param onSuccess is a callback called when the task is successfully executed
  65888. * @param onError is a callback called if an error occurs
  65889. */
  65890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65891. }
  65892. /**
  65893. * This class can be used to easily import assets into a scene
  65894. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65895. */
  65896. export class AssetsManager {
  65897. private _scene;
  65898. private _isLoading;
  65899. protected _tasks: AbstractAssetTask[];
  65900. protected _waitingTasksCount: number;
  65901. protected _totalTasksCount: number;
  65902. /**
  65903. * Callback called when all tasks are processed
  65904. */
  65905. onFinish: (tasks: AbstractAssetTask[]) => void;
  65906. /**
  65907. * Callback called when a task is successful
  65908. */
  65909. onTaskSuccess: (task: AbstractAssetTask) => void;
  65910. /**
  65911. * Callback called when a task had an error
  65912. */
  65913. onTaskError: (task: AbstractAssetTask) => void;
  65914. /**
  65915. * Callback called when a task is done (whatever the result is)
  65916. */
  65917. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65918. /**
  65919. * Observable called when all tasks are processed
  65920. */
  65921. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65922. /**
  65923. * Observable called when a task had an error
  65924. */
  65925. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65926. /**
  65927. * Observable called when all tasks were executed
  65928. */
  65929. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65930. /**
  65931. * Observable called when a task is done (whatever the result is)
  65932. */
  65933. onProgressObservable: Observable<IAssetsProgressEvent>;
  65934. /**
  65935. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65937. */
  65938. useDefaultLoadingScreen: boolean;
  65939. /**
  65940. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65941. * when all assets have been downloaded.
  65942. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65943. */
  65944. autoHideLoadingUI: boolean;
  65945. /**
  65946. * Creates a new AssetsManager
  65947. * @param scene defines the scene to work on
  65948. */
  65949. constructor(scene: Scene);
  65950. /**
  65951. * Add a MeshAssetTask to the list of active tasks
  65952. * @param taskName defines the name of the new task
  65953. * @param meshesNames defines the name of meshes to load
  65954. * @param rootUrl defines the root url to use to locate files
  65955. * @param sceneFilename defines the filename of the scene file
  65956. * @returns a new MeshAssetTask object
  65957. */
  65958. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65959. /**
  65960. * Add a TextFileAssetTask to the list of active tasks
  65961. * @param taskName defines the name of the new task
  65962. * @param url defines the url of the file to load
  65963. * @returns a new TextFileAssetTask object
  65964. */
  65965. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65966. /**
  65967. * Add a BinaryFileAssetTask to the list of active tasks
  65968. * @param taskName defines the name of the new task
  65969. * @param url defines the url of the file to load
  65970. * @returns a new BinaryFileAssetTask object
  65971. */
  65972. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65973. /**
  65974. * Add a ImageAssetTask to the list of active tasks
  65975. * @param taskName defines the name of the new task
  65976. * @param url defines the url of the file to load
  65977. * @returns a new ImageAssetTask object
  65978. */
  65979. addImageTask(taskName: string, url: string): ImageAssetTask;
  65980. /**
  65981. * Add a TextureAssetTask to the list of active tasks
  65982. * @param taskName defines the name of the new task
  65983. * @param url defines the url of the file to load
  65984. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65985. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65986. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65987. * @returns a new TextureAssetTask object
  65988. */
  65989. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65990. /**
  65991. * Add a CubeTextureAssetTask to the list of active tasks
  65992. * @param taskName defines the name of the new task
  65993. * @param url defines the url of the file to load
  65994. * @param extensions defines the extension to use to load the cube map (can be null)
  65995. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65996. * @param files defines the list of files to load (can be null)
  65997. * @returns a new CubeTextureAssetTask object
  65998. */
  65999. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66000. /**
  66001. *
  66002. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66003. * @param taskName defines the name of the new task
  66004. * @param url defines the url of the file to load
  66005. * @param size defines the size you want for the cubemap (can be null)
  66006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66007. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66008. * @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)
  66009. * @param reserved Internal use only
  66010. * @returns a new HDRCubeTextureAssetTask object
  66011. */
  66012. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66013. /**
  66014. *
  66015. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66016. * @param taskName defines the name of the new task
  66017. * @param url defines the url of the file to load
  66018. * @param size defines the size you want for the cubemap (can be null)
  66019. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66020. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66021. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66022. * @returns a new EquiRectangularCubeTextureAssetTask object
  66023. */
  66024. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66025. /**
  66026. * Remove a task from the assets manager.
  66027. * @param task the task to remove
  66028. */
  66029. removeTask(task: AbstractAssetTask): void;
  66030. private _decreaseWaitingTasksCount;
  66031. private _runTask;
  66032. /**
  66033. * Reset the AssetsManager and remove all tasks
  66034. * @return the current instance of the AssetsManager
  66035. */
  66036. reset(): AssetsManager;
  66037. /**
  66038. * Start the loading process
  66039. * @return the current instance of the AssetsManager
  66040. */
  66041. load(): AssetsManager;
  66042. /**
  66043. * Start the loading process as an async operation
  66044. * @return a promise returning the list of failed tasks
  66045. */
  66046. loadAsync(): Promise<void>;
  66047. }
  66048. }
  66049. declare module BABYLON {
  66050. /**
  66051. * Wrapper class for promise with external resolve and reject.
  66052. */
  66053. export class Deferred<T> {
  66054. /**
  66055. * The promise associated with this deferred object.
  66056. */
  66057. readonly promise: Promise<T>;
  66058. private _resolve;
  66059. private _reject;
  66060. /**
  66061. * The resolve method of the promise associated with this deferred object.
  66062. */
  66063. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  66064. /**
  66065. * The reject method of the promise associated with this deferred object.
  66066. */
  66067. get reject(): (reason?: any) => void;
  66068. /**
  66069. * Constructor for this deferred object.
  66070. */
  66071. constructor();
  66072. }
  66073. }
  66074. declare module BABYLON {
  66075. /**
  66076. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66077. */
  66078. export class MeshExploder {
  66079. private _centerMesh;
  66080. private _meshes;
  66081. private _meshesOrigins;
  66082. private _toCenterVectors;
  66083. private _scaledDirection;
  66084. private _newPosition;
  66085. private _centerPosition;
  66086. /**
  66087. * Explodes meshes from a center mesh.
  66088. * @param meshes The meshes to explode.
  66089. * @param centerMesh The mesh to be center of explosion.
  66090. */
  66091. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66092. private _setCenterMesh;
  66093. /**
  66094. * Get class name
  66095. * @returns "MeshExploder"
  66096. */
  66097. getClassName(): string;
  66098. /**
  66099. * "Exploded meshes"
  66100. * @returns Array of meshes with the centerMesh at index 0.
  66101. */
  66102. getMeshes(): Array<Mesh>;
  66103. /**
  66104. * Explodes meshes giving a specific direction
  66105. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66106. */
  66107. explode(direction?: number): void;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /**
  66112. * Class used to help managing file picking and drag'n'drop
  66113. */
  66114. export class FilesInput {
  66115. /**
  66116. * List of files ready to be loaded
  66117. */
  66118. static get FilesToLoad(): {
  66119. [key: string]: File;
  66120. };
  66121. /**
  66122. * Callback called when a file is processed
  66123. */
  66124. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66125. private _engine;
  66126. private _currentScene;
  66127. private _sceneLoadedCallback;
  66128. private _progressCallback;
  66129. private _additionalRenderLoopLogicCallback;
  66130. private _textureLoadingCallback;
  66131. private _startingProcessingFilesCallback;
  66132. private _onReloadCallback;
  66133. private _errorCallback;
  66134. private _elementToMonitor;
  66135. private _sceneFileToLoad;
  66136. private _filesToLoad;
  66137. /**
  66138. * Creates a new FilesInput
  66139. * @param engine defines the rendering engine
  66140. * @param scene defines the hosting scene
  66141. * @param sceneLoadedCallback callback called when scene is loaded
  66142. * @param progressCallback callback called to track progress
  66143. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66144. * @param textureLoadingCallback callback called when a texture is loading
  66145. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66146. * @param onReloadCallback callback called when a reload is requested
  66147. * @param errorCallback callback call if an error occurs
  66148. */
  66149. 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);
  66150. private _dragEnterHandler;
  66151. private _dragOverHandler;
  66152. private _dropHandler;
  66153. /**
  66154. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66155. * @param elementToMonitor defines the DOM element to track
  66156. */
  66157. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66158. /**
  66159. * Release all associated resources
  66160. */
  66161. dispose(): void;
  66162. private renderFunction;
  66163. private drag;
  66164. private drop;
  66165. private _traverseFolder;
  66166. private _processFiles;
  66167. /**
  66168. * Load files from a drop event
  66169. * @param event defines the drop event to use as source
  66170. */
  66171. loadFiles(event: any): void;
  66172. private _processReload;
  66173. /**
  66174. * Reload the current scene from the loaded files
  66175. */
  66176. reload(): void;
  66177. }
  66178. }
  66179. declare module BABYLON {
  66180. /**
  66181. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66183. */
  66184. export class SceneOptimization {
  66185. /**
  66186. * Defines the priority of this optimization (0 by default which means first in the list)
  66187. */
  66188. priority: number;
  66189. /**
  66190. * Gets a string describing the action executed by the current optimization
  66191. * @returns description string
  66192. */
  66193. getDescription(): string;
  66194. /**
  66195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66196. * @param scene defines the current scene where to apply this optimization
  66197. * @param optimizer defines the current optimizer
  66198. * @returns true if everything that can be done was applied
  66199. */
  66200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66201. /**
  66202. * Creates the SceneOptimization object
  66203. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66204. * @param desc defines the description associated with the optimization
  66205. */
  66206. constructor(
  66207. /**
  66208. * Defines the priority of this optimization (0 by default which means first in the list)
  66209. */
  66210. priority?: number);
  66211. }
  66212. /**
  66213. * Defines an optimization used to reduce the size of render target textures
  66214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66215. */
  66216. export class TextureOptimization extends SceneOptimization {
  66217. /**
  66218. * Defines the priority of this optimization (0 by default which means first in the list)
  66219. */
  66220. priority: number;
  66221. /**
  66222. * 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
  66223. */
  66224. maximumSize: number;
  66225. /**
  66226. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66227. */
  66228. step: number;
  66229. /**
  66230. * Gets a string describing the action executed by the current optimization
  66231. * @returns description string
  66232. */
  66233. getDescription(): string;
  66234. /**
  66235. * Creates the TextureOptimization object
  66236. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66237. * @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
  66238. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66239. */
  66240. constructor(
  66241. /**
  66242. * Defines the priority of this optimization (0 by default which means first in the list)
  66243. */
  66244. priority?: number,
  66245. /**
  66246. * 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
  66247. */
  66248. maximumSize?: number,
  66249. /**
  66250. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66251. */
  66252. step?: number);
  66253. /**
  66254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66255. * @param scene defines the current scene where to apply this optimization
  66256. * @param optimizer defines the current optimizer
  66257. * @returns true if everything that can be done was applied
  66258. */
  66259. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66260. }
  66261. /**
  66262. * Defines an optimization used to increase or decrease the rendering resolution
  66263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66264. */
  66265. export class HardwareScalingOptimization extends SceneOptimization {
  66266. /**
  66267. * Defines the priority of this optimization (0 by default which means first in the list)
  66268. */
  66269. priority: number;
  66270. /**
  66271. * Defines the maximum scale to use (2 by default)
  66272. */
  66273. maximumScale: number;
  66274. /**
  66275. * Defines the step to use between two passes (0.5 by default)
  66276. */
  66277. step: number;
  66278. private _currentScale;
  66279. private _directionOffset;
  66280. /**
  66281. * Gets a string describing the action executed by the current optimization
  66282. * @return description string
  66283. */
  66284. getDescription(): string;
  66285. /**
  66286. * Creates the HardwareScalingOptimization object
  66287. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66288. * @param maximumScale defines the maximum scale to use (2 by default)
  66289. * @param step defines the step to use between two passes (0.5 by default)
  66290. */
  66291. constructor(
  66292. /**
  66293. * Defines the priority of this optimization (0 by default which means first in the list)
  66294. */
  66295. priority?: number,
  66296. /**
  66297. * Defines the maximum scale to use (2 by default)
  66298. */
  66299. maximumScale?: number,
  66300. /**
  66301. * Defines the step to use between two passes (0.5 by default)
  66302. */
  66303. step?: number);
  66304. /**
  66305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66306. * @param scene defines the current scene where to apply this optimization
  66307. * @param optimizer defines the current optimizer
  66308. * @returns true if everything that can be done was applied
  66309. */
  66310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66311. }
  66312. /**
  66313. * Defines an optimization used to remove shadows
  66314. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66315. */
  66316. export class ShadowsOptimization extends SceneOptimization {
  66317. /**
  66318. * Gets a string describing the action executed by the current optimization
  66319. * @return description string
  66320. */
  66321. getDescription(): string;
  66322. /**
  66323. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66324. * @param scene defines the current scene where to apply this optimization
  66325. * @param optimizer defines the current optimizer
  66326. * @returns true if everything that can be done was applied
  66327. */
  66328. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66329. }
  66330. /**
  66331. * Defines an optimization used to turn post-processes off
  66332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66333. */
  66334. export class PostProcessesOptimization extends SceneOptimization {
  66335. /**
  66336. * Gets a string describing the action executed by the current optimization
  66337. * @return description string
  66338. */
  66339. getDescription(): string;
  66340. /**
  66341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66342. * @param scene defines the current scene where to apply this optimization
  66343. * @param optimizer defines the current optimizer
  66344. * @returns true if everything that can be done was applied
  66345. */
  66346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66347. }
  66348. /**
  66349. * Defines an optimization used to turn lens flares off
  66350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66351. */
  66352. export class LensFlaresOptimization extends SceneOptimization {
  66353. /**
  66354. * Gets a string describing the action executed by the current optimization
  66355. * @return description string
  66356. */
  66357. getDescription(): string;
  66358. /**
  66359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66360. * @param scene defines the current scene where to apply this optimization
  66361. * @param optimizer defines the current optimizer
  66362. * @returns true if everything that can be done was applied
  66363. */
  66364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66365. }
  66366. /**
  66367. * Defines an optimization based on user defined callback.
  66368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66369. */
  66370. export class CustomOptimization extends SceneOptimization {
  66371. /**
  66372. * Callback called to apply the custom optimization.
  66373. */
  66374. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66375. /**
  66376. * Callback called to get custom description
  66377. */
  66378. onGetDescription: () => string;
  66379. /**
  66380. * Gets a string describing the action executed by the current optimization
  66381. * @returns description string
  66382. */
  66383. getDescription(): string;
  66384. /**
  66385. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66386. * @param scene defines the current scene where to apply this optimization
  66387. * @param optimizer defines the current optimizer
  66388. * @returns true if everything that can be done was applied
  66389. */
  66390. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66391. }
  66392. /**
  66393. * Defines an optimization used to turn particles off
  66394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66395. */
  66396. export class ParticlesOptimization extends SceneOptimization {
  66397. /**
  66398. * Gets a string describing the action executed by the current optimization
  66399. * @return description string
  66400. */
  66401. getDescription(): string;
  66402. /**
  66403. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66404. * @param scene defines the current scene where to apply this optimization
  66405. * @param optimizer defines the current optimizer
  66406. * @returns true if everything that can be done was applied
  66407. */
  66408. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66409. }
  66410. /**
  66411. * Defines an optimization used to turn render targets off
  66412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66413. */
  66414. export class RenderTargetsOptimization extends SceneOptimization {
  66415. /**
  66416. * Gets a string describing the action executed by the current optimization
  66417. * @return description string
  66418. */
  66419. getDescription(): string;
  66420. /**
  66421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66422. * @param scene defines the current scene where to apply this optimization
  66423. * @param optimizer defines the current optimizer
  66424. * @returns true if everything that can be done was applied
  66425. */
  66426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66427. }
  66428. /**
  66429. * Defines an optimization used to merge meshes with compatible materials
  66430. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66431. */
  66432. export class MergeMeshesOptimization extends SceneOptimization {
  66433. private static _UpdateSelectionTree;
  66434. /**
  66435. * Gets or sets a boolean which defines if optimization octree has to be updated
  66436. */
  66437. static get UpdateSelectionTree(): boolean;
  66438. /**
  66439. * Gets or sets a boolean which defines if optimization octree has to be updated
  66440. */
  66441. static set UpdateSelectionTree(value: boolean);
  66442. /**
  66443. * Gets a string describing the action executed by the current optimization
  66444. * @return description string
  66445. */
  66446. getDescription(): string;
  66447. private _canBeMerged;
  66448. /**
  66449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66450. * @param scene defines the current scene where to apply this optimization
  66451. * @param optimizer defines the current optimizer
  66452. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66453. * @returns true if everything that can be done was applied
  66454. */
  66455. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66456. }
  66457. /**
  66458. * Defines a list of options used by SceneOptimizer
  66459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66460. */
  66461. export class SceneOptimizerOptions {
  66462. /**
  66463. * Defines the target frame rate to reach (60 by default)
  66464. */
  66465. targetFrameRate: number;
  66466. /**
  66467. * Defines the interval between two checkes (2000ms by default)
  66468. */
  66469. trackerDuration: number;
  66470. /**
  66471. * Gets the list of optimizations to apply
  66472. */
  66473. optimizations: SceneOptimization[];
  66474. /**
  66475. * Creates a new list of options used by SceneOptimizer
  66476. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66477. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66478. */
  66479. constructor(
  66480. /**
  66481. * Defines the target frame rate to reach (60 by default)
  66482. */
  66483. targetFrameRate?: number,
  66484. /**
  66485. * Defines the interval between two checkes (2000ms by default)
  66486. */
  66487. trackerDuration?: number);
  66488. /**
  66489. * Add a new optimization
  66490. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66491. * @returns the current SceneOptimizerOptions
  66492. */
  66493. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66494. /**
  66495. * Add a new custom optimization
  66496. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66497. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66498. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66499. * @returns the current SceneOptimizerOptions
  66500. */
  66501. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66502. /**
  66503. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66504. * @param targetFrameRate defines the target frame rate (60 by default)
  66505. * @returns a SceneOptimizerOptions object
  66506. */
  66507. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66508. /**
  66509. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66510. * @param targetFrameRate defines the target frame rate (60 by default)
  66511. * @returns a SceneOptimizerOptions object
  66512. */
  66513. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66514. /**
  66515. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66516. * @param targetFrameRate defines the target frame rate (60 by default)
  66517. * @returns a SceneOptimizerOptions object
  66518. */
  66519. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66520. }
  66521. /**
  66522. * Class used to run optimizations in order to reach a target frame rate
  66523. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66524. */
  66525. export class SceneOptimizer implements IDisposable {
  66526. private _isRunning;
  66527. private _options;
  66528. private _scene;
  66529. private _currentPriorityLevel;
  66530. private _targetFrameRate;
  66531. private _trackerDuration;
  66532. private _currentFrameRate;
  66533. private _sceneDisposeObserver;
  66534. private _improvementMode;
  66535. /**
  66536. * Defines an observable called when the optimizer reaches the target frame rate
  66537. */
  66538. onSuccessObservable: Observable<SceneOptimizer>;
  66539. /**
  66540. * Defines an observable called when the optimizer enables an optimization
  66541. */
  66542. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66543. /**
  66544. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66545. */
  66546. onFailureObservable: Observable<SceneOptimizer>;
  66547. /**
  66548. * Gets a boolean indicating if the optimizer is in improvement mode
  66549. */
  66550. get isInImprovementMode(): boolean;
  66551. /**
  66552. * Gets the current priority level (0 at start)
  66553. */
  66554. get currentPriorityLevel(): number;
  66555. /**
  66556. * Gets the current frame rate checked by the SceneOptimizer
  66557. */
  66558. get currentFrameRate(): number;
  66559. /**
  66560. * Gets or sets the current target frame rate (60 by default)
  66561. */
  66562. get targetFrameRate(): number;
  66563. /**
  66564. * Gets or sets the current target frame rate (60 by default)
  66565. */
  66566. set targetFrameRate(value: number);
  66567. /**
  66568. * Gets or sets the current interval between two checks (every 2000ms by default)
  66569. */
  66570. get trackerDuration(): number;
  66571. /**
  66572. * Gets or sets the current interval between two checks (every 2000ms by default)
  66573. */
  66574. set trackerDuration(value: number);
  66575. /**
  66576. * Gets the list of active optimizations
  66577. */
  66578. get optimizations(): SceneOptimization[];
  66579. /**
  66580. * Creates a new SceneOptimizer
  66581. * @param scene defines the scene to work on
  66582. * @param options defines the options to use with the SceneOptimizer
  66583. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66584. * @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)
  66585. */
  66586. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66587. /**
  66588. * Stops the current optimizer
  66589. */
  66590. stop(): void;
  66591. /**
  66592. * Reset the optimizer to initial step (current priority level = 0)
  66593. */
  66594. reset(): void;
  66595. /**
  66596. * Start the optimizer. By default it will try to reach a specific framerate
  66597. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66598. */
  66599. start(): void;
  66600. private _checkCurrentState;
  66601. /**
  66602. * Release all resources
  66603. */
  66604. dispose(): void;
  66605. /**
  66606. * Helper function to create a SceneOptimizer with one single line of code
  66607. * @param scene defines the scene to work on
  66608. * @param options defines the options to use with the SceneOptimizer
  66609. * @param onSuccess defines a callback to call on success
  66610. * @param onFailure defines a callback to call on failure
  66611. * @returns the new SceneOptimizer object
  66612. */
  66613. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66614. }
  66615. }
  66616. declare module BABYLON {
  66617. /**
  66618. * Class used to serialize a scene into a string
  66619. */
  66620. export class SceneSerializer {
  66621. /**
  66622. * Clear cache used by a previous serialization
  66623. */
  66624. static ClearCache(): void;
  66625. /**
  66626. * Serialize a scene into a JSON compatible object
  66627. * @param scene defines the scene to serialize
  66628. * @returns a JSON compatible object
  66629. */
  66630. static Serialize(scene: Scene): any;
  66631. /**
  66632. * Serialize a mesh into a JSON compatible object
  66633. * @param toSerialize defines the mesh to serialize
  66634. * @param withParents defines if parents must be serialized as well
  66635. * @param withChildren defines if children must be serialized as well
  66636. * @returns a JSON compatible object
  66637. */
  66638. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66639. }
  66640. }
  66641. declare module BABYLON {
  66642. /**
  66643. * Class used to host texture specific utilities
  66644. */
  66645. export class TextureTools {
  66646. /**
  66647. * Uses the GPU to create a copy texture rescaled at a given size
  66648. * @param texture Texture to copy from
  66649. * @param width defines the desired width
  66650. * @param height defines the desired height
  66651. * @param useBilinearMode defines if bilinear mode has to be used
  66652. * @return the generated texture
  66653. */
  66654. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66655. }
  66656. }
  66657. declare module BABYLON {
  66658. /**
  66659. * This represents the different options available for the video capture.
  66660. */
  66661. export interface VideoRecorderOptions {
  66662. /** Defines the mime type of the video. */
  66663. mimeType: string;
  66664. /** Defines the FPS the video should be recorded at. */
  66665. fps: number;
  66666. /** Defines the chunk size for the recording data. */
  66667. recordChunckSize: number;
  66668. /** The audio tracks to attach to the recording. */
  66669. audioTracks?: MediaStreamTrack[];
  66670. }
  66671. /**
  66672. * This can help with recording videos from BabylonJS.
  66673. * This is based on the available WebRTC functionalities of the browser.
  66674. *
  66675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66676. */
  66677. export class VideoRecorder {
  66678. private static readonly _defaultOptions;
  66679. /**
  66680. * Returns whether or not the VideoRecorder is available in your browser.
  66681. * @param engine Defines the Babylon Engine.
  66682. * @returns true if supported otherwise false.
  66683. */
  66684. static IsSupported(engine: Engine): boolean;
  66685. private readonly _options;
  66686. private _canvas;
  66687. private _mediaRecorder;
  66688. private _recordedChunks;
  66689. private _fileName;
  66690. private _resolve;
  66691. private _reject;
  66692. /**
  66693. * True when a recording is already in progress.
  66694. */
  66695. get isRecording(): boolean;
  66696. /**
  66697. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66698. * @param engine Defines the BabylonJS Engine you wish to record.
  66699. * @param options Defines options that can be used to customize the capture.
  66700. */
  66701. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66702. /**
  66703. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66704. */
  66705. stopRecording(): void;
  66706. /**
  66707. * Starts recording the canvas for a max duration specified in parameters.
  66708. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66709. * If null no automatic download will start and you can rely on the promise to get the data back.
  66710. * @param maxDuration Defines the maximum recording time in seconds.
  66711. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66712. * @return A promise callback at the end of the recording with the video data in Blob.
  66713. */
  66714. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66715. /**
  66716. * Releases internal resources used during the recording.
  66717. */
  66718. dispose(): void;
  66719. private _handleDataAvailable;
  66720. private _handleError;
  66721. private _handleStop;
  66722. }
  66723. }
  66724. declare module BABYLON {
  66725. /**
  66726. * Class containing a set of static utilities functions for screenshots
  66727. */
  66728. export class ScreenshotTools {
  66729. /**
  66730. * Captures a screenshot of the current rendering
  66731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66732. * @param engine defines the rendering engine
  66733. * @param camera defines the source camera
  66734. * @param size This parameter can be set to a single number or to an object with the
  66735. * following (optional) properties: precision, width, height. If a single number is passed,
  66736. * it will be used for both width and height. If an object is passed, the screenshot size
  66737. * will be derived from the parameters. The precision property is a multiplier allowing
  66738. * rendering at a higher or lower resolution
  66739. * @param successCallback defines the callback receives a single parameter which contains the
  66740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66741. * src parameter of an <img> to display it
  66742. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66743. * Check your browser for supported MIME types
  66744. */
  66745. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66746. /**
  66747. * Captures a screenshot of the current rendering
  66748. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66749. * @param engine defines the rendering engine
  66750. * @param camera defines the source camera
  66751. * @param size This parameter can be set to a single number or to an object with the
  66752. * following (optional) properties: precision, width, height. If a single number is passed,
  66753. * it will be used for both width and height. If an object is passed, the screenshot size
  66754. * will be derived from the parameters. The precision property is a multiplier allowing
  66755. * rendering at a higher or lower resolution
  66756. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66757. * Check your browser for supported MIME types
  66758. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66759. * to the src parameter of an <img> to display it
  66760. */
  66761. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66762. /**
  66763. * Generates an image screenshot from the specified camera.
  66764. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66765. * @param engine The engine to use for rendering
  66766. * @param camera The camera to use for rendering
  66767. * @param size This parameter can be set to a single number or to an object with the
  66768. * following (optional) properties: precision, width, height. If a single number is passed,
  66769. * it will be used for both width and height. If an object is passed, the screenshot size
  66770. * will be derived from the parameters. The precision property is a multiplier allowing
  66771. * rendering at a higher or lower resolution
  66772. * @param successCallback The callback receives a single parameter which contains the
  66773. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66774. * src parameter of an <img> to display it
  66775. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66776. * Check your browser for supported MIME types
  66777. * @param samples Texture samples (default: 1)
  66778. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66779. * @param fileName A name for for the downloaded file.
  66780. */
  66781. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66782. /**
  66783. * Generates an image screenshot from the specified camera.
  66784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66785. * @param engine The engine to use for rendering
  66786. * @param camera The camera to use for rendering
  66787. * @param size This parameter can be set to a single number or to an object with the
  66788. * following (optional) properties: precision, width, height. If a single number is passed,
  66789. * it will be used for both width and height. If an object is passed, the screenshot size
  66790. * will be derived from the parameters. The precision property is a multiplier allowing
  66791. * rendering at a higher or lower resolution
  66792. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66793. * Check your browser for supported MIME types
  66794. * @param samples Texture samples (default: 1)
  66795. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66796. * @param fileName A name for for the downloaded file.
  66797. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66798. * to the src parameter of an <img> to display it
  66799. */
  66800. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66801. /**
  66802. * Gets height and width for screenshot size
  66803. * @private
  66804. */
  66805. private static _getScreenshotSize;
  66806. }
  66807. }
  66808. declare module BABYLON {
  66809. /**
  66810. * Interface for a data buffer
  66811. */
  66812. export interface IDataBuffer {
  66813. /**
  66814. * Reads bytes from the data buffer.
  66815. * @param byteOffset The byte offset to read
  66816. * @param byteLength The byte length to read
  66817. * @returns A promise that resolves when the bytes are read
  66818. */
  66819. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66820. /**
  66821. * The byte length of the buffer.
  66822. */
  66823. readonly byteLength: number;
  66824. }
  66825. /**
  66826. * Utility class for reading from a data buffer
  66827. */
  66828. export class DataReader {
  66829. /**
  66830. * The data buffer associated with this data reader.
  66831. */
  66832. readonly buffer: IDataBuffer;
  66833. /**
  66834. * The current byte offset from the beginning of the data buffer.
  66835. */
  66836. byteOffset: number;
  66837. private _dataView;
  66838. private _dataByteOffset;
  66839. /**
  66840. * Constructor
  66841. * @param buffer The buffer to read
  66842. */
  66843. constructor(buffer: IDataBuffer);
  66844. /**
  66845. * Loads the given byte length.
  66846. * @param byteLength The byte length to load
  66847. * @returns A promise that resolves when the load is complete
  66848. */
  66849. loadAsync(byteLength: number): Promise<void>;
  66850. /**
  66851. * Read a unsigned 32-bit integer from the currently loaded data range.
  66852. * @returns The 32-bit integer read
  66853. */
  66854. readUint32(): number;
  66855. /**
  66856. * Read a byte array from the currently loaded data range.
  66857. * @param byteLength The byte length to read
  66858. * @returns The byte array read
  66859. */
  66860. readUint8Array(byteLength: number): Uint8Array;
  66861. /**
  66862. * Read a string from the currently loaded data range.
  66863. * @param byteLength The byte length to read
  66864. * @returns The string read
  66865. */
  66866. readString(byteLength: number): string;
  66867. /**
  66868. * Skips the given byte length the currently loaded data range.
  66869. * @param byteLength The byte length to skip
  66870. */
  66871. skipBytes(byteLength: number): void;
  66872. }
  66873. }
  66874. declare module BABYLON {
  66875. /**
  66876. * A cursor which tracks a point on a path
  66877. */
  66878. export class PathCursor {
  66879. private path;
  66880. /**
  66881. * Stores path cursor callbacks for when an onchange event is triggered
  66882. */
  66883. private _onchange;
  66884. /**
  66885. * The value of the path cursor
  66886. */
  66887. value: number;
  66888. /**
  66889. * The animation array of the path cursor
  66890. */
  66891. animations: Animation[];
  66892. /**
  66893. * Initializes the path cursor
  66894. * @param path The path to track
  66895. */
  66896. constructor(path: Path2);
  66897. /**
  66898. * Gets the cursor point on the path
  66899. * @returns A point on the path cursor at the cursor location
  66900. */
  66901. getPoint(): Vector3;
  66902. /**
  66903. * Moves the cursor ahead by the step amount
  66904. * @param step The amount to move the cursor forward
  66905. * @returns This path cursor
  66906. */
  66907. moveAhead(step?: number): PathCursor;
  66908. /**
  66909. * Moves the cursor behind by the step amount
  66910. * @param step The amount to move the cursor back
  66911. * @returns This path cursor
  66912. */
  66913. moveBack(step?: number): PathCursor;
  66914. /**
  66915. * Moves the cursor by the step amount
  66916. * If the step amount is greater than one, an exception is thrown
  66917. * @param step The amount to move the cursor
  66918. * @returns This path cursor
  66919. */
  66920. move(step: number): PathCursor;
  66921. /**
  66922. * Ensures that the value is limited between zero and one
  66923. * @returns This path cursor
  66924. */
  66925. private ensureLimits;
  66926. /**
  66927. * Runs onchange callbacks on change (used by the animation engine)
  66928. * @returns This path cursor
  66929. */
  66930. private raiseOnChange;
  66931. /**
  66932. * Executes a function on change
  66933. * @param f A path cursor onchange callback
  66934. * @returns This path cursor
  66935. */
  66936. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66937. }
  66938. }
  66939. declare module BABYLON {
  66940. /** @hidden */
  66941. export var blurPixelShader: {
  66942. name: string;
  66943. shader: string;
  66944. };
  66945. }
  66946. declare module BABYLON {
  66947. /** @hidden */
  66948. export var pointCloudVertexDeclaration: {
  66949. name: string;
  66950. shader: string;
  66951. };
  66952. }
  66953. // Mixins
  66954. interface Window {
  66955. mozIndexedDB: IDBFactory;
  66956. webkitIndexedDB: IDBFactory;
  66957. msIndexedDB: IDBFactory;
  66958. webkitURL: typeof URL;
  66959. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66960. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66961. WebGLRenderingContext: WebGLRenderingContext;
  66962. MSGesture: MSGesture;
  66963. CANNON: any;
  66964. AudioContext: AudioContext;
  66965. webkitAudioContext: AudioContext;
  66966. PointerEvent: any;
  66967. Math: Math;
  66968. Uint8Array: Uint8ArrayConstructor;
  66969. Float32Array: Float32ArrayConstructor;
  66970. mozURL: typeof URL;
  66971. msURL: typeof URL;
  66972. VRFrameData: any; // WebVR, from specs 1.1
  66973. DracoDecoderModule: any;
  66974. setImmediate(handler: (...args: any[]) => void): number;
  66975. }
  66976. interface HTMLCanvasElement {
  66977. requestPointerLock(): void;
  66978. msRequestPointerLock?(): void;
  66979. mozRequestPointerLock?(): void;
  66980. webkitRequestPointerLock?(): void;
  66981. /** Track wether a record is in progress */
  66982. isRecording: boolean;
  66983. /** Capture Stream method defined by some browsers */
  66984. captureStream(fps?: number): MediaStream;
  66985. }
  66986. interface CanvasRenderingContext2D {
  66987. msImageSmoothingEnabled: boolean;
  66988. }
  66989. interface MouseEvent {
  66990. mozMovementX: number;
  66991. mozMovementY: number;
  66992. webkitMovementX: number;
  66993. webkitMovementY: number;
  66994. msMovementX: number;
  66995. msMovementY: number;
  66996. }
  66997. interface Navigator {
  66998. mozGetVRDevices: (any: any) => any;
  66999. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67000. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67001. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67002. webkitGetGamepads(): Gamepad[];
  67003. msGetGamepads(): Gamepad[];
  67004. webkitGamepads(): Gamepad[];
  67005. }
  67006. interface HTMLVideoElement {
  67007. mozSrcObject: any;
  67008. }
  67009. interface Math {
  67010. fround(x: number): number;
  67011. imul(a: number, b: number): number;
  67012. }
  67013. interface WebGLRenderingContext {
  67014. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  67015. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  67016. vertexAttribDivisor(index: number, divisor: number): void;
  67017. createVertexArray(): any;
  67018. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  67019. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  67020. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  67021. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  67022. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  67023. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  67024. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  67025. // Queries
  67026. createQuery(): WebGLQuery;
  67027. deleteQuery(query: WebGLQuery): void;
  67028. beginQuery(target: number, query: WebGLQuery): void;
  67029. endQuery(target: number): void;
  67030. getQueryParameter(query: WebGLQuery, pname: number): any;
  67031. getQuery(target: number, pname: number): any;
  67032. MAX_SAMPLES: number;
  67033. RGBA8: number;
  67034. READ_FRAMEBUFFER: number;
  67035. DRAW_FRAMEBUFFER: number;
  67036. UNIFORM_BUFFER: number;
  67037. HALF_FLOAT_OES: number;
  67038. RGBA16F: number;
  67039. RGBA32F: number;
  67040. R32F: number;
  67041. RG32F: number;
  67042. RGB32F: number;
  67043. R16F: number;
  67044. RG16F: number;
  67045. RGB16F: number;
  67046. RED: number;
  67047. RG: number;
  67048. R8: number;
  67049. RG8: number;
  67050. UNSIGNED_INT_24_8: number;
  67051. DEPTH24_STENCIL8: number;
  67052. MIN: number;
  67053. MAX: number;
  67054. /* Multiple Render Targets */
  67055. drawBuffers(buffers: number[]): void;
  67056. readBuffer(src: number): void;
  67057. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  67058. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  67059. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  67060. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  67061. // Occlusion Query
  67062. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  67063. ANY_SAMPLES_PASSED: number;
  67064. QUERY_RESULT_AVAILABLE: number;
  67065. QUERY_RESULT: number;
  67066. }
  67067. interface WebGLProgram {
  67068. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  67069. }
  67070. interface EXT_disjoint_timer_query {
  67071. QUERY_COUNTER_BITS_EXT: number;
  67072. TIME_ELAPSED_EXT: number;
  67073. TIMESTAMP_EXT: number;
  67074. GPU_DISJOINT_EXT: number;
  67075. QUERY_RESULT_EXT: number;
  67076. QUERY_RESULT_AVAILABLE_EXT: number;
  67077. queryCounterEXT(query: WebGLQuery, target: number): void;
  67078. createQueryEXT(): WebGLQuery;
  67079. beginQueryEXT(target: number, query: WebGLQuery): void;
  67080. endQueryEXT(target: number): void;
  67081. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  67082. deleteQueryEXT(query: WebGLQuery): void;
  67083. }
  67084. interface WebGLUniformLocation {
  67085. _currentState: any;
  67086. }
  67087. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  67088. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  67089. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  67090. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67091. interface WebGLRenderingContext {
  67092. readonly RASTERIZER_DISCARD: number;
  67093. readonly DEPTH_COMPONENT24: number;
  67094. readonly TEXTURE_3D: number;
  67095. readonly TEXTURE_2D_ARRAY: number;
  67096. readonly TEXTURE_COMPARE_FUNC: number;
  67097. readonly TEXTURE_COMPARE_MODE: number;
  67098. readonly COMPARE_REF_TO_TEXTURE: number;
  67099. readonly TEXTURE_WRAP_R: number;
  67100. readonly HALF_FLOAT: number;
  67101. readonly RGB8: number;
  67102. readonly RED_INTEGER: number;
  67103. readonly RG_INTEGER: number;
  67104. readonly RGB_INTEGER: number;
  67105. readonly RGBA_INTEGER: number;
  67106. readonly R8_SNORM: number;
  67107. readonly RG8_SNORM: number;
  67108. readonly RGB8_SNORM: number;
  67109. readonly RGBA8_SNORM: number;
  67110. readonly R8I: number;
  67111. readonly RG8I: number;
  67112. readonly RGB8I: number;
  67113. readonly RGBA8I: number;
  67114. readonly R8UI: number;
  67115. readonly RG8UI: number;
  67116. readonly RGB8UI: number;
  67117. readonly RGBA8UI: number;
  67118. readonly R16I: number;
  67119. readonly RG16I: number;
  67120. readonly RGB16I: number;
  67121. readonly RGBA16I: number;
  67122. readonly R16UI: number;
  67123. readonly RG16UI: number;
  67124. readonly RGB16UI: number;
  67125. readonly RGBA16UI: number;
  67126. readonly R32I: number;
  67127. readonly RG32I: number;
  67128. readonly RGB32I: number;
  67129. readonly RGBA32I: number;
  67130. readonly R32UI: number;
  67131. readonly RG32UI: number;
  67132. readonly RGB32UI: number;
  67133. readonly RGBA32UI: number;
  67134. readonly RGB10_A2UI: number;
  67135. readonly R11F_G11F_B10F: number;
  67136. readonly RGB9_E5: number;
  67137. readonly RGB10_A2: number;
  67138. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67139. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67140. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67141. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67142. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67143. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67144. 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;
  67145. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67146. readonly TRANSFORM_FEEDBACK: number;
  67147. readonly INTERLEAVED_ATTRIBS: number;
  67148. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67149. createTransformFeedback(): WebGLTransformFeedback;
  67150. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67151. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67152. beginTransformFeedback(primitiveMode: number): void;
  67153. endTransformFeedback(): void;
  67154. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67155. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67156. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67157. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67158. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67159. }
  67160. interface ImageBitmap {
  67161. readonly width: number;
  67162. readonly height: number;
  67163. close(): void;
  67164. }
  67165. interface WebGLQuery extends WebGLObject {
  67166. }
  67167. declare var WebGLQuery: {
  67168. prototype: WebGLQuery;
  67169. new(): WebGLQuery;
  67170. };
  67171. interface WebGLSampler extends WebGLObject {
  67172. }
  67173. declare var WebGLSampler: {
  67174. prototype: WebGLSampler;
  67175. new(): WebGLSampler;
  67176. };
  67177. interface WebGLSync extends WebGLObject {
  67178. }
  67179. declare var WebGLSync: {
  67180. prototype: WebGLSync;
  67181. new(): WebGLSync;
  67182. };
  67183. interface WebGLTransformFeedback extends WebGLObject {
  67184. }
  67185. declare var WebGLTransformFeedback: {
  67186. prototype: WebGLTransformFeedback;
  67187. new(): WebGLTransformFeedback;
  67188. };
  67189. interface WebGLVertexArrayObject extends WebGLObject {
  67190. }
  67191. declare var WebGLVertexArrayObject: {
  67192. prototype: WebGLVertexArrayObject;
  67193. new(): WebGLVertexArrayObject;
  67194. };
  67195. // Type definitions for WebVR API
  67196. // Project: https://w3c.github.io/webvr/
  67197. // Definitions by: six a <https://github.com/lostfictions>
  67198. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67199. interface VRDisplay extends EventTarget {
  67200. /**
  67201. * Dictionary of capabilities describing the VRDisplay.
  67202. */
  67203. readonly capabilities: VRDisplayCapabilities;
  67204. /**
  67205. * z-depth defining the far plane of the eye view frustum
  67206. * enables mapping of values in the render target depth
  67207. * attachment to scene coordinates. Initially set to 10000.0.
  67208. */
  67209. depthFar: number;
  67210. /**
  67211. * z-depth defining the near plane of the eye view frustum
  67212. * enables mapping of values in the render target depth
  67213. * attachment to scene coordinates. Initially set to 0.01.
  67214. */
  67215. depthNear: number;
  67216. /**
  67217. * An identifier for this distinct VRDisplay. Used as an
  67218. * association point in the Gamepad API.
  67219. */
  67220. readonly displayId: number;
  67221. /**
  67222. * A display name, a user-readable name identifying it.
  67223. */
  67224. readonly displayName: string;
  67225. readonly isConnected: boolean;
  67226. readonly isPresenting: boolean;
  67227. /**
  67228. * If this VRDisplay supports room-scale experiences, the optional
  67229. * stage attribute contains details on the room-scale parameters.
  67230. */
  67231. readonly stageParameters: VRStageParameters | null;
  67232. /**
  67233. * Passing the value returned by `requestAnimationFrame` to
  67234. * `cancelAnimationFrame` will unregister the callback.
  67235. * @param handle Define the hanle of the request to cancel
  67236. */
  67237. cancelAnimationFrame(handle: number): void;
  67238. /**
  67239. * Stops presenting to the VRDisplay.
  67240. * @returns a promise to know when it stopped
  67241. */
  67242. exitPresent(): Promise<void>;
  67243. /**
  67244. * Return the current VREyeParameters for the given eye.
  67245. * @param whichEye Define the eye we want the parameter for
  67246. * @returns the eye parameters
  67247. */
  67248. getEyeParameters(whichEye: string): VREyeParameters;
  67249. /**
  67250. * Populates the passed VRFrameData with the information required to render
  67251. * the current frame.
  67252. * @param frameData Define the data structure to populate
  67253. * @returns true if ok otherwise false
  67254. */
  67255. getFrameData(frameData: VRFrameData): boolean;
  67256. /**
  67257. * Get the layers currently being presented.
  67258. * @returns the list of VR layers
  67259. */
  67260. getLayers(): VRLayer[];
  67261. /**
  67262. * Return a VRPose containing the future predicted pose of the VRDisplay
  67263. * when the current frame will be presented. The value returned will not
  67264. * change until JavaScript has returned control to the browser.
  67265. *
  67266. * The VRPose will contain the position, orientation, velocity,
  67267. * and acceleration of each of these properties.
  67268. * @returns the pose object
  67269. */
  67270. getPose(): VRPose;
  67271. /**
  67272. * Return the current instantaneous pose of the VRDisplay, with no
  67273. * prediction applied.
  67274. * @returns the current instantaneous pose
  67275. */
  67276. getImmediatePose(): VRPose;
  67277. /**
  67278. * The callback passed to `requestAnimationFrame` will be called
  67279. * any time a new frame should be rendered. When the VRDisplay is
  67280. * presenting the callback will be called at the native refresh
  67281. * rate of the HMD. When not presenting this function acts
  67282. * identically to how window.requestAnimationFrame acts. Content should
  67283. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67284. * asynchronously from other displays and at differing refresh rates.
  67285. * @param callback Define the eaction to run next frame
  67286. * @returns the request handle it
  67287. */
  67288. requestAnimationFrame(callback: FrameRequestCallback): number;
  67289. /**
  67290. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67291. * Repeat calls while already presenting will update the VRLayers being displayed.
  67292. * @param layers Define the list of layer to present
  67293. * @returns a promise to know when the request has been fulfilled
  67294. */
  67295. requestPresent(layers: VRLayer[]): Promise<void>;
  67296. /**
  67297. * Reset the pose for this display, treating its current position and
  67298. * orientation as the "origin/zero" values. VRPose.position,
  67299. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67300. * updated when calling resetPose(). This should be called in only
  67301. * sitting-space experiences.
  67302. */
  67303. resetPose(): void;
  67304. /**
  67305. * The VRLayer provided to the VRDisplay will be captured and presented
  67306. * in the HMD. Calling this function has the same effect on the source
  67307. * canvas as any other operation that uses its source image, and canvases
  67308. * created without preserveDrawingBuffer set to true will be cleared.
  67309. * @param pose Define the pose to submit
  67310. */
  67311. submitFrame(pose?: VRPose): void;
  67312. }
  67313. declare var VRDisplay: {
  67314. prototype: VRDisplay;
  67315. new(): VRDisplay;
  67316. };
  67317. interface VRLayer {
  67318. leftBounds?: number[] | Float32Array | null;
  67319. rightBounds?: number[] | Float32Array | null;
  67320. source?: HTMLCanvasElement | null;
  67321. }
  67322. interface VRDisplayCapabilities {
  67323. readonly canPresent: boolean;
  67324. readonly hasExternalDisplay: boolean;
  67325. readonly hasOrientation: boolean;
  67326. readonly hasPosition: boolean;
  67327. readonly maxLayers: number;
  67328. }
  67329. interface VREyeParameters {
  67330. /** @deprecated */
  67331. readonly fieldOfView: VRFieldOfView;
  67332. readonly offset: Float32Array;
  67333. readonly renderHeight: number;
  67334. readonly renderWidth: number;
  67335. }
  67336. interface VRFieldOfView {
  67337. readonly downDegrees: number;
  67338. readonly leftDegrees: number;
  67339. readonly rightDegrees: number;
  67340. readonly upDegrees: number;
  67341. }
  67342. interface VRFrameData {
  67343. readonly leftProjectionMatrix: Float32Array;
  67344. readonly leftViewMatrix: Float32Array;
  67345. readonly pose: VRPose;
  67346. readonly rightProjectionMatrix: Float32Array;
  67347. readonly rightViewMatrix: Float32Array;
  67348. readonly timestamp: number;
  67349. }
  67350. interface VRPose {
  67351. readonly angularAcceleration: Float32Array | null;
  67352. readonly angularVelocity: Float32Array | null;
  67353. readonly linearAcceleration: Float32Array | null;
  67354. readonly linearVelocity: Float32Array | null;
  67355. readonly orientation: Float32Array | null;
  67356. readonly position: Float32Array | null;
  67357. readonly timestamp: number;
  67358. }
  67359. interface VRStageParameters {
  67360. sittingToStandingTransform?: Float32Array;
  67361. sizeX?: number;
  67362. sizeY?: number;
  67363. }
  67364. interface Navigator {
  67365. getVRDisplays(): Promise<VRDisplay[]>;
  67366. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67367. }
  67368. interface Window {
  67369. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67370. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67371. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67372. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67373. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67374. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67375. }
  67376. interface Gamepad {
  67377. readonly displayId: number;
  67378. }
  67379. type XRSessionMode =
  67380. | "inline"
  67381. | "immersive-vr"
  67382. | "immersive-ar";
  67383. type XRReferenceSpaceType =
  67384. | "viewer"
  67385. | "local"
  67386. | "local-floor"
  67387. | "bounded-floor"
  67388. | "unbounded";
  67389. type XREnvironmentBlendMode =
  67390. | "opaque"
  67391. | "additive"
  67392. | "alpha-blend";
  67393. type XRVisibilityState =
  67394. | "visible"
  67395. | "visible-blurred"
  67396. | "hidden";
  67397. type XRHandedness =
  67398. | "none"
  67399. | "left"
  67400. | "right";
  67401. type XRTargetRayMode =
  67402. | "gaze"
  67403. | "tracked-pointer"
  67404. | "screen";
  67405. type XREye =
  67406. | "none"
  67407. | "left"
  67408. | "right";
  67409. interface XRSpace extends EventTarget {
  67410. }
  67411. interface XRRenderState {
  67412. depthNear?: number;
  67413. depthFar?: number;
  67414. inlineVerticalFieldOfView?: number;
  67415. baseLayer?: XRWebGLLayer;
  67416. }
  67417. interface XRInputSource {
  67418. handedness: XRHandedness;
  67419. targetRayMode: XRTargetRayMode;
  67420. targetRaySpace: XRSpace;
  67421. gripSpace: XRSpace | undefined;
  67422. gamepad: Gamepad | undefined;
  67423. profiles: Array<string>;
  67424. }
  67425. interface XRSession extends XRAnchorCreator {
  67426. addEventListener: Function;
  67427. removeEventListener: Function;
  67428. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67429. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67430. requestAnimationFrame: Function;
  67431. end(): Promise<void>;
  67432. renderState: XRRenderState;
  67433. inputSources: Array<XRInputSource>;
  67434. // AR hit test
  67435. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67436. updateWorldTrackingState(options: {
  67437. planeDetectionState?: { enabled: boolean; }
  67438. }): void;
  67439. }
  67440. interface XRReferenceSpace extends XRSpace {
  67441. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67442. onreset: any;
  67443. }
  67444. type XRPlaneSet = Set<XRPlane>;
  67445. type XRAnchorSet = Set<XRAnchor>;
  67446. interface XRFrame {
  67447. session: XRSession;
  67448. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67449. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67450. // Anchors
  67451. trackedAnchors?: XRAnchorSet;
  67452. // Planes
  67453. worldInformation: {
  67454. detectedPlanes?: XRPlaneSet;
  67455. };
  67456. }
  67457. interface XRViewerPose extends XRPose {
  67458. views: Array<XRView>;
  67459. }
  67460. interface XRPose {
  67461. transform: XRRigidTransform;
  67462. emulatedPosition: boolean;
  67463. }
  67464. interface XRWebGLLayerOptions {
  67465. antialias?: boolean;
  67466. depth?: boolean;
  67467. stencil?: boolean;
  67468. alpha?: boolean;
  67469. multiview?: boolean;
  67470. framebufferScaleFactor?: number;
  67471. }
  67472. declare var XRWebGLLayer: {
  67473. prototype: XRWebGLLayer;
  67474. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67475. };
  67476. interface XRWebGLLayer {
  67477. framebuffer: WebGLFramebuffer;
  67478. framebufferWidth: number;
  67479. framebufferHeight: number;
  67480. getViewport: Function;
  67481. }
  67482. declare class XRRigidTransform {
  67483. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  67484. position: DOMPointReadOnly;
  67485. orientation: DOMPointReadOnly;
  67486. matrix: Float32Array;
  67487. inverse: XRRigidTransform;
  67488. }
  67489. interface XRView {
  67490. eye: XREye;
  67491. projectionMatrix: Float32Array;
  67492. transform: XRRigidTransform;
  67493. }
  67494. interface XRInputSourceChangeEvent {
  67495. session: XRSession;
  67496. removed: Array<XRInputSource>;
  67497. added: Array<XRInputSource>;
  67498. }
  67499. interface XRInputSourceEvent extends Event {
  67500. readonly frame: XRFrame;
  67501. readonly inputSource: XRInputSource;
  67502. }
  67503. // Experimental(er) features
  67504. declare class XRRay {
  67505. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  67506. origin: DOMPointReadOnly;
  67507. direction: DOMPointReadOnly;
  67508. matrix: Float32Array;
  67509. }
  67510. interface XRHitResult {
  67511. hitMatrix: Float32Array;
  67512. }
  67513. interface XRAnchor {
  67514. // remove?
  67515. id?: string;
  67516. anchorSpace: XRSpace;
  67517. lastChangedTime: number;
  67518. detach(): void;
  67519. }
  67520. interface XRPlane extends XRAnchorCreator {
  67521. orientation: "Horizontal" | "Vertical";
  67522. planeSpace: XRSpace;
  67523. polygon: Array<DOMPointReadOnly>;
  67524. lastChangedTime: number;
  67525. }
  67526. interface XRAnchorCreator {
  67527. // AR Anchors
  67528. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67529. }
  67530. /**
  67531. * @ignore
  67532. */
  67533. declare module BABYLON.GLTF2.Exporter {
  67534. }
  67535. /**
  67536. * @ignore
  67537. */
  67538. declare module BABYLON.GLTF1 {
  67539. }
  67540. declare module BABYLON.GUI {
  67541. /**
  67542. * Class used to specific a value and its associated unit
  67543. */
  67544. export class ValueAndUnit {
  67545. /** defines the unit to store */
  67546. unit: number;
  67547. /** defines a boolean indicating if the value can be negative */
  67548. negativeValueAllowed: boolean;
  67549. private _value;
  67550. private _originalUnit;
  67551. /**
  67552. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  67553. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67554. */
  67555. ignoreAdaptiveScaling: boolean;
  67556. /**
  67557. * Creates a new ValueAndUnit
  67558. * @param value defines the value to store
  67559. * @param unit defines the unit to store
  67560. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  67561. */
  67562. constructor(value: number,
  67563. /** defines the unit to store */
  67564. unit?: number,
  67565. /** defines a boolean indicating if the value can be negative */
  67566. negativeValueAllowed?: boolean);
  67567. /** Gets a boolean indicating if the value is a percentage */
  67568. get isPercentage(): boolean;
  67569. /** Gets a boolean indicating if the value is store as pixel */
  67570. get isPixel(): boolean;
  67571. /** Gets direct internal value */
  67572. get internalValue(): number;
  67573. /**
  67574. * Gets value as pixel
  67575. * @param host defines the root host
  67576. * @param refValue defines the reference value for percentages
  67577. * @returns the value as pixel
  67578. */
  67579. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  67580. /**
  67581. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  67582. * @param value defines the value to store
  67583. * @param unit defines the unit to store
  67584. * @returns the current ValueAndUnit
  67585. */
  67586. updateInPlace(value: number, unit?: number): ValueAndUnit;
  67587. /**
  67588. * Gets the value accordingly to its unit
  67589. * @param host defines the root host
  67590. * @returns the value
  67591. */
  67592. getValue(host: AdvancedDynamicTexture): number;
  67593. /**
  67594. * Gets a string representation of the value
  67595. * @param host defines the root host
  67596. * @param decimals defines an optional number of decimals to display
  67597. * @returns a string
  67598. */
  67599. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  67600. /**
  67601. * Store a value parsed from a string
  67602. * @param source defines the source string
  67603. * @returns true if the value was successfully parsed
  67604. */
  67605. fromString(source: string | number): boolean;
  67606. private static _Regex;
  67607. private static _UNITMODE_PERCENTAGE;
  67608. private static _UNITMODE_PIXEL;
  67609. /** UNITMODE_PERCENTAGE */
  67610. static get UNITMODE_PERCENTAGE(): number;
  67611. /** UNITMODE_PIXEL */
  67612. static get UNITMODE_PIXEL(): number;
  67613. }
  67614. }
  67615. declare module BABYLON.GUI {
  67616. /**
  67617. * Define a style used by control to automatically setup properties based on a template.
  67618. * Only support font related properties so far
  67619. */
  67620. export class Style implements BABYLON.IDisposable {
  67621. private _fontFamily;
  67622. private _fontStyle;
  67623. private _fontWeight;
  67624. /** @hidden */
  67625. _host: AdvancedDynamicTexture;
  67626. /** @hidden */
  67627. _fontSize: ValueAndUnit;
  67628. /**
  67629. * BABYLON.Observable raised when the style values are changed
  67630. */
  67631. onChangedObservable: BABYLON.Observable<Style>;
  67632. /**
  67633. * Creates a new style object
  67634. * @param host defines the AdvancedDynamicTexture which hosts this style
  67635. */
  67636. constructor(host: AdvancedDynamicTexture);
  67637. /**
  67638. * Gets or sets the font size
  67639. */
  67640. get fontSize(): string | number;
  67641. set fontSize(value: string | number);
  67642. /**
  67643. * Gets or sets the font family
  67644. */
  67645. get fontFamily(): string;
  67646. set fontFamily(value: string);
  67647. /**
  67648. * Gets or sets the font style
  67649. */
  67650. get fontStyle(): string;
  67651. set fontStyle(value: string);
  67652. /** Gets or sets font weight */
  67653. get fontWeight(): string;
  67654. set fontWeight(value: string);
  67655. /** Dispose all associated resources */
  67656. dispose(): void;
  67657. }
  67658. }
  67659. declare module BABYLON.GUI {
  67660. /**
  67661. * Class used to transport BABYLON.Vector2 information for pointer events
  67662. */
  67663. export class Vector2WithInfo extends BABYLON.Vector2 {
  67664. /** defines the current mouse button index */
  67665. buttonIndex: number;
  67666. /**
  67667. * Creates a new Vector2WithInfo
  67668. * @param source defines the vector2 data to transport
  67669. * @param buttonIndex defines the current mouse button index
  67670. */
  67671. constructor(source: BABYLON.Vector2,
  67672. /** defines the current mouse button index */
  67673. buttonIndex?: number);
  67674. }
  67675. /** Class used to provide 2D matrix features */
  67676. export class Matrix2D {
  67677. /** Gets the internal array of 6 floats used to store matrix data */
  67678. m: Float32Array;
  67679. /**
  67680. * Creates a new matrix
  67681. * @param m00 defines value for (0, 0)
  67682. * @param m01 defines value for (0, 1)
  67683. * @param m10 defines value for (1, 0)
  67684. * @param m11 defines value for (1, 1)
  67685. * @param m20 defines value for (2, 0)
  67686. * @param m21 defines value for (2, 1)
  67687. */
  67688. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  67689. /**
  67690. * Fills the matrix from direct values
  67691. * @param m00 defines value for (0, 0)
  67692. * @param m01 defines value for (0, 1)
  67693. * @param m10 defines value for (1, 0)
  67694. * @param m11 defines value for (1, 1)
  67695. * @param m20 defines value for (2, 0)
  67696. * @param m21 defines value for (2, 1)
  67697. * @returns the current modified matrix
  67698. */
  67699. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  67700. /**
  67701. * Gets matrix determinant
  67702. * @returns the determinant
  67703. */
  67704. determinant(): number;
  67705. /**
  67706. * Inverses the matrix and stores it in a target matrix
  67707. * @param result defines the target matrix
  67708. * @returns the current matrix
  67709. */
  67710. invertToRef(result: Matrix2D): Matrix2D;
  67711. /**
  67712. * Multiplies the current matrix with another one
  67713. * @param other defines the second operand
  67714. * @param result defines the target matrix
  67715. * @returns the current matrix
  67716. */
  67717. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67718. /**
  67719. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67720. * @param x defines the x coordinate to transform
  67721. * @param y defines the x coordinate to transform
  67722. * @param result defines the target vector2
  67723. * @returns the current matrix
  67724. */
  67725. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67726. /**
  67727. * Creates an identity matrix
  67728. * @returns a new matrix
  67729. */
  67730. static Identity(): Matrix2D;
  67731. /**
  67732. * Creates a translation matrix and stores it in a target matrix
  67733. * @param x defines the x coordinate of the translation
  67734. * @param y defines the y coordinate of the translation
  67735. * @param result defines the target matrix
  67736. */
  67737. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67738. /**
  67739. * Creates a scaling matrix and stores it in a target matrix
  67740. * @param x defines the x coordinate of the scaling
  67741. * @param y defines the y coordinate of the scaling
  67742. * @param result defines the target matrix
  67743. */
  67744. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67745. /**
  67746. * Creates a rotation matrix and stores it in a target matrix
  67747. * @param angle defines the rotation angle
  67748. * @param result defines the target matrix
  67749. */
  67750. static RotationToRef(angle: number, result: Matrix2D): void;
  67751. private static _TempPreTranslationMatrix;
  67752. private static _TempPostTranslationMatrix;
  67753. private static _TempRotationMatrix;
  67754. private static _TempScalingMatrix;
  67755. private static _TempCompose0;
  67756. private static _TempCompose1;
  67757. private static _TempCompose2;
  67758. /**
  67759. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67760. * @param tx defines the x coordinate of the translation
  67761. * @param ty defines the y coordinate of the translation
  67762. * @param angle defines the rotation angle
  67763. * @param scaleX defines the x coordinate of the scaling
  67764. * @param scaleY defines the y coordinate of the scaling
  67765. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67766. * @param result defines the target matrix
  67767. */
  67768. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67769. }
  67770. }
  67771. declare module BABYLON.GUI {
  67772. /**
  67773. * Class used to store 2D control sizes
  67774. */
  67775. export class Measure {
  67776. /** defines left coordinate */
  67777. left: number;
  67778. /** defines top coordinate */
  67779. top: number;
  67780. /** defines width dimension */
  67781. width: number;
  67782. /** defines height dimension */
  67783. height: number;
  67784. /**
  67785. * Creates a new measure
  67786. * @param left defines left coordinate
  67787. * @param top defines top coordinate
  67788. * @param width defines width dimension
  67789. * @param height defines height dimension
  67790. */
  67791. constructor(
  67792. /** defines left coordinate */
  67793. left: number,
  67794. /** defines top coordinate */
  67795. top: number,
  67796. /** defines width dimension */
  67797. width: number,
  67798. /** defines height dimension */
  67799. height: number);
  67800. /**
  67801. * Copy from another measure
  67802. * @param other defines the other measure to copy from
  67803. */
  67804. copyFrom(other: Measure): void;
  67805. /**
  67806. * Copy from a group of 4 floats
  67807. * @param left defines left coordinate
  67808. * @param top defines top coordinate
  67809. * @param width defines width dimension
  67810. * @param height defines height dimension
  67811. */
  67812. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67813. /**
  67814. * Computes the axis aligned bounding box measure for two given measures
  67815. * @param a Input measure
  67816. * @param b Input measure
  67817. * @param result the resulting bounding measure
  67818. */
  67819. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67820. /**
  67821. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67822. * @param transform the matrix to transform the measure before computing the AABB
  67823. * @param result the resulting AABB
  67824. */
  67825. transformToRef(transform: Matrix2D, result: Measure): void;
  67826. /**
  67827. * Check equality between this measure and another one
  67828. * @param other defines the other measures
  67829. * @returns true if both measures are equals
  67830. */
  67831. isEqualsTo(other: Measure): boolean;
  67832. /**
  67833. * Creates an empty measure
  67834. * @returns a new measure
  67835. */
  67836. static Empty(): Measure;
  67837. }
  67838. }
  67839. declare module BABYLON.GUI {
  67840. /**
  67841. * Interface used to define a control that can receive focus
  67842. */
  67843. export interface IFocusableControl {
  67844. /**
  67845. * Function called when the control receives the focus
  67846. */
  67847. onFocus(): void;
  67848. /**
  67849. * Function called when the control loses the focus
  67850. */
  67851. onBlur(): void;
  67852. /**
  67853. * Function called to let the control handle keyboard events
  67854. * @param evt defines the current keyboard event
  67855. */
  67856. processKeyboard(evt: KeyboardEvent): void;
  67857. /**
  67858. * Function called to get the list of controls that should not steal the focus from this control
  67859. * @returns an array of controls
  67860. */
  67861. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67862. }
  67863. /**
  67864. * Class used to create texture to support 2D GUI elements
  67865. * @see http://doc.babylonjs.com/how_to/gui
  67866. */
  67867. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67868. private _isDirty;
  67869. private _renderObserver;
  67870. private _resizeObserver;
  67871. private _preKeyboardObserver;
  67872. private _pointerMoveObserver;
  67873. private _pointerObserver;
  67874. private _canvasPointerOutObserver;
  67875. private _background;
  67876. /** @hidden */
  67877. _rootContainer: Container;
  67878. /** @hidden */
  67879. _lastPickedControl: Control;
  67880. /** @hidden */
  67881. _lastControlOver: {
  67882. [pointerId: number]: Control;
  67883. };
  67884. /** @hidden */
  67885. _lastControlDown: {
  67886. [pointerId: number]: Control;
  67887. };
  67888. /** @hidden */
  67889. _capturingControl: {
  67890. [pointerId: number]: Control;
  67891. };
  67892. /** @hidden */
  67893. _shouldBlockPointer: boolean;
  67894. /** @hidden */
  67895. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67896. /** @hidden */
  67897. _linkedControls: Control[];
  67898. private _isFullscreen;
  67899. private _fullscreenViewport;
  67900. private _idealWidth;
  67901. private _idealHeight;
  67902. private _useSmallestIdeal;
  67903. private _renderAtIdealSize;
  67904. private _focusedControl;
  67905. private _blockNextFocusCheck;
  67906. private _renderScale;
  67907. private _rootElement;
  67908. private _cursorChanged;
  67909. /**
  67910. * Define type to string to ensure compatibility across browsers
  67911. * Safari doesn't support DataTransfer constructor
  67912. */
  67913. private _clipboardData;
  67914. /**
  67915. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67916. */
  67917. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67918. /**
  67919. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67920. */
  67921. onControlPickedObservable: BABYLON.Observable<Control>;
  67922. /**
  67923. * BABYLON.Observable event triggered before layout is evaluated
  67924. */
  67925. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67926. /**
  67927. * BABYLON.Observable event triggered after the layout was evaluated
  67928. */
  67929. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67930. /**
  67931. * BABYLON.Observable event triggered before the texture is rendered
  67932. */
  67933. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67934. /**
  67935. * BABYLON.Observable event triggered after the texture was rendered
  67936. */
  67937. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67938. /**
  67939. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67940. */
  67941. premulAlpha: boolean;
  67942. /**
  67943. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67944. * Useful when you want more antialiasing
  67945. */
  67946. get renderScale(): number;
  67947. set renderScale(value: number);
  67948. /** Gets or sets the background color */
  67949. get background(): string;
  67950. set background(value: string);
  67951. /**
  67952. * Gets or sets the ideal width used to design controls.
  67953. * The GUI will then rescale everything accordingly
  67954. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67955. */
  67956. get idealWidth(): number;
  67957. set idealWidth(value: number);
  67958. /**
  67959. * Gets or sets the ideal height used to design controls.
  67960. * The GUI will then rescale everything accordingly
  67961. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67962. */
  67963. get idealHeight(): number;
  67964. set idealHeight(value: number);
  67965. /**
  67966. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67967. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67968. */
  67969. get useSmallestIdeal(): boolean;
  67970. set useSmallestIdeal(value: boolean);
  67971. /**
  67972. * Gets or sets a boolean indicating if adaptive scaling must be used
  67973. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67974. */
  67975. get renderAtIdealSize(): boolean;
  67976. set renderAtIdealSize(value: boolean);
  67977. /**
  67978. * Gets the underlying layer used to render the texture when in fullscreen mode
  67979. */
  67980. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  67981. /**
  67982. * Gets the root container control
  67983. */
  67984. get rootContainer(): Container;
  67985. /**
  67986. * Returns an array containing the root container.
  67987. * This is mostly used to let the Inspector introspects the ADT
  67988. * @returns an array containing the rootContainer
  67989. */
  67990. getChildren(): Array<Container>;
  67991. /**
  67992. * Will return all controls that are inside this texture
  67993. * @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
  67994. * @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
  67995. * @return all child controls
  67996. */
  67997. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67998. /**
  67999. * Gets or sets the current focused control
  68000. */
  68001. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  68002. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  68003. /**
  68004. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  68005. */
  68006. get isForeground(): boolean;
  68007. set isForeground(value: boolean);
  68008. /**
  68009. * Gets or set information about clipboardData
  68010. */
  68011. get clipboardData(): string;
  68012. set clipboardData(value: string);
  68013. /**
  68014. * Creates a new AdvancedDynamicTexture
  68015. * @param name defines the name of the texture
  68016. * @param width defines the width of the texture
  68017. * @param height defines the height of the texture
  68018. * @param scene defines the hosting scene
  68019. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  68020. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  68021. */
  68022. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  68023. /**
  68024. * Get the current class name of the texture useful for serialization or dynamic coding.
  68025. * @returns "AdvancedDynamicTexture"
  68026. */
  68027. getClassName(): string;
  68028. /**
  68029. * Function used to execute a function on all controls
  68030. * @param func defines the function to execute
  68031. * @param container defines the container where controls belong. If null the root container will be used
  68032. */
  68033. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  68034. private _useInvalidateRectOptimization;
  68035. /**
  68036. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  68037. */
  68038. get useInvalidateRectOptimization(): boolean;
  68039. set useInvalidateRectOptimization(value: boolean);
  68040. private _invalidatedRectangle;
  68041. /**
  68042. * Invalidates a rectangle area on the gui texture
  68043. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  68044. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  68045. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  68046. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  68047. */
  68048. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  68049. /**
  68050. * Marks the texture as dirty forcing a complete update
  68051. */
  68052. markAsDirty(): void;
  68053. /**
  68054. * Helper function used to create a new style
  68055. * @returns a new style
  68056. * @see http://doc.babylonjs.com/how_to/gui#styles
  68057. */
  68058. createStyle(): Style;
  68059. /**
  68060. * Adds a new control to the root container
  68061. * @param control defines the control to add
  68062. * @returns the current texture
  68063. */
  68064. addControl(control: Control): AdvancedDynamicTexture;
  68065. /**
  68066. * Removes a control from the root container
  68067. * @param control defines the control to remove
  68068. * @returns the current texture
  68069. */
  68070. removeControl(control: Control): AdvancedDynamicTexture;
  68071. /**
  68072. * Release all resources
  68073. */
  68074. dispose(): void;
  68075. private _onResize;
  68076. /** @hidden */
  68077. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  68078. /**
  68079. * Get screen coordinates for a vector3
  68080. * @param position defines the position to project
  68081. * @param worldMatrix defines the world matrix to use
  68082. * @returns the projected position
  68083. */
  68084. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  68085. private _checkUpdate;
  68086. private _clearMeasure;
  68087. private _render;
  68088. /** @hidden */
  68089. _changeCursor(cursor: string): void;
  68090. /** @hidden */
  68091. _registerLastControlDown(control: Control, pointerId: number): void;
  68092. private _doPicking;
  68093. /** @hidden */
  68094. _cleanControlAfterRemovalFromList(list: {
  68095. [pointerId: number]: Control;
  68096. }, control: Control): void;
  68097. /** @hidden */
  68098. _cleanControlAfterRemoval(control: Control): void;
  68099. /** Attach to all scene events required to support pointer events */
  68100. attach(): void;
  68101. /** @hidden */
  68102. private onClipboardCopy;
  68103. /** @hidden */
  68104. private onClipboardCut;
  68105. /** @hidden */
  68106. private onClipboardPaste;
  68107. /**
  68108. * Register the clipboard Events onto the canvas
  68109. */
  68110. registerClipboardEvents(): void;
  68111. /**
  68112. * Unregister the clipboard Events from the canvas
  68113. */
  68114. unRegisterClipboardEvents(): void;
  68115. /**
  68116. * Connect the texture to a hosting mesh to enable interactions
  68117. * @param mesh defines the mesh to attach to
  68118. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68119. */
  68120. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68121. /**
  68122. * Move the focus to a specific control
  68123. * @param control defines the control which will receive the focus
  68124. */
  68125. moveFocusToControl(control: IFocusableControl): void;
  68126. private _manageFocus;
  68127. private _attachToOnPointerOut;
  68128. /**
  68129. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68130. * @param mesh defines the mesh which will receive the texture
  68131. * @param width defines the texture width (1024 by default)
  68132. * @param height defines the texture height (1024 by default)
  68133. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68134. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68135. * @returns a new AdvancedDynamicTexture
  68136. */
  68137. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68138. /**
  68139. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68140. * In this mode the texture will rely on a layer for its rendering.
  68141. * This allows it to be treated like any other layer.
  68142. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68143. * LayerMask is set through advancedTexture.layer.layerMask
  68144. * @param name defines name for the texture
  68145. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68146. * @param scene defines the hsoting scene
  68147. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68148. * @returns a new AdvancedDynamicTexture
  68149. */
  68150. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68151. }
  68152. }
  68153. declare module BABYLON.GUI {
  68154. /**
  68155. * Root class used for all 2D controls
  68156. * @see http://doc.babylonjs.com/how_to/gui#controls
  68157. */
  68158. export class Control {
  68159. /** defines the name of the control */
  68160. name?: string | undefined;
  68161. /**
  68162. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68163. */
  68164. static AllowAlphaInheritance: boolean;
  68165. private _alpha;
  68166. private _alphaSet;
  68167. private _zIndex;
  68168. /** @hidden */
  68169. _host: AdvancedDynamicTexture;
  68170. /** Gets or sets the control parent */
  68171. parent: BABYLON.Nullable<Container>;
  68172. /** @hidden */
  68173. _currentMeasure: Measure;
  68174. private _fontFamily;
  68175. private _fontStyle;
  68176. private _fontWeight;
  68177. private _fontSize;
  68178. private _font;
  68179. /** @hidden */
  68180. _width: ValueAndUnit;
  68181. /** @hidden */
  68182. _height: ValueAndUnit;
  68183. /** @hidden */
  68184. protected _fontOffset: {
  68185. ascent: number;
  68186. height: number;
  68187. descent: number;
  68188. };
  68189. private _color;
  68190. private _style;
  68191. private _styleObserver;
  68192. /** @hidden */
  68193. protected _horizontalAlignment: number;
  68194. /** @hidden */
  68195. protected _verticalAlignment: number;
  68196. /** @hidden */
  68197. protected _isDirty: boolean;
  68198. /** @hidden */
  68199. protected _wasDirty: boolean;
  68200. /** @hidden */
  68201. _tempParentMeasure: Measure;
  68202. /** @hidden */
  68203. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68204. /** @hidden */
  68205. protected _cachedParentMeasure: Measure;
  68206. private _paddingLeft;
  68207. private _paddingRight;
  68208. private _paddingTop;
  68209. private _paddingBottom;
  68210. /** @hidden */
  68211. _left: ValueAndUnit;
  68212. /** @hidden */
  68213. _top: ValueAndUnit;
  68214. private _scaleX;
  68215. private _scaleY;
  68216. private _rotation;
  68217. private _transformCenterX;
  68218. private _transformCenterY;
  68219. /** @hidden */
  68220. _transformMatrix: Matrix2D;
  68221. /** @hidden */
  68222. protected _invertTransformMatrix: Matrix2D;
  68223. /** @hidden */
  68224. protected _transformedPosition: BABYLON.Vector2;
  68225. private _isMatrixDirty;
  68226. private _cachedOffsetX;
  68227. private _cachedOffsetY;
  68228. private _isVisible;
  68229. private _isHighlighted;
  68230. /** @hidden */
  68231. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68232. private _fontSet;
  68233. private _dummyVector2;
  68234. private _downCount;
  68235. private _enterCount;
  68236. private _doNotRender;
  68237. private _downPointerIds;
  68238. protected _isEnabled: boolean;
  68239. protected _disabledColor: string;
  68240. /** @hidden */
  68241. protected _rebuildLayout: boolean;
  68242. /** @hidden */
  68243. _isClipped: boolean;
  68244. /** @hidden */
  68245. _automaticSize: boolean;
  68246. /** @hidden */
  68247. _tag: any;
  68248. /**
  68249. * 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
  68250. */
  68251. uniqueId: number;
  68252. /**
  68253. * Gets or sets an object used to store user defined information for the node
  68254. */
  68255. metadata: any;
  68256. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68257. isHitTestVisible: boolean;
  68258. /** Gets or sets a boolean indicating if the control can block pointer events */
  68259. isPointerBlocker: boolean;
  68260. /** Gets or sets a boolean indicating if the control can be focusable */
  68261. isFocusInvisible: boolean;
  68262. /**
  68263. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  68264. * 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
  68265. */
  68266. clipChildren: boolean;
  68267. /**
  68268. * Gets or sets a boolean indicating that control content must be clipped
  68269. * 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
  68270. */
  68271. clipContent: boolean;
  68272. /**
  68273. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68274. */
  68275. useBitmapCache: boolean;
  68276. private _cacheData;
  68277. private _shadowOffsetX;
  68278. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68279. get shadowOffsetX(): number;
  68280. set shadowOffsetX(value: number);
  68281. private _shadowOffsetY;
  68282. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68283. get shadowOffsetY(): number;
  68284. set shadowOffsetY(value: number);
  68285. private _shadowBlur;
  68286. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68287. get shadowBlur(): number;
  68288. set shadowBlur(value: number);
  68289. private _shadowColor;
  68290. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68291. get shadowColor(): string;
  68292. set shadowColor(value: string);
  68293. /** Gets or sets the cursor to use when the control is hovered */
  68294. hoverCursor: string;
  68295. /** @hidden */
  68296. protected _linkOffsetX: ValueAndUnit;
  68297. /** @hidden */
  68298. protected _linkOffsetY: ValueAndUnit;
  68299. /** Gets the control type name */
  68300. get typeName(): string;
  68301. /**
  68302. * Get the current class name of the control.
  68303. * @returns current class name
  68304. */
  68305. getClassName(): string;
  68306. /**
  68307. * An event triggered when the pointer move over the control.
  68308. */
  68309. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68310. /**
  68311. * An event triggered when the pointer move out of the control.
  68312. */
  68313. onPointerOutObservable: BABYLON.Observable<Control>;
  68314. /**
  68315. * An event triggered when the pointer taps the control
  68316. */
  68317. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68318. /**
  68319. * An event triggered when pointer up
  68320. */
  68321. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  68322. /**
  68323. * An event triggered when a control is clicked on
  68324. */
  68325. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  68326. /**
  68327. * An event triggered when pointer enters the control
  68328. */
  68329. onPointerEnterObservable: BABYLON.Observable<Control>;
  68330. /**
  68331. * An event triggered when the control is marked as dirty
  68332. */
  68333. onDirtyObservable: BABYLON.Observable<Control>;
  68334. /**
  68335. * An event triggered before drawing the control
  68336. */
  68337. onBeforeDrawObservable: BABYLON.Observable<Control>;
  68338. /**
  68339. * An event triggered after the control was drawn
  68340. */
  68341. onAfterDrawObservable: BABYLON.Observable<Control>;
  68342. /**
  68343. * Get the hosting AdvancedDynamicTexture
  68344. */
  68345. get host(): AdvancedDynamicTexture;
  68346. /** Gets or set information about font offsets (used to render and align text) */
  68347. get fontOffset(): {
  68348. ascent: number;
  68349. height: number;
  68350. descent: number;
  68351. };
  68352. set fontOffset(offset: {
  68353. ascent: number;
  68354. height: number;
  68355. descent: number;
  68356. });
  68357. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  68358. get alpha(): number;
  68359. set alpha(value: number);
  68360. /**
  68361. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  68362. */
  68363. get isHighlighted(): boolean;
  68364. set isHighlighted(value: boolean);
  68365. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  68366. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68367. */
  68368. get scaleX(): number;
  68369. set scaleX(value: number);
  68370. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  68371. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68372. */
  68373. get scaleY(): number;
  68374. set scaleY(value: number);
  68375. /** Gets or sets the rotation angle (0 by default)
  68376. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68377. */
  68378. get rotation(): number;
  68379. set rotation(value: number);
  68380. /** Gets or sets the transformation center on Y axis (0 by default)
  68381. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68382. */
  68383. get transformCenterY(): number;
  68384. set transformCenterY(value: number);
  68385. /** Gets or sets the transformation center on X axis (0 by default)
  68386. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68387. */
  68388. get transformCenterX(): number;
  68389. set transformCenterX(value: number);
  68390. /**
  68391. * Gets or sets the horizontal alignment
  68392. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68393. */
  68394. get horizontalAlignment(): number;
  68395. set horizontalAlignment(value: number);
  68396. /**
  68397. * Gets or sets the vertical alignment
  68398. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68399. */
  68400. get verticalAlignment(): number;
  68401. set verticalAlignment(value: number);
  68402. /**
  68403. * Gets or sets control width
  68404. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68405. */
  68406. get width(): string | number;
  68407. set width(value: string | number);
  68408. /**
  68409. * Gets or sets the control width in pixel
  68410. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68411. */
  68412. get widthInPixels(): number;
  68413. set widthInPixels(value: number);
  68414. /**
  68415. * Gets or sets control height
  68416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68417. */
  68418. get height(): string | number;
  68419. set height(value: string | number);
  68420. /**
  68421. * Gets or sets control height in pixel
  68422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68423. */
  68424. get heightInPixels(): number;
  68425. set heightInPixels(value: number);
  68426. /** Gets or set font family */
  68427. get fontFamily(): string;
  68428. set fontFamily(value: string);
  68429. /** Gets or sets font style */
  68430. get fontStyle(): string;
  68431. set fontStyle(value: string);
  68432. /** Gets or sets font weight */
  68433. get fontWeight(): string;
  68434. set fontWeight(value: string);
  68435. /**
  68436. * Gets or sets style
  68437. * @see http://doc.babylonjs.com/how_to/gui#styles
  68438. */
  68439. get style(): BABYLON.Nullable<Style>;
  68440. set style(value: BABYLON.Nullable<Style>);
  68441. /** @hidden */
  68442. get _isFontSizeInPercentage(): boolean;
  68443. /** Gets or sets font size in pixels */
  68444. get fontSizeInPixels(): number;
  68445. set fontSizeInPixels(value: number);
  68446. /** Gets or sets font size */
  68447. get fontSize(): string | number;
  68448. set fontSize(value: string | number);
  68449. /** Gets or sets foreground color */
  68450. get color(): string;
  68451. set color(value: string);
  68452. /** Gets or sets z index which is used to reorder controls on the z axis */
  68453. get zIndex(): number;
  68454. set zIndex(value: number);
  68455. /** Gets or sets a boolean indicating if the control can be rendered */
  68456. get notRenderable(): boolean;
  68457. set notRenderable(value: boolean);
  68458. /** Gets or sets a boolean indicating if the control is visible */
  68459. get isVisible(): boolean;
  68460. set isVisible(value: boolean);
  68461. /** Gets a boolean indicating that the control needs to update its rendering */
  68462. get isDirty(): boolean;
  68463. /**
  68464. * Gets the current linked mesh (or null if none)
  68465. */
  68466. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  68467. /**
  68468. * Gets or sets a value indicating the padding to use on the left of the control
  68469. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68470. */
  68471. get paddingLeft(): string | number;
  68472. set paddingLeft(value: string | number);
  68473. /**
  68474. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  68475. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68476. */
  68477. get paddingLeftInPixels(): number;
  68478. set paddingLeftInPixels(value: number);
  68479. /**
  68480. * Gets or sets a value indicating the padding to use on the right of the control
  68481. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68482. */
  68483. get paddingRight(): string | number;
  68484. set paddingRight(value: string | number);
  68485. /**
  68486. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  68487. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68488. */
  68489. get paddingRightInPixels(): number;
  68490. set paddingRightInPixels(value: number);
  68491. /**
  68492. * Gets or sets a value indicating the padding to use on the top of the control
  68493. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68494. */
  68495. get paddingTop(): string | number;
  68496. set paddingTop(value: string | number);
  68497. /**
  68498. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  68499. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68500. */
  68501. get paddingTopInPixels(): number;
  68502. set paddingTopInPixels(value: number);
  68503. /**
  68504. * Gets or sets a value indicating the padding to use on the bottom of the control
  68505. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68506. */
  68507. get paddingBottom(): string | number;
  68508. set paddingBottom(value: string | number);
  68509. /**
  68510. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  68511. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68512. */
  68513. get paddingBottomInPixels(): number;
  68514. set paddingBottomInPixels(value: number);
  68515. /**
  68516. * Gets or sets a value indicating the left coordinate of the control
  68517. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68518. */
  68519. get left(): string | number;
  68520. set left(value: string | number);
  68521. /**
  68522. * Gets or sets a value indicating the left coordinate in pixels of the control
  68523. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68524. */
  68525. get leftInPixels(): number;
  68526. set leftInPixels(value: number);
  68527. /**
  68528. * Gets or sets a value indicating the top coordinate of the control
  68529. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68530. */
  68531. get top(): string | number;
  68532. set top(value: string | number);
  68533. /**
  68534. * Gets or sets a value indicating the top coordinate in pixels of the control
  68535. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68536. */
  68537. get topInPixels(): number;
  68538. set topInPixels(value: number);
  68539. /**
  68540. * Gets or sets a value indicating the offset on X axis to the linked mesh
  68541. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68542. */
  68543. get linkOffsetX(): string | number;
  68544. set linkOffsetX(value: string | number);
  68545. /**
  68546. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  68547. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68548. */
  68549. get linkOffsetXInPixels(): number;
  68550. set linkOffsetXInPixels(value: number);
  68551. /**
  68552. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  68553. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68554. */
  68555. get linkOffsetY(): string | number;
  68556. set linkOffsetY(value: string | number);
  68557. /**
  68558. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  68559. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68560. */
  68561. get linkOffsetYInPixels(): number;
  68562. set linkOffsetYInPixels(value: number);
  68563. /** Gets the center coordinate on X axis */
  68564. get centerX(): number;
  68565. /** Gets the center coordinate on Y axis */
  68566. get centerY(): number;
  68567. /** Gets or sets if control is Enabled*/
  68568. get isEnabled(): boolean;
  68569. set isEnabled(value: boolean);
  68570. /** Gets or sets background color of control if it's disabled*/
  68571. get disabledColor(): string;
  68572. set disabledColor(value: string);
  68573. /**
  68574. * Creates a new control
  68575. * @param name defines the name of the control
  68576. */
  68577. constructor(
  68578. /** defines the name of the control */
  68579. name?: string | undefined);
  68580. /** @hidden */
  68581. protected _getTypeName(): string;
  68582. /**
  68583. * Gets the first ascendant in the hierarchy of the given type
  68584. * @param className defines the required type
  68585. * @returns the ascendant or null if not found
  68586. */
  68587. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  68588. /** @hidden */
  68589. _resetFontCache(): void;
  68590. /**
  68591. * Determines if a container is an ascendant of the current control
  68592. * @param container defines the container to look for
  68593. * @returns true if the container is one of the ascendant of the control
  68594. */
  68595. isAscendant(container: Control): boolean;
  68596. /**
  68597. * Gets coordinates in local control space
  68598. * @param globalCoordinates defines the coordinates to transform
  68599. * @returns the new coordinates in local space
  68600. */
  68601. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68602. /**
  68603. * Gets coordinates in local control space
  68604. * @param globalCoordinates defines the coordinates to transform
  68605. * @param result defines the target vector2 where to store the result
  68606. * @returns the current control
  68607. */
  68608. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  68609. /**
  68610. * Gets coordinates in parent local control space
  68611. * @param globalCoordinates defines the coordinates to transform
  68612. * @returns the new coordinates in parent local space
  68613. */
  68614. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68615. /**
  68616. * Move the current control to a vector3 position projected onto the screen.
  68617. * @param position defines the target position
  68618. * @param scene defines the hosting scene
  68619. */
  68620. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  68621. /**
  68622. * Will store all controls that have this control as ascendant in a given array
  68623. * @param results defines the array where to store the descendants
  68624. * @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
  68625. * @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
  68626. */
  68627. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68628. /**
  68629. * Will return all controls that have this control as ascendant
  68630. * @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
  68631. * @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
  68632. * @return all child controls
  68633. */
  68634. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68635. /**
  68636. * Link current control with a target mesh
  68637. * @param mesh defines the mesh to link with
  68638. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68639. */
  68640. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  68641. /** @hidden */
  68642. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  68643. /** @hidden */
  68644. _offsetLeft(offset: number): void;
  68645. /** @hidden */
  68646. _offsetTop(offset: number): void;
  68647. /** @hidden */
  68648. _markMatrixAsDirty(): void;
  68649. /** @hidden */
  68650. _flagDescendantsAsMatrixDirty(): void;
  68651. /** @hidden */
  68652. _intersectsRect(rect: Measure): boolean;
  68653. /** @hidden */
  68654. protected invalidateRect(): void;
  68655. /** @hidden */
  68656. _markAsDirty(force?: boolean): void;
  68657. /** @hidden */
  68658. _markAllAsDirty(): void;
  68659. /** @hidden */
  68660. _link(host: AdvancedDynamicTexture): void;
  68661. /** @hidden */
  68662. protected _transform(context?: CanvasRenderingContext2D): void;
  68663. /** @hidden */
  68664. _renderHighlight(context: CanvasRenderingContext2D): void;
  68665. /** @hidden */
  68666. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68667. /** @hidden */
  68668. protected _applyStates(context: CanvasRenderingContext2D): void;
  68669. /** @hidden */
  68670. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68671. /** @hidden */
  68672. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68673. protected _evaluateClippingState(parentMeasure: Measure): void;
  68674. /** @hidden */
  68675. _measure(): void;
  68676. /** @hidden */
  68677. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68678. /** @hidden */
  68679. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68680. /** @hidden */
  68681. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68682. /** @hidden */
  68683. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68684. private static _ClipMeasure;
  68685. private _tmpMeasureA;
  68686. private _clip;
  68687. /** @hidden */
  68688. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  68689. /** @hidden */
  68690. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68691. /**
  68692. * Tests if a given coordinates belong to the current control
  68693. * @param x defines x coordinate to test
  68694. * @param y defines y coordinate to test
  68695. * @returns true if the coordinates are inside the control
  68696. */
  68697. contains(x: number, y: number): boolean;
  68698. /** @hidden */
  68699. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68700. /** @hidden */
  68701. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68702. /** @hidden */
  68703. _onPointerEnter(target: Control): boolean;
  68704. /** @hidden */
  68705. _onPointerOut(target: Control, force?: boolean): void;
  68706. /** @hidden */
  68707. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68708. /** @hidden */
  68709. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68710. /** @hidden */
  68711. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68712. /** @hidden */
  68713. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  68714. private _prepareFont;
  68715. /** Releases associated resources */
  68716. dispose(): void;
  68717. private static _HORIZONTAL_ALIGNMENT_LEFT;
  68718. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  68719. private static _HORIZONTAL_ALIGNMENT_CENTER;
  68720. private static _VERTICAL_ALIGNMENT_TOP;
  68721. private static _VERTICAL_ALIGNMENT_BOTTOM;
  68722. private static _VERTICAL_ALIGNMENT_CENTER;
  68723. /** HORIZONTAL_ALIGNMENT_LEFT */
  68724. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  68725. /** HORIZONTAL_ALIGNMENT_RIGHT */
  68726. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  68727. /** HORIZONTAL_ALIGNMENT_CENTER */
  68728. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  68729. /** VERTICAL_ALIGNMENT_TOP */
  68730. static get VERTICAL_ALIGNMENT_TOP(): number;
  68731. /** VERTICAL_ALIGNMENT_BOTTOM */
  68732. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  68733. /** VERTICAL_ALIGNMENT_CENTER */
  68734. static get VERTICAL_ALIGNMENT_CENTER(): number;
  68735. private static _FontHeightSizes;
  68736. /** @hidden */
  68737. static _GetFontOffset(font: string): {
  68738. ascent: number;
  68739. height: number;
  68740. descent: number;
  68741. };
  68742. /**
  68743. * Creates a stack panel that can be used to render headers
  68744. * @param control defines the control to associate with the header
  68745. * @param text defines the text of the header
  68746. * @param size defines the size of the header
  68747. * @param options defines options used to configure the header
  68748. * @returns a new StackPanel
  68749. * @ignore
  68750. * @hidden
  68751. */
  68752. static AddHeader: (control: Control, text: string, size: string | number, options: {
  68753. isHorizontal: boolean;
  68754. controlFirst: boolean;
  68755. }) => any;
  68756. /** @hidden */
  68757. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  68758. }
  68759. }
  68760. declare module BABYLON.GUI {
  68761. /**
  68762. * Root class for 2D containers
  68763. * @see http://doc.babylonjs.com/how_to/gui#containers
  68764. */
  68765. export class Container extends Control {
  68766. name?: string | undefined;
  68767. /** @hidden */
  68768. protected _children: Control[];
  68769. /** @hidden */
  68770. protected _measureForChildren: Measure;
  68771. /** @hidden */
  68772. protected _background: string;
  68773. /** @hidden */
  68774. protected _adaptWidthToChildren: boolean;
  68775. /** @hidden */
  68776. protected _adaptHeightToChildren: boolean;
  68777. /**
  68778. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68779. */
  68780. logLayoutCycleErrors: boolean;
  68781. /**
  68782. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68783. */
  68784. maxLayoutCycle: number;
  68785. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68786. get adaptHeightToChildren(): boolean;
  68787. set adaptHeightToChildren(value: boolean);
  68788. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68789. get adaptWidthToChildren(): boolean;
  68790. set adaptWidthToChildren(value: boolean);
  68791. /** Gets or sets background color */
  68792. get background(): string;
  68793. set background(value: string);
  68794. /** Gets the list of children */
  68795. get children(): Control[];
  68796. /**
  68797. * Creates a new Container
  68798. * @param name defines the name of the container
  68799. */
  68800. constructor(name?: string | undefined);
  68801. protected _getTypeName(): string;
  68802. _flagDescendantsAsMatrixDirty(): void;
  68803. /**
  68804. * Gets a child using its name
  68805. * @param name defines the child name to look for
  68806. * @returns the child control if found
  68807. */
  68808. getChildByName(name: string): BABYLON.Nullable<Control>;
  68809. /**
  68810. * Gets a child using its type and its name
  68811. * @param name defines the child name to look for
  68812. * @param type defines the child type to look for
  68813. * @returns the child control if found
  68814. */
  68815. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68816. /**
  68817. * Search for a specific control in children
  68818. * @param control defines the control to look for
  68819. * @returns true if the control is in child list
  68820. */
  68821. containsControl(control: Control): boolean;
  68822. /**
  68823. * Adds a new control to the current container
  68824. * @param control defines the control to add
  68825. * @returns the current container
  68826. */
  68827. addControl(control: BABYLON.Nullable<Control>): Container;
  68828. /**
  68829. * Removes all controls from the current container
  68830. * @returns the current container
  68831. */
  68832. clearControls(): Container;
  68833. /**
  68834. * Removes a control from the current container
  68835. * @param control defines the control to remove
  68836. * @returns the current container
  68837. */
  68838. removeControl(control: Control): Container;
  68839. /** @hidden */
  68840. _reOrderControl(control: Control): void;
  68841. /** @hidden */
  68842. _offsetLeft(offset: number): void;
  68843. /** @hidden */
  68844. _offsetTop(offset: number): void;
  68845. /** @hidden */
  68846. _markAllAsDirty(): void;
  68847. /** @hidden */
  68848. protected _localDraw(context: CanvasRenderingContext2D): void;
  68849. /** @hidden */
  68850. _link(host: AdvancedDynamicTexture): void;
  68851. /** @hidden */
  68852. protected _beforeLayout(): void;
  68853. /** @hidden */
  68854. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68855. /** @hidden */
  68856. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68857. protected _postMeasure(): void;
  68858. /** @hidden */
  68859. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68860. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68861. /** @hidden */
  68862. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68863. /** @hidden */
  68864. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68865. /** Releases associated resources */
  68866. dispose(): void;
  68867. }
  68868. }
  68869. declare module BABYLON.GUI {
  68870. /** Class used to create rectangle container */
  68871. export class Rectangle extends Container {
  68872. name?: string | undefined;
  68873. private _thickness;
  68874. private _cornerRadius;
  68875. /** Gets or sets border thickness */
  68876. get thickness(): number;
  68877. set thickness(value: number);
  68878. /** Gets or sets the corner radius angle */
  68879. get cornerRadius(): number;
  68880. set cornerRadius(value: number);
  68881. /**
  68882. * Creates a new Rectangle
  68883. * @param name defines the control name
  68884. */
  68885. constructor(name?: string | undefined);
  68886. protected _getTypeName(): string;
  68887. protected _localDraw(context: CanvasRenderingContext2D): void;
  68888. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68889. private _drawRoundedRect;
  68890. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68891. }
  68892. }
  68893. declare module BABYLON.GUI {
  68894. /**
  68895. * Enum that determines the text-wrapping mode to use.
  68896. */
  68897. export enum TextWrapping {
  68898. /**
  68899. * Clip the text when it's larger than Control.width; this is the default mode.
  68900. */
  68901. Clip = 0,
  68902. /**
  68903. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68904. */
  68905. WordWrap = 1,
  68906. /**
  68907. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68908. */
  68909. Ellipsis = 2
  68910. }
  68911. /**
  68912. * Class used to create text block control
  68913. */
  68914. export class TextBlock extends Control {
  68915. /**
  68916. * Defines the name of the control
  68917. */
  68918. name?: string | undefined;
  68919. private _text;
  68920. private _textWrapping;
  68921. private _textHorizontalAlignment;
  68922. private _textVerticalAlignment;
  68923. private _lines;
  68924. private _resizeToFit;
  68925. private _lineSpacing;
  68926. private _outlineWidth;
  68927. private _outlineColor;
  68928. /**
  68929. * An event triggered after the text is changed
  68930. */
  68931. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68932. /**
  68933. * An event triggered after the text was broken up into lines
  68934. */
  68935. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68936. /**
  68937. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68938. */
  68939. get lines(): any[];
  68940. /**
  68941. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68942. */
  68943. get resizeToFit(): boolean;
  68944. /**
  68945. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68946. */
  68947. set resizeToFit(value: boolean);
  68948. /**
  68949. * Gets or sets a boolean indicating if text must be wrapped
  68950. */
  68951. get textWrapping(): TextWrapping | boolean;
  68952. /**
  68953. * Gets or sets a boolean indicating if text must be wrapped
  68954. */
  68955. set textWrapping(value: TextWrapping | boolean);
  68956. /**
  68957. * Gets or sets text to display
  68958. */
  68959. get text(): string;
  68960. /**
  68961. * Gets or sets text to display
  68962. */
  68963. set text(value: string);
  68964. /**
  68965. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68966. */
  68967. get textHorizontalAlignment(): number;
  68968. /**
  68969. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68970. */
  68971. set textHorizontalAlignment(value: number);
  68972. /**
  68973. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68974. */
  68975. get textVerticalAlignment(): number;
  68976. /**
  68977. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68978. */
  68979. set textVerticalAlignment(value: number);
  68980. /**
  68981. * Gets or sets line spacing value
  68982. */
  68983. set lineSpacing(value: string | number);
  68984. /**
  68985. * Gets or sets line spacing value
  68986. */
  68987. get lineSpacing(): string | number;
  68988. /**
  68989. * Gets or sets outlineWidth of the text to display
  68990. */
  68991. get outlineWidth(): number;
  68992. /**
  68993. * Gets or sets outlineWidth of the text to display
  68994. */
  68995. set outlineWidth(value: number);
  68996. /**
  68997. * Gets or sets outlineColor of the text to display
  68998. */
  68999. get outlineColor(): string;
  69000. /**
  69001. * Gets or sets outlineColor of the text to display
  69002. */
  69003. set outlineColor(value: string);
  69004. /**
  69005. * Creates a new TextBlock object
  69006. * @param name defines the name of the control
  69007. * @param text defines the text to display (emptry string by default)
  69008. */
  69009. constructor(
  69010. /**
  69011. * Defines the name of the control
  69012. */
  69013. name?: string | undefined, text?: string);
  69014. protected _getTypeName(): string;
  69015. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69016. private _drawText;
  69017. /** @hidden */
  69018. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69019. protected _applyStates(context: CanvasRenderingContext2D): void;
  69020. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  69021. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  69022. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  69023. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  69024. protected _renderLines(context: CanvasRenderingContext2D): void;
  69025. /**
  69026. * Given a width constraint applied on the text block, find the expected height
  69027. * @returns expected height
  69028. */
  69029. computeExpectedHeight(): number;
  69030. dispose(): void;
  69031. }
  69032. }
  69033. declare module BABYLON.GUI {
  69034. /**
  69035. * Class used to create 2D images
  69036. */
  69037. export class Image extends Control {
  69038. name?: string | undefined;
  69039. private _workingCanvas;
  69040. private _domImage;
  69041. private _imageWidth;
  69042. private _imageHeight;
  69043. private _loaded;
  69044. private _stretch;
  69045. private _source;
  69046. private _autoScale;
  69047. private _sourceLeft;
  69048. private _sourceTop;
  69049. private _sourceWidth;
  69050. private _sourceHeight;
  69051. private _cellWidth;
  69052. private _cellHeight;
  69053. private _cellId;
  69054. private _populateNinePatchSlicesFromImage;
  69055. private _sliceLeft;
  69056. private _sliceRight;
  69057. private _sliceTop;
  69058. private _sliceBottom;
  69059. private _detectPointerOnOpaqueOnly;
  69060. /**
  69061. * BABYLON.Observable notified when the content is loaded
  69062. */
  69063. onImageLoadedObservable: BABYLON.Observable<Image>;
  69064. /**
  69065. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  69066. */
  69067. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  69068. /**
  69069. * Gets a boolean indicating that the content is loaded
  69070. */
  69071. get isLoaded(): boolean;
  69072. /**
  69073. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  69074. */
  69075. get populateNinePatchSlicesFromImage(): boolean;
  69076. set populateNinePatchSlicesFromImage(value: boolean);
  69077. /**
  69078. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  69079. * Beware using this as this will comsume more memory as the image has to be stored twice
  69080. */
  69081. get detectPointerOnOpaqueOnly(): boolean;
  69082. set detectPointerOnOpaqueOnly(value: boolean);
  69083. /**
  69084. * Gets or sets the left value for slicing (9-patch)
  69085. */
  69086. get sliceLeft(): number;
  69087. set sliceLeft(value: number);
  69088. /**
  69089. * Gets or sets the right value for slicing (9-patch)
  69090. */
  69091. get sliceRight(): number;
  69092. set sliceRight(value: number);
  69093. /**
  69094. * Gets or sets the top value for slicing (9-patch)
  69095. */
  69096. get sliceTop(): number;
  69097. set sliceTop(value: number);
  69098. /**
  69099. * Gets or sets the bottom value for slicing (9-patch)
  69100. */
  69101. get sliceBottom(): number;
  69102. set sliceBottom(value: number);
  69103. /**
  69104. * Gets or sets the left coordinate in the source image
  69105. */
  69106. get sourceLeft(): number;
  69107. set sourceLeft(value: number);
  69108. /**
  69109. * Gets or sets the top coordinate in the source image
  69110. */
  69111. get sourceTop(): number;
  69112. set sourceTop(value: number);
  69113. /**
  69114. * Gets or sets the width to capture in the source image
  69115. */
  69116. get sourceWidth(): number;
  69117. set sourceWidth(value: number);
  69118. /**
  69119. * Gets or sets the height to capture in the source image
  69120. */
  69121. get sourceHeight(): number;
  69122. set sourceHeight(value: number);
  69123. /**
  69124. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69125. * @see http://doc.babylonjs.com/how_to/gui#image
  69126. */
  69127. get autoScale(): boolean;
  69128. set autoScale(value: boolean);
  69129. /** Gets or sets the streching mode used by the image */
  69130. get stretch(): number;
  69131. set stretch(value: number);
  69132. /** @hidden */
  69133. _rotate90(n: number): Image;
  69134. /**
  69135. * Gets or sets the internal DOM image used to render the control
  69136. */
  69137. set domImage(value: HTMLImageElement);
  69138. get domImage(): HTMLImageElement;
  69139. private _onImageLoaded;
  69140. private _extractNinePatchSliceDataFromImage;
  69141. /**
  69142. * Gets or sets image source url
  69143. */
  69144. set source(value: BABYLON.Nullable<string>);
  69145. /**
  69146. * Checks for svg document with icon id present
  69147. */
  69148. private _svgCheck;
  69149. /**
  69150. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69151. * given external svg file and icon id
  69152. */
  69153. private _getSVGAttribs;
  69154. /**
  69155. * Gets or sets the cell width to use when animation sheet is enabled
  69156. * @see http://doc.babylonjs.com/how_to/gui#image
  69157. */
  69158. get cellWidth(): number;
  69159. set cellWidth(value: number);
  69160. /**
  69161. * Gets or sets the cell height to use when animation sheet is enabled
  69162. * @see http://doc.babylonjs.com/how_to/gui#image
  69163. */
  69164. get cellHeight(): number;
  69165. set cellHeight(value: number);
  69166. /**
  69167. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69168. * @see http://doc.babylonjs.com/how_to/gui#image
  69169. */
  69170. get cellId(): number;
  69171. set cellId(value: number);
  69172. /**
  69173. * Creates a new Image
  69174. * @param name defines the control name
  69175. * @param url defines the image url
  69176. */
  69177. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69178. /**
  69179. * Tests if a given coordinates belong to the current control
  69180. * @param x defines x coordinate to test
  69181. * @param y defines y coordinate to test
  69182. * @returns true if the coordinates are inside the control
  69183. */
  69184. contains(x: number, y: number): boolean;
  69185. protected _getTypeName(): string;
  69186. /** Force the control to synchronize with its content */
  69187. synchronizeSizeWithContent(): void;
  69188. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69189. private _prepareWorkingCanvasForOpaqueDetection;
  69190. private _drawImage;
  69191. _draw(context: CanvasRenderingContext2D): void;
  69192. private _renderCornerPatch;
  69193. private _renderNinePatch;
  69194. dispose(): void;
  69195. /** STRETCH_NONE */
  69196. static readonly STRETCH_NONE: number;
  69197. /** STRETCH_FILL */
  69198. static readonly STRETCH_FILL: number;
  69199. /** STRETCH_UNIFORM */
  69200. static readonly STRETCH_UNIFORM: number;
  69201. /** STRETCH_EXTEND */
  69202. static readonly STRETCH_EXTEND: number;
  69203. /** NINE_PATCH */
  69204. static readonly STRETCH_NINE_PATCH: number;
  69205. }
  69206. }
  69207. declare module BABYLON.GUI {
  69208. /**
  69209. * Class used to create 2D buttons
  69210. */
  69211. export class Button extends Rectangle {
  69212. name?: string | undefined;
  69213. /**
  69214. * Function called to generate a pointer enter animation
  69215. */
  69216. pointerEnterAnimation: () => void;
  69217. /**
  69218. * Function called to generate a pointer out animation
  69219. */
  69220. pointerOutAnimation: () => void;
  69221. /**
  69222. * Function called to generate a pointer down animation
  69223. */
  69224. pointerDownAnimation: () => void;
  69225. /**
  69226. * Function called to generate a pointer up animation
  69227. */
  69228. pointerUpAnimation: () => void;
  69229. /**
  69230. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69231. */
  69232. delegatePickingToChildren: boolean;
  69233. private _image;
  69234. /**
  69235. * Returns the image part of the button (if any)
  69236. */
  69237. get image(): BABYLON.Nullable<Image>;
  69238. private _textBlock;
  69239. /**
  69240. * Returns the image part of the button (if any)
  69241. */
  69242. get textBlock(): BABYLON.Nullable<TextBlock>;
  69243. /**
  69244. * Creates a new Button
  69245. * @param name defines the name of the button
  69246. */
  69247. constructor(name?: string | undefined);
  69248. protected _getTypeName(): string;
  69249. /** @hidden */
  69250. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69251. /** @hidden */
  69252. _onPointerEnter(target: Control): boolean;
  69253. /** @hidden */
  69254. _onPointerOut(target: Control, force?: boolean): void;
  69255. /** @hidden */
  69256. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69257. /** @hidden */
  69258. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69259. /**
  69260. * Creates a new button made with an image and a text
  69261. * @param name defines the name of the button
  69262. * @param text defines the text of the button
  69263. * @param imageUrl defines the url of the image
  69264. * @returns a new Button
  69265. */
  69266. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69267. /**
  69268. * Creates a new button made with an image
  69269. * @param name defines the name of the button
  69270. * @param imageUrl defines the url of the image
  69271. * @returns a new Button
  69272. */
  69273. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69274. /**
  69275. * Creates a new button made with a text
  69276. * @param name defines the name of the button
  69277. * @param text defines the text of the button
  69278. * @returns a new Button
  69279. */
  69280. static CreateSimpleButton(name: string, text: string): Button;
  69281. /**
  69282. * Creates a new button made with an image and a centered text
  69283. * @param name defines the name of the button
  69284. * @param text defines the text of the button
  69285. * @param imageUrl defines the url of the image
  69286. * @returns a new Button
  69287. */
  69288. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69289. }
  69290. }
  69291. declare module BABYLON.GUI {
  69292. /**
  69293. * Class used to create a 2D stack panel container
  69294. */
  69295. export class StackPanel extends Container {
  69296. name?: string | undefined;
  69297. private _isVertical;
  69298. private _manualWidth;
  69299. private _manualHeight;
  69300. private _doNotTrackManualChanges;
  69301. /**
  69302. * Gets or sets a boolean indicating that layou warnings should be ignored
  69303. */
  69304. ignoreLayoutWarnings: boolean;
  69305. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69306. get isVertical(): boolean;
  69307. set isVertical(value: boolean);
  69308. /**
  69309. * Gets or sets panel width.
  69310. * This value should not be set when in horizontal mode as it will be computed automatically
  69311. */
  69312. set width(value: string | number);
  69313. get width(): string | number;
  69314. /**
  69315. * Gets or sets panel height.
  69316. * This value should not be set when in vertical mode as it will be computed automatically
  69317. */
  69318. set height(value: string | number);
  69319. get height(): string | number;
  69320. /**
  69321. * Creates a new StackPanel
  69322. * @param name defines control name
  69323. */
  69324. constructor(name?: string | undefined);
  69325. protected _getTypeName(): string;
  69326. /** @hidden */
  69327. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69328. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69329. protected _postMeasure(): void;
  69330. }
  69331. }
  69332. declare module BABYLON.GUI {
  69333. /**
  69334. * Class used to represent a 2D checkbox
  69335. */
  69336. export class Checkbox extends Control {
  69337. name?: string | undefined;
  69338. private _isChecked;
  69339. private _background;
  69340. private _checkSizeRatio;
  69341. private _thickness;
  69342. /** Gets or sets border thickness */
  69343. get thickness(): number;
  69344. set thickness(value: number);
  69345. /**
  69346. * BABYLON.Observable raised when isChecked property changes
  69347. */
  69348. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69349. /** Gets or sets a value indicating the ratio between overall size and check size */
  69350. get checkSizeRatio(): number;
  69351. set checkSizeRatio(value: number);
  69352. /** Gets or sets background color */
  69353. get background(): string;
  69354. set background(value: string);
  69355. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69356. get isChecked(): boolean;
  69357. set isChecked(value: boolean);
  69358. /**
  69359. * Creates a new CheckBox
  69360. * @param name defines the control name
  69361. */
  69362. constructor(name?: string | undefined);
  69363. protected _getTypeName(): string;
  69364. /** @hidden */
  69365. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69366. /** @hidden */
  69367. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69368. /**
  69369. * Utility function to easily create a checkbox with a header
  69370. * @param title defines the label to use for the header
  69371. * @param onValueChanged defines the callback to call when value changes
  69372. * @returns a StackPanel containing the checkbox and a textBlock
  69373. */
  69374. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  69375. }
  69376. }
  69377. declare module BABYLON.GUI {
  69378. /**
  69379. * Class used to store key control properties
  69380. */
  69381. export class KeyPropertySet {
  69382. /** Width */
  69383. width?: string;
  69384. /** Height */
  69385. height?: string;
  69386. /** Left padding */
  69387. paddingLeft?: string;
  69388. /** Right padding */
  69389. paddingRight?: string;
  69390. /** Top padding */
  69391. paddingTop?: string;
  69392. /** Bottom padding */
  69393. paddingBottom?: string;
  69394. /** Foreground color */
  69395. color?: string;
  69396. /** Background color */
  69397. background?: string;
  69398. }
  69399. /**
  69400. * Class used to create virtual keyboard
  69401. */
  69402. export class VirtualKeyboard extends StackPanel {
  69403. /** BABYLON.Observable raised when a key is pressed */
  69404. onKeyPressObservable: BABYLON.Observable<string>;
  69405. /** Gets or sets default key button width */
  69406. defaultButtonWidth: string;
  69407. /** Gets or sets default key button height */
  69408. defaultButtonHeight: string;
  69409. /** Gets or sets default key button left padding */
  69410. defaultButtonPaddingLeft: string;
  69411. /** Gets or sets default key button right padding */
  69412. defaultButtonPaddingRight: string;
  69413. /** Gets or sets default key button top padding */
  69414. defaultButtonPaddingTop: string;
  69415. /** Gets or sets default key button bottom padding */
  69416. defaultButtonPaddingBottom: string;
  69417. /** Gets or sets default key button foreground color */
  69418. defaultButtonColor: string;
  69419. /** Gets or sets default key button background color */
  69420. defaultButtonBackground: string;
  69421. /** Gets or sets shift button foreground color */
  69422. shiftButtonColor: string;
  69423. /** Gets or sets shift button thickness*/
  69424. selectedShiftThickness: number;
  69425. /** Gets shift key state */
  69426. shiftState: number;
  69427. protected _getTypeName(): string;
  69428. private _createKey;
  69429. /**
  69430. * Adds a new row of keys
  69431. * @param keys defines the list of keys to add
  69432. * @param propertySets defines the associated property sets
  69433. */
  69434. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  69435. /**
  69436. * Set the shift key to a specific state
  69437. * @param shiftState defines the new shift state
  69438. */
  69439. applyShiftState(shiftState: number): void;
  69440. private _currentlyConnectedInputText;
  69441. private _connectedInputTexts;
  69442. private _onKeyPressObserver;
  69443. /** Gets the input text control currently attached to the keyboard */
  69444. get connectedInputText(): BABYLON.Nullable<InputText>;
  69445. /**
  69446. * Connects the keyboard with an input text control
  69447. *
  69448. * @param input defines the target control
  69449. */
  69450. connect(input: InputText): void;
  69451. /**
  69452. * Disconnects the keyboard from connected InputText controls
  69453. *
  69454. * @param input optionally defines a target control, otherwise all are disconnected
  69455. */
  69456. disconnect(input?: InputText): void;
  69457. private _removeConnectedInputObservables;
  69458. /**
  69459. * Release all resources
  69460. */
  69461. dispose(): void;
  69462. /**
  69463. * Creates a new keyboard using a default layout
  69464. *
  69465. * @param name defines control name
  69466. * @returns a new VirtualKeyboard
  69467. */
  69468. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  69469. }
  69470. }
  69471. declare module BABYLON.GUI {
  69472. /**
  69473. * Class used to create input text control
  69474. */
  69475. export class InputText extends Control implements IFocusableControl {
  69476. name?: string | undefined;
  69477. private _text;
  69478. private _placeholderText;
  69479. private _background;
  69480. private _focusedBackground;
  69481. private _focusedColor;
  69482. private _placeholderColor;
  69483. private _thickness;
  69484. private _margin;
  69485. private _autoStretchWidth;
  69486. private _maxWidth;
  69487. private _isFocused;
  69488. private _blinkTimeout;
  69489. private _blinkIsEven;
  69490. private _cursorOffset;
  69491. private _scrollLeft;
  69492. private _textWidth;
  69493. private _clickedCoordinate;
  69494. private _deadKey;
  69495. private _addKey;
  69496. private _currentKey;
  69497. private _isTextHighlightOn;
  69498. private _textHighlightColor;
  69499. private _highligherOpacity;
  69500. private _highlightedText;
  69501. private _startHighlightIndex;
  69502. private _endHighlightIndex;
  69503. private _cursorIndex;
  69504. private _onFocusSelectAll;
  69505. private _isPointerDown;
  69506. private _onClipboardObserver;
  69507. private _onPointerDblTapObserver;
  69508. /** @hidden */
  69509. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  69510. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  69511. promptMessage: string;
  69512. /** Force disable prompt on mobile device */
  69513. disableMobilePrompt: boolean;
  69514. /** BABYLON.Observable raised when the text changes */
  69515. onTextChangedObservable: BABYLON.Observable<InputText>;
  69516. /** BABYLON.Observable raised just before an entered character is to be added */
  69517. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  69518. /** BABYLON.Observable raised when the control gets the focus */
  69519. onFocusObservable: BABYLON.Observable<InputText>;
  69520. /** BABYLON.Observable raised when the control loses the focus */
  69521. onBlurObservable: BABYLON.Observable<InputText>;
  69522. /**Observable raised when the text is highlighted */
  69523. onTextHighlightObservable: BABYLON.Observable<InputText>;
  69524. /**Observable raised when copy event is triggered */
  69525. onTextCopyObservable: BABYLON.Observable<InputText>;
  69526. /** BABYLON.Observable raised when cut event is triggered */
  69527. onTextCutObservable: BABYLON.Observable<InputText>;
  69528. /** BABYLON.Observable raised when paste event is triggered */
  69529. onTextPasteObservable: BABYLON.Observable<InputText>;
  69530. /** BABYLON.Observable raised when a key event was processed */
  69531. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  69532. /** Gets or sets the maximum width allowed by the control */
  69533. get maxWidth(): string | number;
  69534. /** Gets the maximum width allowed by the control in pixels */
  69535. get maxWidthInPixels(): number;
  69536. set maxWidth(value: string | number);
  69537. /** Gets or sets the text highlighter transparency; default: 0.4 */
  69538. get highligherOpacity(): number;
  69539. set highligherOpacity(value: number);
  69540. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  69541. get onFocusSelectAll(): boolean;
  69542. set onFocusSelectAll(value: boolean);
  69543. /** Gets or sets the text hightlight color */
  69544. get textHighlightColor(): string;
  69545. set textHighlightColor(value: string);
  69546. /** Gets or sets control margin */
  69547. get margin(): string;
  69548. /** Gets control margin in pixels */
  69549. get marginInPixels(): number;
  69550. set margin(value: string);
  69551. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  69552. get autoStretchWidth(): boolean;
  69553. set autoStretchWidth(value: boolean);
  69554. /** Gets or sets border thickness */
  69555. get thickness(): number;
  69556. set thickness(value: number);
  69557. /** Gets or sets the background color when focused */
  69558. get focusedBackground(): string;
  69559. set focusedBackground(value: string);
  69560. /** Gets or sets the background color when focused */
  69561. get focusedColor(): string;
  69562. set focusedColor(value: string);
  69563. /** Gets or sets the background color */
  69564. get background(): string;
  69565. set background(value: string);
  69566. /** Gets or sets the placeholder color */
  69567. get placeholderColor(): string;
  69568. set placeholderColor(value: string);
  69569. /** Gets or sets the text displayed when the control is empty */
  69570. get placeholderText(): string;
  69571. set placeholderText(value: string);
  69572. /** Gets or sets the dead key flag */
  69573. get deadKey(): boolean;
  69574. set deadKey(flag: boolean);
  69575. /** Gets or sets the highlight text */
  69576. get highlightedText(): string;
  69577. set highlightedText(text: string);
  69578. /** Gets or sets if the current key should be added */
  69579. get addKey(): boolean;
  69580. set addKey(flag: boolean);
  69581. /** Gets or sets the value of the current key being entered */
  69582. get currentKey(): string;
  69583. set currentKey(key: string);
  69584. /** Gets or sets the text displayed in the control */
  69585. get text(): string;
  69586. set text(value: string);
  69587. /** Gets or sets control width */
  69588. get width(): string | number;
  69589. set width(value: string | number);
  69590. /**
  69591. * Creates a new InputText
  69592. * @param name defines the control name
  69593. * @param text defines the text of the control
  69594. */
  69595. constructor(name?: string | undefined, text?: string);
  69596. /** @hidden */
  69597. onBlur(): void;
  69598. /** @hidden */
  69599. onFocus(): void;
  69600. protected _getTypeName(): string;
  69601. /**
  69602. * Function called to get the list of controls that should not steal the focus from this control
  69603. * @returns an array of controls
  69604. */
  69605. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69606. /** @hidden */
  69607. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  69608. /** @hidden */
  69609. private _updateValueFromCursorIndex;
  69610. /** @hidden */
  69611. private _processDblClick;
  69612. /** @hidden */
  69613. private _selectAllText;
  69614. /**
  69615. * Handles the keyboard event
  69616. * @param evt Defines the KeyboardEvent
  69617. */
  69618. processKeyboard(evt: KeyboardEvent): void;
  69619. /** @hidden */
  69620. private _onCopyText;
  69621. /** @hidden */
  69622. private _onCutText;
  69623. /** @hidden */
  69624. private _onPasteText;
  69625. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69627. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69628. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69629. protected _beforeRenderText(text: string): string;
  69630. dispose(): void;
  69631. }
  69632. }
  69633. declare module BABYLON.GUI {
  69634. /**
  69635. * Class used to create a 2D grid container
  69636. */
  69637. export class Grid extends Container {
  69638. name?: string | undefined;
  69639. private _rowDefinitions;
  69640. private _columnDefinitions;
  69641. private _cells;
  69642. private _childControls;
  69643. /**
  69644. * Gets the number of columns
  69645. */
  69646. get columnCount(): number;
  69647. /**
  69648. * Gets the number of rows
  69649. */
  69650. get rowCount(): number;
  69651. /** Gets the list of children */
  69652. get children(): Control[];
  69653. /** Gets the list of cells (e.g. the containers) */
  69654. get cells(): {
  69655. [key: string]: Container;
  69656. };
  69657. /**
  69658. * Gets the definition of a specific row
  69659. * @param index defines the index of the row
  69660. * @returns the row definition
  69661. */
  69662. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69663. /**
  69664. * Gets the definition of a specific column
  69665. * @param index defines the index of the column
  69666. * @returns the column definition
  69667. */
  69668. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69669. /**
  69670. * Adds a new row to the grid
  69671. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69672. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  69673. * @returns the current grid
  69674. */
  69675. addRowDefinition(height: number, isPixel?: boolean): Grid;
  69676. /**
  69677. * Adds a new column to the grid
  69678. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69679. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69680. * @returns the current grid
  69681. */
  69682. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  69683. /**
  69684. * Update a row definition
  69685. * @param index defines the index of the row to update
  69686. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69687. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  69688. * @returns the current grid
  69689. */
  69690. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  69691. /**
  69692. * Update a column definition
  69693. * @param index defines the index of the column to update
  69694. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69695. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69696. * @returns the current grid
  69697. */
  69698. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  69699. /**
  69700. * Gets the list of children stored in a specific cell
  69701. * @param row defines the row to check
  69702. * @param column defines the column to check
  69703. * @returns the list of controls
  69704. */
  69705. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  69706. /**
  69707. * Gets a string representing the child cell info (row x column)
  69708. * @param child defines the control to get info from
  69709. * @returns a string containing the child cell info (row x column)
  69710. */
  69711. getChildCellInfo(child: Control): string;
  69712. private _removeCell;
  69713. private _offsetCell;
  69714. /**
  69715. * Remove a column definition at specified index
  69716. * @param index defines the index of the column to remove
  69717. * @returns the current grid
  69718. */
  69719. removeColumnDefinition(index: number): Grid;
  69720. /**
  69721. * Remove a row definition at specified index
  69722. * @param index defines the index of the row to remove
  69723. * @returns the current grid
  69724. */
  69725. removeRowDefinition(index: number): Grid;
  69726. /**
  69727. * Adds a new control to the current grid
  69728. * @param control defines the control to add
  69729. * @param row defines the row where to add the control (0 by default)
  69730. * @param column defines the column where to add the control (0 by default)
  69731. * @returns the current grid
  69732. */
  69733. addControl(control: Control, row?: number, column?: number): Grid;
  69734. /**
  69735. * Removes a control from the current container
  69736. * @param control defines the control to remove
  69737. * @returns the current container
  69738. */
  69739. removeControl(control: Control): Container;
  69740. /**
  69741. * Creates a new Grid
  69742. * @param name defines control name
  69743. */
  69744. constructor(name?: string | undefined);
  69745. protected _getTypeName(): string;
  69746. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  69747. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69748. _flagDescendantsAsMatrixDirty(): void;
  69749. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69750. /** Releases associated resources */
  69751. dispose(): void;
  69752. }
  69753. }
  69754. declare module BABYLON.GUI {
  69755. /** Class used to create color pickers */
  69756. export class ColorPicker extends Control {
  69757. name?: string | undefined;
  69758. private static _Epsilon;
  69759. private _colorWheelCanvas;
  69760. private _value;
  69761. private _tmpColor;
  69762. private _pointerStartedOnSquare;
  69763. private _pointerStartedOnWheel;
  69764. private _squareLeft;
  69765. private _squareTop;
  69766. private _squareSize;
  69767. private _h;
  69768. private _s;
  69769. private _v;
  69770. private _lastPointerDownID;
  69771. /**
  69772. * BABYLON.Observable raised when the value changes
  69773. */
  69774. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  69775. /** Gets or sets the color of the color picker */
  69776. get value(): BABYLON.Color3;
  69777. set value(value: BABYLON.Color3);
  69778. /**
  69779. * Gets or sets control width
  69780. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69781. */
  69782. get width(): string | number;
  69783. set width(value: string | number);
  69784. /**
  69785. * Gets or sets control height
  69786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69787. */
  69788. get height(): string | number;
  69789. /** Gets or sets control height */
  69790. set height(value: string | number);
  69791. /** Gets or sets control size */
  69792. get size(): string | number;
  69793. set size(value: string | number);
  69794. /**
  69795. * Creates a new ColorPicker
  69796. * @param name defines the control name
  69797. */
  69798. constructor(name?: string | undefined);
  69799. protected _getTypeName(): string;
  69800. /** @hidden */
  69801. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69802. private _updateSquareProps;
  69803. private _drawGradientSquare;
  69804. private _drawCircle;
  69805. private _createColorWheelCanvas;
  69806. /** @hidden */
  69807. _draw(context: CanvasRenderingContext2D): void;
  69808. private _pointerIsDown;
  69809. private _updateValueFromPointer;
  69810. private _isPointOnSquare;
  69811. private _isPointOnWheel;
  69812. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69813. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69814. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69815. /**
  69816. * This function expands the color picker by creating a color picker dialog with manual
  69817. * color value input and the ability to save colors into an array to be used later in
  69818. * subsequent launches of the dialogue.
  69819. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69820. * @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.
  69821. * @returns picked color as a hex string and the saved colors array as hex strings.
  69822. */
  69823. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69824. pickerWidth?: string;
  69825. pickerHeight?: string;
  69826. headerHeight?: string;
  69827. lastColor?: string;
  69828. swatchLimit?: number;
  69829. numSwatchesPerLine?: number;
  69830. savedColors?: Array<string>;
  69831. }): Promise<{
  69832. savedColors?: string[];
  69833. pickedColor: string;
  69834. }>;
  69835. }
  69836. }
  69837. declare module BABYLON.GUI {
  69838. /** Class used to create 2D ellipse containers */
  69839. export class Ellipse extends Container {
  69840. name?: string | undefined;
  69841. private _thickness;
  69842. /** Gets or sets border thickness */
  69843. get thickness(): number;
  69844. set thickness(value: number);
  69845. /**
  69846. * Creates a new Ellipse
  69847. * @param name defines the control name
  69848. */
  69849. constructor(name?: string | undefined);
  69850. protected _getTypeName(): string;
  69851. protected _localDraw(context: CanvasRenderingContext2D): void;
  69852. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69853. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69854. }
  69855. }
  69856. declare module BABYLON.GUI {
  69857. /**
  69858. * Class used to create a password control
  69859. */
  69860. export class InputPassword extends InputText {
  69861. protected _beforeRenderText(text: string): string;
  69862. }
  69863. }
  69864. declare module BABYLON.GUI {
  69865. /** Class used to render 2D lines */
  69866. export class Line extends Control {
  69867. name?: string | undefined;
  69868. private _lineWidth;
  69869. private _x1;
  69870. private _y1;
  69871. private _x2;
  69872. private _y2;
  69873. private _dash;
  69874. private _connectedControl;
  69875. private _connectedControlDirtyObserver;
  69876. /** Gets or sets the dash pattern */
  69877. get dash(): Array<number>;
  69878. set dash(value: Array<number>);
  69879. /** Gets or sets the control connected with the line end */
  69880. get connectedControl(): Control;
  69881. set connectedControl(value: Control);
  69882. /** Gets or sets start coordinates on X axis */
  69883. get x1(): string | number;
  69884. set x1(value: string | number);
  69885. /** Gets or sets start coordinates on Y axis */
  69886. get y1(): string | number;
  69887. set y1(value: string | number);
  69888. /** Gets or sets end coordinates on X axis */
  69889. get x2(): string | number;
  69890. set x2(value: string | number);
  69891. /** Gets or sets end coordinates on Y axis */
  69892. get y2(): string | number;
  69893. set y2(value: string | number);
  69894. /** Gets or sets line width */
  69895. get lineWidth(): number;
  69896. set lineWidth(value: number);
  69897. /** Gets or sets horizontal alignment */
  69898. set horizontalAlignment(value: number);
  69899. /** Gets or sets vertical alignment */
  69900. set verticalAlignment(value: number);
  69901. private get _effectiveX2();
  69902. private get _effectiveY2();
  69903. /**
  69904. * Creates a new Line
  69905. * @param name defines the control name
  69906. */
  69907. constructor(name?: string | undefined);
  69908. protected _getTypeName(): string;
  69909. _draw(context: CanvasRenderingContext2D): void;
  69910. _measure(): void;
  69911. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69912. /**
  69913. * Move one end of the line given 3D cartesian coordinates.
  69914. * @param position Targeted world position
  69915. * @param scene BABYLON.Scene
  69916. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69917. */
  69918. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69919. /**
  69920. * Move one end of the line to a position in screen absolute space.
  69921. * @param projectedPosition Position in screen absolute space (X, Y)
  69922. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69923. */
  69924. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69925. }
  69926. }
  69927. declare module BABYLON.GUI {
  69928. /**
  69929. * Class used to store a point for a MultiLine object.
  69930. * The point can be pure 2D coordinates, a mesh or a control
  69931. */
  69932. export class MultiLinePoint {
  69933. private _multiLine;
  69934. private _x;
  69935. private _y;
  69936. private _control;
  69937. private _mesh;
  69938. private _controlObserver;
  69939. private _meshObserver;
  69940. /** @hidden */
  69941. _point: BABYLON.Vector2;
  69942. /**
  69943. * Creates a new MultiLinePoint
  69944. * @param multiLine defines the source MultiLine object
  69945. */
  69946. constructor(multiLine: MultiLine);
  69947. /** Gets or sets x coordinate */
  69948. get x(): string | number;
  69949. set x(value: string | number);
  69950. /** Gets or sets y coordinate */
  69951. get y(): string | number;
  69952. set y(value: string | number);
  69953. /** Gets or sets the control associated with this point */
  69954. get control(): BABYLON.Nullable<Control>;
  69955. set control(value: BABYLON.Nullable<Control>);
  69956. /** Gets or sets the mesh associated with this point */
  69957. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69958. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  69959. /** Resets links */
  69960. resetLinks(): void;
  69961. /**
  69962. * Gets a translation vector
  69963. * @returns the translation vector
  69964. */
  69965. translate(): BABYLON.Vector2;
  69966. private _translatePoint;
  69967. /** Release associated resources */
  69968. dispose(): void;
  69969. }
  69970. }
  69971. declare module BABYLON.GUI {
  69972. /**
  69973. * Class used to create multi line control
  69974. */
  69975. export class MultiLine extends Control {
  69976. name?: string | undefined;
  69977. private _lineWidth;
  69978. private _dash;
  69979. private _points;
  69980. private _minX;
  69981. private _minY;
  69982. private _maxX;
  69983. private _maxY;
  69984. /**
  69985. * Creates a new MultiLine
  69986. * @param name defines the control name
  69987. */
  69988. constructor(name?: string | undefined);
  69989. /** Gets or sets dash pattern */
  69990. get dash(): Array<number>;
  69991. set dash(value: Array<number>);
  69992. /**
  69993. * Gets point stored at specified index
  69994. * @param index defines the index to look for
  69995. * @returns the requested point if found
  69996. */
  69997. getAt(index: number): MultiLinePoint;
  69998. /** Function called when a point is updated */
  69999. onPointUpdate: () => void;
  70000. /**
  70001. * Adds new points to the point collection
  70002. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  70003. * @returns the list of created MultiLinePoint
  70004. */
  70005. add(...items: (AbstractMesh | Control | {
  70006. x: string | number;
  70007. y: string | number;
  70008. })[]): MultiLinePoint[];
  70009. /**
  70010. * Adds a new point to the point collection
  70011. * @param item defines the item (mesh, control or 2d coordiantes) to add
  70012. * @returns the created MultiLinePoint
  70013. */
  70014. push(item?: (AbstractMesh | Control | {
  70015. x: string | number;
  70016. y: string | number;
  70017. })): MultiLinePoint;
  70018. /**
  70019. * Remove a specific value or point from the active point collection
  70020. * @param value defines the value or point to remove
  70021. */
  70022. remove(value: number | MultiLinePoint): void;
  70023. /**
  70024. * Resets this object to initial state (no point)
  70025. */
  70026. reset(): void;
  70027. /**
  70028. * Resets all links
  70029. */
  70030. resetLinks(): void;
  70031. /** Gets or sets line width */
  70032. get lineWidth(): number;
  70033. set lineWidth(value: number);
  70034. set horizontalAlignment(value: number);
  70035. set verticalAlignment(value: number);
  70036. protected _getTypeName(): string;
  70037. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70038. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70039. _measure(): void;
  70040. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70041. dispose(): void;
  70042. }
  70043. }
  70044. declare module BABYLON.GUI {
  70045. /**
  70046. * Class used to create radio button controls
  70047. */
  70048. export class RadioButton extends Control {
  70049. name?: string | undefined;
  70050. private _isChecked;
  70051. private _background;
  70052. private _checkSizeRatio;
  70053. private _thickness;
  70054. /** Gets or sets border thickness */
  70055. get thickness(): number;
  70056. set thickness(value: number);
  70057. /** Gets or sets group name */
  70058. group: string;
  70059. /** BABYLON.Observable raised when isChecked is changed */
  70060. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  70061. /** Gets or sets a value indicating the ratio between overall size and check size */
  70062. get checkSizeRatio(): number;
  70063. set checkSizeRatio(value: number);
  70064. /** Gets or sets background color */
  70065. get background(): string;
  70066. set background(value: string);
  70067. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  70068. get isChecked(): boolean;
  70069. set isChecked(value: boolean);
  70070. /**
  70071. * Creates a new RadioButton
  70072. * @param name defines the control name
  70073. */
  70074. constructor(name?: string | undefined);
  70075. protected _getTypeName(): string;
  70076. _draw(context: CanvasRenderingContext2D): void;
  70077. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70078. /**
  70079. * Utility function to easily create a radio button with a header
  70080. * @param title defines the label to use for the header
  70081. * @param group defines the group to use for the radio button
  70082. * @param isChecked defines the initial state of the radio button
  70083. * @param onValueChanged defines the callback to call when value changes
  70084. * @returns a StackPanel containing the radio button and a textBlock
  70085. */
  70086. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  70087. }
  70088. }
  70089. declare module BABYLON.GUI {
  70090. /**
  70091. * Class used to create slider controls
  70092. */
  70093. export class BaseSlider extends Control {
  70094. name?: string | undefined;
  70095. protected _thumbWidth: ValueAndUnit;
  70096. private _minimum;
  70097. private _maximum;
  70098. private _value;
  70099. private _isVertical;
  70100. protected _barOffset: ValueAndUnit;
  70101. private _isThumbClamped;
  70102. protected _displayThumb: boolean;
  70103. private _step;
  70104. private _lastPointerDownID;
  70105. protected _effectiveBarOffset: number;
  70106. protected _renderLeft: number;
  70107. protected _renderTop: number;
  70108. protected _renderWidth: number;
  70109. protected _renderHeight: number;
  70110. protected _backgroundBoxLength: number;
  70111. protected _backgroundBoxThickness: number;
  70112. protected _effectiveThumbThickness: number;
  70113. /** BABYLON.Observable raised when the sldier value changes */
  70114. onValueChangedObservable: BABYLON.Observable<number>;
  70115. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70116. get displayThumb(): boolean;
  70117. set displayThumb(value: boolean);
  70118. /** Gets or sets a step to apply to values (0 by default) */
  70119. get step(): number;
  70120. set step(value: number);
  70121. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70122. get barOffset(): string | number;
  70123. /** Gets main bar offset in pixels*/
  70124. get barOffsetInPixels(): number;
  70125. set barOffset(value: string | number);
  70126. /** Gets or sets thumb width */
  70127. get thumbWidth(): string | number;
  70128. /** Gets thumb width in pixels */
  70129. get thumbWidthInPixels(): number;
  70130. set thumbWidth(value: string | number);
  70131. /** Gets or sets minimum value */
  70132. get minimum(): number;
  70133. set minimum(value: number);
  70134. /** Gets or sets maximum value */
  70135. get maximum(): number;
  70136. set maximum(value: number);
  70137. /** Gets or sets current value */
  70138. get value(): number;
  70139. set value(value: number);
  70140. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70141. get isVertical(): boolean;
  70142. set isVertical(value: boolean);
  70143. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70144. get isThumbClamped(): boolean;
  70145. set isThumbClamped(value: boolean);
  70146. /**
  70147. * Creates a new BaseSlider
  70148. * @param name defines the control name
  70149. */
  70150. constructor(name?: string | undefined);
  70151. protected _getTypeName(): string;
  70152. protected _getThumbPosition(): number;
  70153. protected _getThumbThickness(type: string): number;
  70154. protected _prepareRenderingData(type: string): void;
  70155. private _pointerIsDown;
  70156. /** @hidden */
  70157. protected _updateValueFromPointer(x: number, y: number): void;
  70158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70159. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70160. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70161. }
  70162. }
  70163. declare module BABYLON.GUI {
  70164. /**
  70165. * Class used to create slider controls
  70166. */
  70167. export class Slider extends BaseSlider {
  70168. name?: string | undefined;
  70169. private _background;
  70170. private _borderColor;
  70171. private _isThumbCircle;
  70172. protected _displayValueBar: boolean;
  70173. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70174. get displayValueBar(): boolean;
  70175. set displayValueBar(value: boolean);
  70176. /** Gets or sets border color */
  70177. get borderColor(): string;
  70178. set borderColor(value: string);
  70179. /** Gets or sets background color */
  70180. get background(): string;
  70181. set background(value: string);
  70182. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70183. get isThumbCircle(): boolean;
  70184. set isThumbCircle(value: boolean);
  70185. /**
  70186. * Creates a new Slider
  70187. * @param name defines the control name
  70188. */
  70189. constructor(name?: string | undefined);
  70190. protected _getTypeName(): string;
  70191. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70192. }
  70193. }
  70194. declare module BABYLON.GUI {
  70195. /** Class used to create a RadioGroup
  70196. * which contains groups of radio buttons
  70197. */
  70198. export class SelectorGroup {
  70199. /** name of SelectorGroup */
  70200. name: string;
  70201. private _groupPanel;
  70202. private _selectors;
  70203. private _groupHeader;
  70204. /**
  70205. * Creates a new SelectorGroup
  70206. * @param name of group, used as a group heading
  70207. */
  70208. constructor(
  70209. /** name of SelectorGroup */
  70210. name: string);
  70211. /** Gets the groupPanel of the SelectorGroup */
  70212. get groupPanel(): StackPanel;
  70213. /** Gets the selectors array */
  70214. get selectors(): StackPanel[];
  70215. /** Gets and sets the group header */
  70216. get header(): string;
  70217. set header(label: string);
  70218. /** @hidden */
  70219. private _addGroupHeader;
  70220. /** @hidden*/
  70221. _getSelector(selectorNb: number): StackPanel | undefined;
  70222. /** Removes the selector at the given position
  70223. * @param selectorNb the position of the selector within the group
  70224. */
  70225. removeSelector(selectorNb: number): void;
  70226. }
  70227. /** Class used to create a CheckboxGroup
  70228. * which contains groups of checkbox buttons
  70229. */
  70230. export class CheckboxGroup extends SelectorGroup {
  70231. /** Adds a checkbox as a control
  70232. * @param text is the label for the selector
  70233. * @param func is the function called when the Selector is checked
  70234. * @param checked is true when Selector is checked
  70235. */
  70236. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70237. /** @hidden */
  70238. _setSelectorLabel(selectorNb: number, label: string): void;
  70239. /** @hidden */
  70240. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70241. /** @hidden */
  70242. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70243. /** @hidden */
  70244. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70245. }
  70246. /** Class used to create a RadioGroup
  70247. * which contains groups of radio buttons
  70248. */
  70249. export class RadioGroup extends SelectorGroup {
  70250. private _selectNb;
  70251. /** Adds a radio button as a control
  70252. * @param label is the label for the selector
  70253. * @param func is the function called when the Selector is checked
  70254. * @param checked is true when Selector is checked
  70255. */
  70256. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70257. /** @hidden */
  70258. _setSelectorLabel(selectorNb: number, label: string): void;
  70259. /** @hidden */
  70260. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70261. /** @hidden */
  70262. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70263. /** @hidden */
  70264. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70265. }
  70266. /** Class used to create a SliderGroup
  70267. * which contains groups of slider buttons
  70268. */
  70269. export class SliderGroup extends SelectorGroup {
  70270. /**
  70271. * Adds a slider to the SelectorGroup
  70272. * @param label is the label for the SliderBar
  70273. * @param func is the function called when the Slider moves
  70274. * @param unit is a string describing the units used, eg degrees or metres
  70275. * @param min is the minimum value for the Slider
  70276. * @param max is the maximum value for the Slider
  70277. * @param value is the start value for the Slider between min and max
  70278. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70279. */
  70280. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70281. /** @hidden */
  70282. _setSelectorLabel(selectorNb: number, label: string): void;
  70283. /** @hidden */
  70284. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70285. /** @hidden */
  70286. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70287. /** @hidden */
  70288. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70289. }
  70290. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70291. * @see http://doc.babylonjs.com/how_to/selector
  70292. */
  70293. export class SelectionPanel extends Rectangle {
  70294. /** name of SelectionPanel */
  70295. name: string;
  70296. /** an array of SelectionGroups */
  70297. groups: SelectorGroup[];
  70298. private _panel;
  70299. private _buttonColor;
  70300. private _buttonBackground;
  70301. private _headerColor;
  70302. private _barColor;
  70303. private _barHeight;
  70304. private _spacerHeight;
  70305. private _labelColor;
  70306. private _groups;
  70307. private _bars;
  70308. /**
  70309. * Creates a new SelectionPanel
  70310. * @param name of SelectionPanel
  70311. * @param groups is an array of SelectionGroups
  70312. */
  70313. constructor(
  70314. /** name of SelectionPanel */
  70315. name: string,
  70316. /** an array of SelectionGroups */
  70317. groups?: SelectorGroup[]);
  70318. protected _getTypeName(): string;
  70319. /** Gets or sets the headerColor */
  70320. get headerColor(): string;
  70321. set headerColor(color: string);
  70322. private _setHeaderColor;
  70323. /** Gets or sets the button color */
  70324. get buttonColor(): string;
  70325. set buttonColor(color: string);
  70326. private _setbuttonColor;
  70327. /** Gets or sets the label color */
  70328. get labelColor(): string;
  70329. set labelColor(color: string);
  70330. private _setLabelColor;
  70331. /** Gets or sets the button background */
  70332. get buttonBackground(): string;
  70333. set buttonBackground(color: string);
  70334. private _setButtonBackground;
  70335. /** Gets or sets the color of separator bar */
  70336. get barColor(): string;
  70337. set barColor(color: string);
  70338. private _setBarColor;
  70339. /** Gets or sets the height of separator bar */
  70340. get barHeight(): string;
  70341. set barHeight(value: string);
  70342. private _setBarHeight;
  70343. /** Gets or sets the height of spacers*/
  70344. get spacerHeight(): string;
  70345. set spacerHeight(value: string);
  70346. private _setSpacerHeight;
  70347. /** Adds a bar between groups */
  70348. private _addSpacer;
  70349. /** Add a group to the selection panel
  70350. * @param group is the selector group to add
  70351. */
  70352. addGroup(group: SelectorGroup): void;
  70353. /** Remove the group from the given position
  70354. * @param groupNb is the position of the group in the list
  70355. */
  70356. removeGroup(groupNb: number): void;
  70357. /** Change a group header label
  70358. * @param label is the new group header label
  70359. * @param groupNb is the number of the group to relabel
  70360. * */
  70361. setHeaderName(label: string, groupNb: number): void;
  70362. /** Change selector label to the one given
  70363. * @param label is the new selector label
  70364. * @param groupNb is the number of the groupcontaining the selector
  70365. * @param selectorNb is the number of the selector within a group to relabel
  70366. * */
  70367. relabel(label: string, groupNb: number, selectorNb: number): void;
  70368. /** For a given group position remove the selector at the given position
  70369. * @param groupNb is the number of the group to remove the selector from
  70370. * @param selectorNb is the number of the selector within the group
  70371. */
  70372. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  70373. /** For a given group position of correct type add a checkbox button
  70374. * @param groupNb is the number of the group to remove the selector from
  70375. * @param label is the label for the selector
  70376. * @param func is the function called when the Selector is checked
  70377. * @param checked is true when Selector is checked
  70378. */
  70379. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70380. /** For a given group position of correct type add a radio button
  70381. * @param groupNb is the number of the group to remove the selector from
  70382. * @param label is the label for the selector
  70383. * @param func is the function called when the Selector is checked
  70384. * @param checked is true when Selector is checked
  70385. */
  70386. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70387. /**
  70388. * For a given slider group add a slider
  70389. * @param groupNb is the number of the group to add the slider to
  70390. * @param label is the label for the Slider
  70391. * @param func is the function called when the Slider moves
  70392. * @param unit is a string describing the units used, eg degrees or metres
  70393. * @param min is the minimum value for the Slider
  70394. * @param max is the maximum value for the Slider
  70395. * @param value is the start value for the Slider between min and max
  70396. * @param onVal is the function used to format the value displayed, eg radians to degrees
  70397. */
  70398. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  70399. }
  70400. }
  70401. declare module BABYLON.GUI {
  70402. /**
  70403. * Class used to hold a the container for ScrollViewer
  70404. * @hidden
  70405. */
  70406. export class _ScrollViewerWindow extends Container {
  70407. parentClientWidth: number;
  70408. parentClientHeight: number;
  70409. /**
  70410. * Creates a new ScrollViewerWindow
  70411. * @param name of ScrollViewerWindow
  70412. */
  70413. constructor(name?: string);
  70414. protected _getTypeName(): string;
  70415. /** @hidden */
  70416. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70417. protected _postMeasure(): void;
  70418. }
  70419. }
  70420. declare module BABYLON.GUI {
  70421. /**
  70422. * Class used to create slider controls
  70423. */
  70424. export class ScrollBar extends BaseSlider {
  70425. name?: string | undefined;
  70426. private _background;
  70427. private _borderColor;
  70428. private _tempMeasure;
  70429. /** Gets or sets border color */
  70430. get borderColor(): string;
  70431. set borderColor(value: string);
  70432. /** Gets or sets background color */
  70433. get background(): string;
  70434. set background(value: string);
  70435. /**
  70436. * Creates a new Slider
  70437. * @param name defines the control name
  70438. */
  70439. constructor(name?: string | undefined);
  70440. protected _getTypeName(): string;
  70441. protected _getThumbThickness(): number;
  70442. _draw(context: CanvasRenderingContext2D): void;
  70443. private _first;
  70444. private _originX;
  70445. private _originY;
  70446. /** @hidden */
  70447. protected _updateValueFromPointer(x: number, y: number): void;
  70448. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70449. }
  70450. }
  70451. declare module BABYLON.GUI {
  70452. /**
  70453. * Class used to create slider controls
  70454. */
  70455. export class ImageScrollBar extends BaseSlider {
  70456. name?: string | undefined;
  70457. private _backgroundBaseImage;
  70458. private _backgroundImage;
  70459. private _thumbImage;
  70460. private _thumbBaseImage;
  70461. private _thumbLength;
  70462. private _thumbHeight;
  70463. private _barImageHeight;
  70464. private _tempMeasure;
  70465. /**
  70466. * Gets or sets the image used to render the background for horizontal bar
  70467. */
  70468. get backgroundImage(): Image;
  70469. set backgroundImage(value: Image);
  70470. /**
  70471. * Gets or sets the image used to render the thumb
  70472. */
  70473. get thumbImage(): Image;
  70474. set thumbImage(value: Image);
  70475. /**
  70476. * Gets or sets the length of the thumb
  70477. */
  70478. get thumbLength(): number;
  70479. set thumbLength(value: number);
  70480. /**
  70481. * Gets or sets the height of the thumb
  70482. */
  70483. get thumbHeight(): number;
  70484. set thumbHeight(value: number);
  70485. /**
  70486. * Gets or sets the height of the bar image
  70487. */
  70488. get barImageHeight(): number;
  70489. set barImageHeight(value: number);
  70490. /**
  70491. * Creates a new ImageScrollBar
  70492. * @param name defines the control name
  70493. */
  70494. constructor(name?: string | undefined);
  70495. protected _getTypeName(): string;
  70496. protected _getThumbThickness(): number;
  70497. _draw(context: CanvasRenderingContext2D): void;
  70498. private _first;
  70499. private _originX;
  70500. private _originY;
  70501. /** @hidden */
  70502. protected _updateValueFromPointer(x: number, y: number): void;
  70503. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70504. }
  70505. }
  70506. declare module BABYLON.GUI {
  70507. /**
  70508. * Class used to hold a viewer window and sliders in a grid
  70509. */
  70510. export class ScrollViewer extends Rectangle {
  70511. private _grid;
  70512. private _horizontalBarSpace;
  70513. private _verticalBarSpace;
  70514. private _dragSpace;
  70515. private _horizontalBar;
  70516. private _verticalBar;
  70517. private _barColor;
  70518. private _barBackground;
  70519. private _barImage;
  70520. private _barBackgroundImage;
  70521. private _barSize;
  70522. private _endLeft;
  70523. private _endTop;
  70524. private _window;
  70525. private _pointerIsOver;
  70526. private _wheelPrecision;
  70527. private _onPointerObserver;
  70528. private _clientWidth;
  70529. private _clientHeight;
  70530. private _useImageBar;
  70531. private _thumbLength;
  70532. private _thumbHeight;
  70533. private _barImageHeight;
  70534. /**
  70535. * Gets the horizontal scrollbar
  70536. */
  70537. get horizontalBar(): ScrollBar | ImageScrollBar;
  70538. /**
  70539. * Gets the vertical scrollbar
  70540. */
  70541. get verticalBar(): ScrollBar | ImageScrollBar;
  70542. /**
  70543. * Adds a new control to the current container
  70544. * @param control defines the control to add
  70545. * @returns the current container
  70546. */
  70547. addControl(control: BABYLON.Nullable<Control>): Container;
  70548. /**
  70549. * Removes a control from the current container
  70550. * @param control defines the control to remove
  70551. * @returns the current container
  70552. */
  70553. removeControl(control: Control): Container;
  70554. /** Gets the list of children */
  70555. get children(): Control[];
  70556. _flagDescendantsAsMatrixDirty(): void;
  70557. /**
  70558. * Creates a new ScrollViewer
  70559. * @param name of ScrollViewer
  70560. */
  70561. constructor(name?: string, isImageBased?: boolean);
  70562. /** Reset the scroll viewer window to initial size */
  70563. resetWindow(): void;
  70564. protected _getTypeName(): string;
  70565. private _buildClientSizes;
  70566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70567. protected _postMeasure(): void;
  70568. /**
  70569. * Gets or sets the mouse wheel precision
  70570. * from 0 to 1 with a default value of 0.05
  70571. * */
  70572. get wheelPrecision(): number;
  70573. set wheelPrecision(value: number);
  70574. /** Gets or sets the scroll bar container background color */
  70575. get scrollBackground(): string;
  70576. set scrollBackground(color: string);
  70577. /** Gets or sets the bar color */
  70578. get barColor(): string;
  70579. set barColor(color: string);
  70580. /** Gets or sets the bar image */
  70581. get thumbImage(): Image;
  70582. set thumbImage(value: Image);
  70583. /** Gets or sets the size of the bar */
  70584. get barSize(): number;
  70585. set barSize(value: number);
  70586. /** Gets or sets the length of the thumb */
  70587. get thumbLength(): number;
  70588. set thumbLength(value: number);
  70589. /** Gets or sets the height of the thumb */
  70590. get thumbHeight(): number;
  70591. set thumbHeight(value: number);
  70592. /** Gets or sets the height of the bar image */
  70593. get barImageHeight(): number;
  70594. set barImageHeight(value: number);
  70595. /** Gets or sets the bar background */
  70596. get barBackground(): string;
  70597. set barBackground(color: string);
  70598. /** Gets or sets the bar background image */
  70599. get barImage(): Image;
  70600. set barImage(value: Image);
  70601. /** @hidden */
  70602. private _updateScroller;
  70603. _link(host: AdvancedDynamicTexture): void;
  70604. /** @hidden */
  70605. private _addBar;
  70606. /** @hidden */
  70607. private _attachWheel;
  70608. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70609. /** Releases associated resources */
  70610. dispose(): void;
  70611. }
  70612. }
  70613. declare module BABYLON.GUI {
  70614. /** Class used to render a grid */
  70615. export class DisplayGrid extends Control {
  70616. name?: string | undefined;
  70617. private _cellWidth;
  70618. private _cellHeight;
  70619. private _minorLineTickness;
  70620. private _minorLineColor;
  70621. private _majorLineTickness;
  70622. private _majorLineColor;
  70623. private _majorLineFrequency;
  70624. private _background;
  70625. private _displayMajorLines;
  70626. private _displayMinorLines;
  70627. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  70628. get displayMinorLines(): boolean;
  70629. set displayMinorLines(value: boolean);
  70630. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  70631. get displayMajorLines(): boolean;
  70632. set displayMajorLines(value: boolean);
  70633. /** Gets or sets background color (Black by default) */
  70634. get background(): string;
  70635. set background(value: string);
  70636. /** Gets or sets the width of each cell (20 by default) */
  70637. get cellWidth(): number;
  70638. set cellWidth(value: number);
  70639. /** Gets or sets the height of each cell (20 by default) */
  70640. get cellHeight(): number;
  70641. set cellHeight(value: number);
  70642. /** Gets or sets the tickness of minor lines (1 by default) */
  70643. get minorLineTickness(): number;
  70644. set minorLineTickness(value: number);
  70645. /** Gets or sets the color of minor lines (DarkGray by default) */
  70646. get minorLineColor(): string;
  70647. set minorLineColor(value: string);
  70648. /** Gets or sets the tickness of major lines (2 by default) */
  70649. get majorLineTickness(): number;
  70650. set majorLineTickness(value: number);
  70651. /** Gets or sets the color of major lines (White by default) */
  70652. get majorLineColor(): string;
  70653. set majorLineColor(value: string);
  70654. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  70655. get majorLineFrequency(): number;
  70656. set majorLineFrequency(value: number);
  70657. /**
  70658. * Creates a new GridDisplayRectangle
  70659. * @param name defines the control name
  70660. */
  70661. constructor(name?: string | undefined);
  70662. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70663. protected _getTypeName(): string;
  70664. }
  70665. }
  70666. declare module BABYLON.GUI {
  70667. /**
  70668. * Class used to create slider controls based on images
  70669. */
  70670. export class ImageBasedSlider extends BaseSlider {
  70671. name?: string | undefined;
  70672. private _backgroundImage;
  70673. private _thumbImage;
  70674. private _valueBarImage;
  70675. private _tempMeasure;
  70676. get displayThumb(): boolean;
  70677. set displayThumb(value: boolean);
  70678. /**
  70679. * Gets or sets the image used to render the background
  70680. */
  70681. get backgroundImage(): Image;
  70682. set backgroundImage(value: Image);
  70683. /**
  70684. * Gets or sets the image used to render the value bar
  70685. */
  70686. get valueBarImage(): Image;
  70687. set valueBarImage(value: Image);
  70688. /**
  70689. * Gets or sets the image used to render the thumb
  70690. */
  70691. get thumbImage(): Image;
  70692. set thumbImage(value: Image);
  70693. /**
  70694. * Creates a new ImageBasedSlider
  70695. * @param name defines the control name
  70696. */
  70697. constructor(name?: string | undefined);
  70698. protected _getTypeName(): string;
  70699. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70700. }
  70701. }
  70702. declare module BABYLON.GUI {
  70703. /**
  70704. * Forcing an export so that this code will execute
  70705. * @hidden
  70706. */
  70707. const name = "Statics";
  70708. }
  70709. declare module BABYLON.GUI {
  70710. /**
  70711. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  70712. */
  70713. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  70714. /**
  70715. * Define the instrumented AdvancedDynamicTexture.
  70716. */
  70717. texture: AdvancedDynamicTexture;
  70718. private _captureRenderTime;
  70719. private _renderTime;
  70720. private _captureLayoutTime;
  70721. private _layoutTime;
  70722. private _onBeginRenderObserver;
  70723. private _onEndRenderObserver;
  70724. private _onBeginLayoutObserver;
  70725. private _onEndLayoutObserver;
  70726. /**
  70727. * Gets the perf counter used to capture render time
  70728. */
  70729. get renderTimeCounter(): BABYLON.PerfCounter;
  70730. /**
  70731. * Gets the perf counter used to capture layout time
  70732. */
  70733. get layoutTimeCounter(): BABYLON.PerfCounter;
  70734. /**
  70735. * Enable or disable the render time capture
  70736. */
  70737. get captureRenderTime(): boolean;
  70738. set captureRenderTime(value: boolean);
  70739. /**
  70740. * Enable or disable the layout time capture
  70741. */
  70742. get captureLayoutTime(): boolean;
  70743. set captureLayoutTime(value: boolean);
  70744. /**
  70745. * Instantiates a new advanced dynamic texture instrumentation.
  70746. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  70747. * @param texture Defines the AdvancedDynamicTexture to instrument
  70748. */
  70749. constructor(
  70750. /**
  70751. * Define the instrumented AdvancedDynamicTexture.
  70752. */
  70753. texture: AdvancedDynamicTexture);
  70754. /**
  70755. * Dispose and release associated resources.
  70756. */
  70757. dispose(): void;
  70758. }
  70759. }
  70760. declare module BABYLON.GUI {
  70761. /**
  70762. * Class used to load GUI via XML.
  70763. */
  70764. export class XmlLoader {
  70765. private _nodes;
  70766. private _nodeTypes;
  70767. private _isLoaded;
  70768. private _objectAttributes;
  70769. private _parentClass;
  70770. /**
  70771. * Create a new xml loader
  70772. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  70773. */
  70774. constructor(parentClass?: null);
  70775. private _getChainElement;
  70776. private _getClassAttribute;
  70777. private _createGuiElement;
  70778. private _parseGrid;
  70779. private _parseElement;
  70780. private _prepareSourceElement;
  70781. private _parseElementsFromSource;
  70782. private _parseXml;
  70783. /**
  70784. * Gets if the loading has finished.
  70785. * @returns whether the loading has finished or not
  70786. */
  70787. isLoaded(): boolean;
  70788. /**
  70789. * Gets a loaded node / control by id.
  70790. * @param id the Controls id set in the xml
  70791. * @returns element of type Control
  70792. */
  70793. getNodeById(id: string): any;
  70794. /**
  70795. * Gets all loaded nodes / controls
  70796. * @returns Array of controls
  70797. */
  70798. getNodes(): any;
  70799. /**
  70800. * Initiates the xml layout loading
  70801. * @param xmlFile defines the xml layout to load
  70802. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  70803. * @param callback defines the callback called on layout load.
  70804. */
  70805. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  70806. }
  70807. }
  70808. declare module BABYLON.GUI {
  70809. /**
  70810. * Class used to create containers for controls
  70811. */
  70812. export class Container3D extends Control3D {
  70813. private _blockLayout;
  70814. /**
  70815. * Gets the list of child controls
  70816. */
  70817. protected _children: Control3D[];
  70818. /**
  70819. * Gets the list of child controls
  70820. */
  70821. get children(): Array<Control3D>;
  70822. /**
  70823. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  70824. * This is helpful to optimize layout operation when adding multiple children in a row
  70825. */
  70826. get blockLayout(): boolean;
  70827. set blockLayout(value: boolean);
  70828. /**
  70829. * Creates a new container
  70830. * @param name defines the container name
  70831. */
  70832. constructor(name?: string);
  70833. /**
  70834. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  70835. * @returns the current container
  70836. */
  70837. updateLayout(): Container3D;
  70838. /**
  70839. * Gets a boolean indicating if the given control is in the children of this control
  70840. * @param control defines the control to check
  70841. * @returns true if the control is in the child list
  70842. */
  70843. containsControl(control: Control3D): boolean;
  70844. /**
  70845. * Adds a control to the children of this control
  70846. * @param control defines the control to add
  70847. * @returns the current container
  70848. */
  70849. addControl(control: Control3D): Container3D;
  70850. /**
  70851. * This function will be called everytime a new control is added
  70852. */
  70853. protected _arrangeChildren(): void;
  70854. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70855. /**
  70856. * Removes a control from the children of this control
  70857. * @param control defines the control to remove
  70858. * @returns the current container
  70859. */
  70860. removeControl(control: Control3D): Container3D;
  70861. protected _getTypeName(): string;
  70862. /**
  70863. * Releases all associated resources
  70864. */
  70865. dispose(): void;
  70866. /** Control rotation will remain unchanged */
  70867. static readonly UNSET_ORIENTATION: number;
  70868. /** Control will rotate to make it look at sphere central axis */
  70869. static readonly FACEORIGIN_ORIENTATION: number;
  70870. /** Control will rotate to make it look back at sphere central axis */
  70871. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  70872. /** Control will rotate to look at z axis (0, 0, 1) */
  70873. static readonly FACEFORWARD_ORIENTATION: number;
  70874. /** Control will rotate to look at negative z axis (0, 0, -1) */
  70875. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  70876. }
  70877. }
  70878. declare module BABYLON.GUI {
  70879. /**
  70880. * Class used to manage 3D user interface
  70881. * @see http://doc.babylonjs.com/how_to/gui3d
  70882. */
  70883. export class GUI3DManager implements BABYLON.IDisposable {
  70884. private _scene;
  70885. private _sceneDisposeObserver;
  70886. private _utilityLayer;
  70887. private _rootContainer;
  70888. private _pointerObserver;
  70889. private _pointerOutObserver;
  70890. /** @hidden */
  70891. _lastPickedControl: Control3D;
  70892. /** @hidden */
  70893. _lastControlOver: {
  70894. [pointerId: number]: Control3D;
  70895. };
  70896. /** @hidden */
  70897. _lastControlDown: {
  70898. [pointerId: number]: Control3D;
  70899. };
  70900. /**
  70901. * BABYLON.Observable raised when the point picked by the pointer events changed
  70902. */
  70903. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70904. /** @hidden */
  70905. _sharedMaterials: {
  70906. [key: string]: BABYLON.Material;
  70907. };
  70908. /** Gets the hosting scene */
  70909. get scene(): BABYLON.Scene;
  70910. /** Gets associated utility layer */
  70911. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70912. /**
  70913. * Creates a new GUI3DManager
  70914. * @param scene
  70915. */
  70916. constructor(scene?: BABYLON.Scene);
  70917. private _handlePointerOut;
  70918. private _doPicking;
  70919. /**
  70920. * Gets the root container
  70921. */
  70922. get rootContainer(): Container3D;
  70923. /**
  70924. * Gets a boolean indicating if the given control is in the root child list
  70925. * @param control defines the control to check
  70926. * @returns true if the control is in the root child list
  70927. */
  70928. containsControl(control: Control3D): boolean;
  70929. /**
  70930. * Adds a control to the root child list
  70931. * @param control defines the control to add
  70932. * @returns the current manager
  70933. */
  70934. addControl(control: Control3D): GUI3DManager;
  70935. /**
  70936. * Removes a control from the root child list
  70937. * @param control defines the control to remove
  70938. * @returns the current container
  70939. */
  70940. removeControl(control: Control3D): GUI3DManager;
  70941. /**
  70942. * Releases all associated resources
  70943. */
  70944. dispose(): void;
  70945. }
  70946. }
  70947. declare module BABYLON.GUI {
  70948. /**
  70949. * Class used to transport BABYLON.Vector3 information for pointer events
  70950. */
  70951. export class Vector3WithInfo extends BABYLON.Vector3 {
  70952. /** defines the current mouse button index */
  70953. buttonIndex: number;
  70954. /**
  70955. * Creates a new Vector3WithInfo
  70956. * @param source defines the vector3 data to transport
  70957. * @param buttonIndex defines the current mouse button index
  70958. */
  70959. constructor(source: BABYLON.Vector3,
  70960. /** defines the current mouse button index */
  70961. buttonIndex?: number);
  70962. }
  70963. }
  70964. declare module BABYLON.GUI {
  70965. /**
  70966. * Class used as base class for controls
  70967. */
  70968. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70969. /** Defines the control name */
  70970. name?: string | undefined;
  70971. /** @hidden */
  70972. _host: GUI3DManager;
  70973. private _node;
  70974. private _downCount;
  70975. private _enterCount;
  70976. private _downPointerIds;
  70977. private _isVisible;
  70978. /** Gets or sets the control position in world space */
  70979. get position(): BABYLON.Vector3;
  70980. set position(value: BABYLON.Vector3);
  70981. /** Gets or sets the control scaling in world space */
  70982. get scaling(): BABYLON.Vector3;
  70983. set scaling(value: BABYLON.Vector3);
  70984. /** Callback used to start pointer enter animation */
  70985. pointerEnterAnimation: () => void;
  70986. /** Callback used to start pointer out animation */
  70987. pointerOutAnimation: () => void;
  70988. /** Callback used to start pointer down animation */
  70989. pointerDownAnimation: () => void;
  70990. /** Callback used to start pointer up animation */
  70991. pointerUpAnimation: () => void;
  70992. /**
  70993. * An event triggered when the pointer move over the control
  70994. */
  70995. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70996. /**
  70997. * An event triggered when the pointer move out of the control
  70998. */
  70999. onPointerOutObservable: BABYLON.Observable<Control3D>;
  71000. /**
  71001. * An event triggered when the pointer taps the control
  71002. */
  71003. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  71004. /**
  71005. * An event triggered when pointer is up
  71006. */
  71007. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  71008. /**
  71009. * An event triggered when a control is clicked on (with a mouse)
  71010. */
  71011. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  71012. /**
  71013. * An event triggered when pointer enters the control
  71014. */
  71015. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  71016. /**
  71017. * Gets or sets the parent container
  71018. */
  71019. parent: BABYLON.Nullable<Container3D>;
  71020. private _behaviors;
  71021. /**
  71022. * Gets the list of attached behaviors
  71023. * @see http://doc.babylonjs.com/features/behaviour
  71024. */
  71025. get behaviors(): BABYLON.Behavior<Control3D>[];
  71026. /**
  71027. * Attach a behavior to the control
  71028. * @see http://doc.babylonjs.com/features/behaviour
  71029. * @param behavior defines the behavior to attach
  71030. * @returns the current control
  71031. */
  71032. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71033. /**
  71034. * Remove an attached behavior
  71035. * @see http://doc.babylonjs.com/features/behaviour
  71036. * @param behavior defines the behavior to attach
  71037. * @returns the current control
  71038. */
  71039. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71040. /**
  71041. * Gets an attached behavior by name
  71042. * @param name defines the name of the behavior to look for
  71043. * @see http://doc.babylonjs.com/features/behaviour
  71044. * @returns null if behavior was not found else the requested behavior
  71045. */
  71046. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  71047. /** Gets or sets a boolean indicating if the control is visible */
  71048. get isVisible(): boolean;
  71049. set isVisible(value: boolean);
  71050. /**
  71051. * Creates a new control
  71052. * @param name defines the control name
  71053. */
  71054. constructor(
  71055. /** Defines the control name */
  71056. name?: string | undefined);
  71057. /**
  71058. * Gets a string representing the class name
  71059. */
  71060. get typeName(): string;
  71061. /**
  71062. * Get the current class name of the control.
  71063. * @returns current class name
  71064. */
  71065. getClassName(): string;
  71066. protected _getTypeName(): string;
  71067. /**
  71068. * Gets the transform node used by this control
  71069. */
  71070. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  71071. /**
  71072. * Gets the mesh used to render this control
  71073. */
  71074. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71075. /**
  71076. * Link the control as child of the given node
  71077. * @param node defines the node to link to. Use null to unlink the control
  71078. * @returns the current control
  71079. */
  71080. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  71081. /** @hidden **/
  71082. _prepareNode(scene: BABYLON.Scene): void;
  71083. /**
  71084. * Node creation.
  71085. * Can be overriden by children
  71086. * @param scene defines the scene where the node must be attached
  71087. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  71088. */
  71089. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71090. /**
  71091. * Affect a material to the given mesh
  71092. * @param mesh defines the mesh which will represent the control
  71093. */
  71094. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71095. /** @hidden */
  71096. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71097. /** @hidden */
  71098. _onPointerEnter(target: Control3D): boolean;
  71099. /** @hidden */
  71100. _onPointerOut(target: Control3D): void;
  71101. /** @hidden */
  71102. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71103. /** @hidden */
  71104. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71105. /** @hidden */
  71106. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71107. /** @hidden */
  71108. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71109. /** @hidden */
  71110. _disposeNode(): void;
  71111. /**
  71112. * Releases all associated resources
  71113. */
  71114. dispose(): void;
  71115. }
  71116. }
  71117. declare module BABYLON.GUI {
  71118. /**
  71119. * Class used as a root to all buttons
  71120. */
  71121. export class AbstractButton3D extends Control3D {
  71122. /**
  71123. * Creates a new button
  71124. * @param name defines the control name
  71125. */
  71126. constructor(name?: string);
  71127. protected _getTypeName(): string;
  71128. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71129. }
  71130. }
  71131. declare module BABYLON.GUI {
  71132. /**
  71133. * Class used to create a button in 3D
  71134. */
  71135. export class Button3D extends AbstractButton3D {
  71136. /** @hidden */
  71137. protected _currentMaterial: BABYLON.Material;
  71138. private _facadeTexture;
  71139. private _content;
  71140. private _contentResolution;
  71141. private _contentScaleRatio;
  71142. /**
  71143. * Gets or sets the texture resolution used to render content (512 by default)
  71144. */
  71145. get contentResolution(): BABYLON.int;
  71146. set contentResolution(value: BABYLON.int);
  71147. /**
  71148. * Gets or sets the texture scale ratio used to render content (2 by default)
  71149. */
  71150. get contentScaleRatio(): number;
  71151. set contentScaleRatio(value: number);
  71152. protected _disposeFacadeTexture(): void;
  71153. protected _resetContent(): void;
  71154. /**
  71155. * Creates a new button
  71156. * @param name defines the control name
  71157. */
  71158. constructor(name?: string);
  71159. /**
  71160. * Gets or sets the GUI 2D content used to display the button's facade
  71161. */
  71162. get content(): Control;
  71163. set content(value: Control);
  71164. /**
  71165. * Apply the facade texture (created from the content property).
  71166. * This function can be overloaded by child classes
  71167. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71168. */
  71169. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71170. protected _getTypeName(): string;
  71171. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71172. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71173. /**
  71174. * Releases all associated resources
  71175. */
  71176. dispose(): void;
  71177. }
  71178. }
  71179. declare module BABYLON.GUI {
  71180. /**
  71181. * Abstract class used to create a container panel deployed on the surface of a volume
  71182. */
  71183. export abstract class VolumeBasedPanel extends Container3D {
  71184. private _columns;
  71185. private _rows;
  71186. private _rowThenColum;
  71187. private _orientation;
  71188. protected _cellWidth: number;
  71189. protected _cellHeight: number;
  71190. /**
  71191. * Gets or sets the distance between elements
  71192. */
  71193. margin: number;
  71194. /**
  71195. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71196. * | Value | Type | Description |
  71197. * | ----- | ----------------------------------- | ----------- |
  71198. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71199. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71200. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71201. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71202. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71203. */
  71204. get orientation(): number;
  71205. set orientation(value: number);
  71206. /**
  71207. * Gets or sets the number of columns requested (10 by default).
  71208. * The panel will automatically compute the number of rows based on number of child controls.
  71209. */
  71210. get columns(): BABYLON.int;
  71211. set columns(value: BABYLON.int);
  71212. /**
  71213. * Gets or sets a the number of rows requested.
  71214. * The panel will automatically compute the number of columns based on number of child controls.
  71215. */
  71216. get rows(): BABYLON.int;
  71217. set rows(value: BABYLON.int);
  71218. /**
  71219. * Creates new VolumeBasedPanel
  71220. */
  71221. constructor();
  71222. protected _arrangeChildren(): void;
  71223. /** Child classes must implement this function to provide correct control positioning */
  71224. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71225. /** Child classes can implement this function to provide additional processing */
  71226. protected _finalProcessing(): void;
  71227. }
  71228. }
  71229. declare module BABYLON.GUI {
  71230. /**
  71231. * Class used to create a container panel deployed on the surface of a cylinder
  71232. */
  71233. export class CylinderPanel extends VolumeBasedPanel {
  71234. private _radius;
  71235. /**
  71236. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71237. */
  71238. get radius(): BABYLON.float;
  71239. set radius(value: BABYLON.float);
  71240. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71241. private _cylindricalMapping;
  71242. }
  71243. }
  71244. declare module BABYLON.GUI {
  71245. /** @hidden */
  71246. export var fluentVertexShader: {
  71247. name: string;
  71248. shader: string;
  71249. };
  71250. }
  71251. declare module BABYLON.GUI {
  71252. /** @hidden */
  71253. export var fluentPixelShader: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module BABYLON.GUI {
  71259. /** @hidden */
  71260. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71261. INNERGLOW: boolean;
  71262. BORDER: boolean;
  71263. HOVERLIGHT: boolean;
  71264. TEXTURE: boolean;
  71265. constructor();
  71266. }
  71267. /**
  71268. * Class used to render controls with fluent desgin
  71269. */
  71270. export class FluentMaterial extends BABYLON.PushMaterial {
  71271. /**
  71272. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71273. */
  71274. innerGlowColorIntensity: number;
  71275. /**
  71276. * Gets or sets the inner glow color (white by default)
  71277. */
  71278. innerGlowColor: BABYLON.Color3;
  71279. /**
  71280. * Gets or sets alpha value (default is 1.0)
  71281. */
  71282. alpha: number;
  71283. /**
  71284. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71285. */
  71286. albedoColor: BABYLON.Color3;
  71287. /**
  71288. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71289. */
  71290. renderBorders: boolean;
  71291. /**
  71292. * Gets or sets border width (default is 0.5)
  71293. */
  71294. borderWidth: number;
  71295. /**
  71296. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71297. */
  71298. edgeSmoothingValue: number;
  71299. /**
  71300. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71301. */
  71302. borderMinValue: number;
  71303. /**
  71304. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71305. */
  71306. renderHoverLight: boolean;
  71307. /**
  71308. * Gets or sets the radius used to render the hover light (default is 1.0)
  71309. */
  71310. hoverRadius: number;
  71311. /**
  71312. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71313. */
  71314. hoverColor: BABYLON.Color4;
  71315. /**
  71316. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71317. */
  71318. hoverPosition: BABYLON.Vector3;
  71319. private _albedoTexture;
  71320. /** Gets or sets the texture to use for albedo color */
  71321. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71322. /**
  71323. * Creates a new Fluent material
  71324. * @param name defines the name of the material
  71325. * @param scene defines the hosting scene
  71326. */
  71327. constructor(name: string, scene: BABYLON.Scene);
  71328. needAlphaBlending(): boolean;
  71329. needAlphaTesting(): boolean;
  71330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71332. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71333. getActiveTextures(): BABYLON.BaseTexture[];
  71334. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71335. dispose(forceDisposeEffect?: boolean): void;
  71336. clone(name: string): FluentMaterial;
  71337. serialize(): any;
  71338. getClassName(): string;
  71339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  71340. }
  71341. }
  71342. declare module BABYLON.GUI {
  71343. /**
  71344. * Class used to create a holographic button in 3D
  71345. */
  71346. export class HolographicButton extends Button3D {
  71347. private _backPlate;
  71348. private _textPlate;
  71349. private _frontPlate;
  71350. private _text;
  71351. private _imageUrl;
  71352. private _shareMaterials;
  71353. private _frontMaterial;
  71354. private _backMaterial;
  71355. private _plateMaterial;
  71356. private _pickedPointObserver;
  71357. private _tooltipFade;
  71358. private _tooltipTextBlock;
  71359. private _tooltipTexture;
  71360. private _tooltipMesh;
  71361. private _tooltipHoverObserver;
  71362. private _tooltipOutObserver;
  71363. private _disposeTooltip;
  71364. /**
  71365. * Rendering ground id of all the mesh in the button
  71366. */
  71367. set renderingGroupId(id: number);
  71368. get renderingGroupId(): number;
  71369. /**
  71370. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  71371. */
  71372. set tooltipText(text: BABYLON.Nullable<string>);
  71373. get tooltipText(): BABYLON.Nullable<string>;
  71374. /**
  71375. * Gets or sets text for the button
  71376. */
  71377. get text(): string;
  71378. set text(value: string);
  71379. /**
  71380. * Gets or sets the image url for the button
  71381. */
  71382. get imageUrl(): string;
  71383. set imageUrl(value: string);
  71384. /**
  71385. * Gets the back material used by this button
  71386. */
  71387. get backMaterial(): FluentMaterial;
  71388. /**
  71389. * Gets the front material used by this button
  71390. */
  71391. get frontMaterial(): FluentMaterial;
  71392. /**
  71393. * Gets the plate material used by this button
  71394. */
  71395. get plateMaterial(): BABYLON.StandardMaterial;
  71396. /**
  71397. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  71398. */
  71399. get shareMaterials(): boolean;
  71400. /**
  71401. * Creates a new button
  71402. * @param name defines the control name
  71403. */
  71404. constructor(name?: string, shareMaterials?: boolean);
  71405. protected _getTypeName(): string;
  71406. private _rebuildContent;
  71407. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71408. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71409. private _createBackMaterial;
  71410. private _createFrontMaterial;
  71411. private _createPlateMaterial;
  71412. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  71413. /**
  71414. * Releases all associated resources
  71415. */
  71416. dispose(): void;
  71417. }
  71418. }
  71419. declare module BABYLON.GUI {
  71420. /**
  71421. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  71422. */
  71423. export class MeshButton3D extends Button3D {
  71424. /** @hidden */
  71425. protected _currentMesh: BABYLON.Mesh;
  71426. /**
  71427. * Creates a new 3D button based on a mesh
  71428. * @param mesh mesh to become a 3D button
  71429. * @param name defines the control name
  71430. */
  71431. constructor(mesh: BABYLON.Mesh, name?: string);
  71432. protected _getTypeName(): string;
  71433. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71434. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71435. }
  71436. }
  71437. declare module BABYLON.GUI {
  71438. /**
  71439. * Class used to create a container panel deployed on the surface of a plane
  71440. */
  71441. export class PlanePanel extends VolumeBasedPanel {
  71442. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71443. }
  71444. }
  71445. declare module BABYLON.GUI {
  71446. /**
  71447. * Class used to create a container panel where items get randomized planar mapping
  71448. */
  71449. export class ScatterPanel extends VolumeBasedPanel {
  71450. private _iteration;
  71451. /**
  71452. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  71453. */
  71454. get iteration(): BABYLON.float;
  71455. set iteration(value: BABYLON.float);
  71456. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71457. private _scatterMapping;
  71458. protected _finalProcessing(): void;
  71459. }
  71460. }
  71461. declare module BABYLON.GUI {
  71462. /**
  71463. * Class used to create a container panel deployed on the surface of a sphere
  71464. */
  71465. export class SpherePanel extends VolumeBasedPanel {
  71466. private _radius;
  71467. /**
  71468. * Gets or sets the radius of the sphere where to project controls (5 by default)
  71469. */
  71470. get radius(): BABYLON.float;
  71471. set radius(value: BABYLON.float);
  71472. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71473. private _sphericalMapping;
  71474. }
  71475. }
  71476. declare module BABYLON.GUI {
  71477. /**
  71478. * Class used to create a stack panel in 3D on XY plane
  71479. */
  71480. export class StackPanel3D extends Container3D {
  71481. private _isVertical;
  71482. /**
  71483. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  71484. */
  71485. get isVertical(): boolean;
  71486. set isVertical(value: boolean);
  71487. /**
  71488. * Gets or sets the distance between elements
  71489. */
  71490. margin: number;
  71491. /**
  71492. * Creates new StackPanel
  71493. * @param isVertical
  71494. */
  71495. constructor(isVertical?: boolean);
  71496. protected _arrangeChildren(): void;
  71497. }
  71498. }
  71499. declare module BABYLON {
  71500. /**
  71501. * Configuration for glTF validation
  71502. */
  71503. export interface IGLTFValidationConfiguration {
  71504. /**
  71505. * The url of the glTF validator.
  71506. */
  71507. url: string;
  71508. }
  71509. /**
  71510. * glTF validation
  71511. */
  71512. export class GLTFValidation {
  71513. /**
  71514. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  71515. */
  71516. static Configuration: IGLTFValidationConfiguration;
  71517. private static _LoadScriptPromise;
  71518. /**
  71519. * Validate a glTF asset using the glTF-Validator.
  71520. * @param data The JSON of a glTF or the array buffer of a binary glTF
  71521. * @param rootUrl The root url for the glTF
  71522. * @param fileName The file name for the glTF
  71523. * @param getExternalResource The callback to get external resources for the glTF validator
  71524. * @returns A promise that resolves with the glTF validation results once complete
  71525. */
  71526. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  71527. }
  71528. }
  71529. declare module BABYLON {
  71530. /**
  71531. * Mode that determines the coordinate system to use.
  71532. */
  71533. export enum GLTFLoaderCoordinateSystemMode {
  71534. /**
  71535. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  71536. */
  71537. AUTO = 0,
  71538. /**
  71539. * Sets the useRightHandedSystem flag on the scene.
  71540. */
  71541. FORCE_RIGHT_HANDED = 1
  71542. }
  71543. /**
  71544. * Mode that determines what animations will start.
  71545. */
  71546. export enum GLTFLoaderAnimationStartMode {
  71547. /**
  71548. * No animation will start.
  71549. */
  71550. NONE = 0,
  71551. /**
  71552. * The first animation will start.
  71553. */
  71554. FIRST = 1,
  71555. /**
  71556. * All animations will start.
  71557. */
  71558. ALL = 2
  71559. }
  71560. /**
  71561. * Interface that contains the data for the glTF asset.
  71562. */
  71563. export interface IGLTFLoaderData {
  71564. /**
  71565. * The object that represents the glTF JSON.
  71566. */
  71567. json: Object;
  71568. /**
  71569. * The BIN chunk of a binary glTF.
  71570. */
  71571. bin: Nullable<IDataBuffer>;
  71572. }
  71573. /**
  71574. * Interface for extending the loader.
  71575. */
  71576. export interface IGLTFLoaderExtension {
  71577. /**
  71578. * The name of this extension.
  71579. */
  71580. readonly name: string;
  71581. /**
  71582. * Defines whether this extension is enabled.
  71583. */
  71584. enabled: boolean;
  71585. /**
  71586. * Defines the order of this extension.
  71587. * The loader sorts the extensions using these values when loading.
  71588. */
  71589. order?: number;
  71590. }
  71591. /**
  71592. * Loader state.
  71593. */
  71594. export enum GLTFLoaderState {
  71595. /**
  71596. * The asset is loading.
  71597. */
  71598. LOADING = 0,
  71599. /**
  71600. * The asset is ready for rendering.
  71601. */
  71602. READY = 1,
  71603. /**
  71604. * The asset is completely loaded.
  71605. */
  71606. COMPLETE = 2
  71607. }
  71608. /** @hidden */
  71609. export interface IGLTFLoader extends IDisposable {
  71610. readonly state: Nullable<GLTFLoaderState>;
  71611. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  71612. meshes: AbstractMesh[];
  71613. particleSystems: IParticleSystem[];
  71614. skeletons: Skeleton[];
  71615. animationGroups: AnimationGroup[];
  71616. }>;
  71617. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  71618. }
  71619. /**
  71620. * File loader for loading glTF files into a scene.
  71621. */
  71622. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71623. /** @hidden */
  71624. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71625. /** @hidden */
  71626. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71627. /**
  71628. * Raised when the asset has been parsed
  71629. */
  71630. onParsedObservable: Observable<IGLTFLoaderData>;
  71631. private _onParsedObserver;
  71632. /**
  71633. * Raised when the asset has been parsed
  71634. */
  71635. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  71636. /**
  71637. * 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.
  71638. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  71639. * Defaults to true.
  71640. * @hidden
  71641. */
  71642. static IncrementalLoading: boolean;
  71643. /**
  71644. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  71645. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  71646. * @hidden
  71647. */
  71648. static HomogeneousCoordinates: boolean;
  71649. /**
  71650. * The coordinate system mode. Defaults to AUTO.
  71651. */
  71652. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  71653. /**
  71654. * The animation start mode. Defaults to FIRST.
  71655. */
  71656. animationStartMode: GLTFLoaderAnimationStartMode;
  71657. /**
  71658. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  71659. */
  71660. compileMaterials: boolean;
  71661. /**
  71662. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  71663. */
  71664. useClipPlane: boolean;
  71665. /**
  71666. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  71667. */
  71668. compileShadowGenerators: boolean;
  71669. /**
  71670. * Defines if the Alpha blended materials are only applied as coverage.
  71671. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  71672. * If true, no extra effects are applied to transparent pixels.
  71673. */
  71674. transparencyAsCoverage: boolean;
  71675. /**
  71676. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  71677. * Enabling will disable offline support and glTF validator.
  71678. * Defaults to false.
  71679. */
  71680. useRangeRequests: boolean;
  71681. /**
  71682. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  71683. */
  71684. createInstances: boolean;
  71685. /**
  71686. * Function called before loading a url referenced by the asset.
  71687. */
  71688. preprocessUrlAsync: (url: string) => Promise<string>;
  71689. /**
  71690. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71691. */
  71692. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  71693. private _onMeshLoadedObserver;
  71694. /**
  71695. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71696. */
  71697. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  71698. /**
  71699. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  71700. */
  71701. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  71702. private _onTextureLoadedObserver;
  71703. /**
  71704. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  71705. */
  71706. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  71707. /**
  71708. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  71709. */
  71710. readonly onMaterialLoadedObservable: Observable<Material>;
  71711. private _onMaterialLoadedObserver;
  71712. /**
  71713. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  71714. */
  71715. set onMaterialLoaded(callback: (material: Material) => void);
  71716. /**
  71717. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  71718. */
  71719. readonly onCameraLoadedObservable: Observable<Camera>;
  71720. private _onCameraLoadedObserver;
  71721. /**
  71722. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  71723. */
  71724. set onCameraLoaded(callback: (camera: Camera) => void);
  71725. /**
  71726. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  71727. * For assets with LODs, raised when all of the LODs are complete.
  71728. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71729. */
  71730. readonly onCompleteObservable: Observable<void>;
  71731. private _onCompleteObserver;
  71732. /**
  71733. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  71734. * For assets with LODs, raised when all of the LODs are complete.
  71735. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71736. */
  71737. set onComplete(callback: () => void);
  71738. /**
  71739. * Observable raised when an error occurs.
  71740. */
  71741. readonly onErrorObservable: Observable<any>;
  71742. private _onErrorObserver;
  71743. /**
  71744. * Callback raised when an error occurs.
  71745. */
  71746. set onError(callback: (reason: any) => void);
  71747. /**
  71748. * Observable raised after the loader is disposed.
  71749. */
  71750. readonly onDisposeObservable: Observable<void>;
  71751. private _onDisposeObserver;
  71752. /**
  71753. * Callback raised after the loader is disposed.
  71754. */
  71755. set onDispose(callback: () => void);
  71756. /**
  71757. * Observable raised after a loader extension is created.
  71758. * Set additional options for a loader extension in this event.
  71759. */
  71760. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  71761. private _onExtensionLoadedObserver;
  71762. /**
  71763. * Callback raised after a loader extension is created.
  71764. */
  71765. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  71766. /**
  71767. * Defines if the loader logging is enabled.
  71768. */
  71769. get loggingEnabled(): boolean;
  71770. set loggingEnabled(value: boolean);
  71771. /**
  71772. * Defines if the loader should capture performance counters.
  71773. */
  71774. get capturePerformanceCounters(): boolean;
  71775. set capturePerformanceCounters(value: boolean);
  71776. /**
  71777. * Defines if the loader should validate the asset.
  71778. */
  71779. validate: boolean;
  71780. /**
  71781. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  71782. */
  71783. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  71784. private _onValidatedObserver;
  71785. /**
  71786. * Callback raised after a loader extension is created.
  71787. */
  71788. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  71789. private _loader;
  71790. /**
  71791. * Name of the loader ("gltf")
  71792. */
  71793. name: string;
  71794. /** @hidden */
  71795. extensions: ISceneLoaderPluginExtensions;
  71796. /**
  71797. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  71798. */
  71799. dispose(): void;
  71800. /** @hidden */
  71801. _clear(): void;
  71802. /** @hidden */
  71803. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71804. /** @hidden */
  71805. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71806. /** @hidden */
  71807. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71808. meshes: AbstractMesh[];
  71809. particleSystems: IParticleSystem[];
  71810. skeletons: Skeleton[];
  71811. animationGroups: AnimationGroup[];
  71812. }>;
  71813. /** @hidden */
  71814. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71815. /** @hidden */
  71816. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71817. /** @hidden */
  71818. canDirectLoad(data: string): boolean;
  71819. /** @hidden */
  71820. directLoad(scene: Scene, data: string): any;
  71821. /**
  71822. * The callback that allows custom handling of the root url based on the response url.
  71823. * @param rootUrl the original root url
  71824. * @param responseURL the response url if available
  71825. * @returns the new root url
  71826. */
  71827. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  71828. /** @hidden */
  71829. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  71830. /**
  71831. * The loader state or null if the loader is not active.
  71832. */
  71833. get loaderState(): Nullable<GLTFLoaderState>;
  71834. /**
  71835. * Returns a promise that resolves when the asset is completely loaded.
  71836. * @returns a promise that resolves when the asset is completely loaded.
  71837. */
  71838. whenCompleteAsync(): Promise<void>;
  71839. private _validate;
  71840. private _getLoader;
  71841. private _parseJson;
  71842. private _unpackBinaryAsync;
  71843. private _unpackBinaryV1Async;
  71844. private _unpackBinaryV2Async;
  71845. private static _parseVersion;
  71846. private static _compareVersion;
  71847. private static readonly _logSpaces;
  71848. private _logIndentLevel;
  71849. private _loggingEnabled;
  71850. /** @hidden */
  71851. _log: (message: string) => void;
  71852. /** @hidden */
  71853. _logOpen(message: string): void;
  71854. /** @hidden */
  71855. _logClose(): void;
  71856. private _logEnabled;
  71857. private _logDisabled;
  71858. private _capturePerformanceCounters;
  71859. /** @hidden */
  71860. _startPerformanceCounter: (counterName: string) => void;
  71861. /** @hidden */
  71862. _endPerformanceCounter: (counterName: string) => void;
  71863. private _startPerformanceCounterEnabled;
  71864. private _startPerformanceCounterDisabled;
  71865. private _endPerformanceCounterEnabled;
  71866. private _endPerformanceCounterDisabled;
  71867. }
  71868. }
  71869. declare module BABYLON.GLTF1 {
  71870. /**
  71871. * Enums
  71872. * @hidden
  71873. */
  71874. export enum EComponentType {
  71875. BYTE = 5120,
  71876. UNSIGNED_BYTE = 5121,
  71877. SHORT = 5122,
  71878. UNSIGNED_SHORT = 5123,
  71879. FLOAT = 5126
  71880. }
  71881. /** @hidden */
  71882. export enum EShaderType {
  71883. FRAGMENT = 35632,
  71884. VERTEX = 35633
  71885. }
  71886. /** @hidden */
  71887. export enum EParameterType {
  71888. BYTE = 5120,
  71889. UNSIGNED_BYTE = 5121,
  71890. SHORT = 5122,
  71891. UNSIGNED_SHORT = 5123,
  71892. INT = 5124,
  71893. UNSIGNED_INT = 5125,
  71894. FLOAT = 5126,
  71895. FLOAT_VEC2 = 35664,
  71896. FLOAT_VEC3 = 35665,
  71897. FLOAT_VEC4 = 35666,
  71898. INT_VEC2 = 35667,
  71899. INT_VEC3 = 35668,
  71900. INT_VEC4 = 35669,
  71901. BOOL = 35670,
  71902. BOOL_VEC2 = 35671,
  71903. BOOL_VEC3 = 35672,
  71904. BOOL_VEC4 = 35673,
  71905. FLOAT_MAT2 = 35674,
  71906. FLOAT_MAT3 = 35675,
  71907. FLOAT_MAT4 = 35676,
  71908. SAMPLER_2D = 35678
  71909. }
  71910. /** @hidden */
  71911. export enum ETextureWrapMode {
  71912. CLAMP_TO_EDGE = 33071,
  71913. MIRRORED_REPEAT = 33648,
  71914. REPEAT = 10497
  71915. }
  71916. /** @hidden */
  71917. export enum ETextureFilterType {
  71918. NEAREST = 9728,
  71919. LINEAR = 9728,
  71920. NEAREST_MIPMAP_NEAREST = 9984,
  71921. LINEAR_MIPMAP_NEAREST = 9985,
  71922. NEAREST_MIPMAP_LINEAR = 9986,
  71923. LINEAR_MIPMAP_LINEAR = 9987
  71924. }
  71925. /** @hidden */
  71926. export enum ETextureFormat {
  71927. ALPHA = 6406,
  71928. RGB = 6407,
  71929. RGBA = 6408,
  71930. LUMINANCE = 6409,
  71931. LUMINANCE_ALPHA = 6410
  71932. }
  71933. /** @hidden */
  71934. export enum ECullingType {
  71935. FRONT = 1028,
  71936. BACK = 1029,
  71937. FRONT_AND_BACK = 1032
  71938. }
  71939. /** @hidden */
  71940. export enum EBlendingFunction {
  71941. ZERO = 0,
  71942. ONE = 1,
  71943. SRC_COLOR = 768,
  71944. ONE_MINUS_SRC_COLOR = 769,
  71945. DST_COLOR = 774,
  71946. ONE_MINUS_DST_COLOR = 775,
  71947. SRC_ALPHA = 770,
  71948. ONE_MINUS_SRC_ALPHA = 771,
  71949. DST_ALPHA = 772,
  71950. ONE_MINUS_DST_ALPHA = 773,
  71951. CONSTANT_COLOR = 32769,
  71952. ONE_MINUS_CONSTANT_COLOR = 32770,
  71953. CONSTANT_ALPHA = 32771,
  71954. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71955. SRC_ALPHA_SATURATE = 776
  71956. }
  71957. /** @hidden */
  71958. export interface IGLTFProperty {
  71959. extensions?: {
  71960. [key: string]: any;
  71961. };
  71962. extras?: Object;
  71963. }
  71964. /** @hidden */
  71965. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71966. name?: string;
  71967. }
  71968. /** @hidden */
  71969. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71970. bufferView: string;
  71971. byteOffset: number;
  71972. byteStride: number;
  71973. count: number;
  71974. type: string;
  71975. componentType: EComponentType;
  71976. max?: number[];
  71977. min?: number[];
  71978. name?: string;
  71979. }
  71980. /** @hidden */
  71981. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71982. buffer: string;
  71983. byteOffset: number;
  71984. byteLength: number;
  71985. byteStride: number;
  71986. target?: number;
  71987. }
  71988. /** @hidden */
  71989. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71990. uri: string;
  71991. byteLength?: number;
  71992. type?: string;
  71993. }
  71994. /** @hidden */
  71995. export interface IGLTFShader extends IGLTFChildRootProperty {
  71996. uri: string;
  71997. type: EShaderType;
  71998. }
  71999. /** @hidden */
  72000. export interface IGLTFProgram extends IGLTFChildRootProperty {
  72001. attributes: string[];
  72002. fragmentShader: string;
  72003. vertexShader: string;
  72004. }
  72005. /** @hidden */
  72006. export interface IGLTFTechniqueParameter {
  72007. type: number;
  72008. count?: number;
  72009. semantic?: string;
  72010. node?: string;
  72011. value?: number | boolean | string | Array<any>;
  72012. source?: string;
  72013. babylonValue?: any;
  72014. }
  72015. /** @hidden */
  72016. export interface IGLTFTechniqueCommonProfile {
  72017. lightingModel: string;
  72018. texcoordBindings: Object;
  72019. parameters?: Array<any>;
  72020. }
  72021. /** @hidden */
  72022. export interface IGLTFTechniqueStatesFunctions {
  72023. blendColor?: number[];
  72024. blendEquationSeparate?: number[];
  72025. blendFuncSeparate?: number[];
  72026. colorMask: boolean[];
  72027. cullFace: number[];
  72028. }
  72029. /** @hidden */
  72030. export interface IGLTFTechniqueStates {
  72031. enable: number[];
  72032. functions: IGLTFTechniqueStatesFunctions;
  72033. }
  72034. /** @hidden */
  72035. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  72036. parameters: {
  72037. [key: string]: IGLTFTechniqueParameter;
  72038. };
  72039. program: string;
  72040. attributes: {
  72041. [key: string]: string;
  72042. };
  72043. uniforms: {
  72044. [key: string]: string;
  72045. };
  72046. states: IGLTFTechniqueStates;
  72047. }
  72048. /** @hidden */
  72049. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  72050. technique?: string;
  72051. values: string[];
  72052. }
  72053. /** @hidden */
  72054. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  72055. attributes: {
  72056. [key: string]: string;
  72057. };
  72058. indices: string;
  72059. material: string;
  72060. mode?: number;
  72061. }
  72062. /** @hidden */
  72063. export interface IGLTFMesh extends IGLTFChildRootProperty {
  72064. primitives: IGLTFMeshPrimitive[];
  72065. }
  72066. /** @hidden */
  72067. export interface IGLTFImage extends IGLTFChildRootProperty {
  72068. uri: string;
  72069. }
  72070. /** @hidden */
  72071. export interface IGLTFSampler extends IGLTFChildRootProperty {
  72072. magFilter?: number;
  72073. minFilter?: number;
  72074. wrapS?: number;
  72075. wrapT?: number;
  72076. }
  72077. /** @hidden */
  72078. export interface IGLTFTexture extends IGLTFChildRootProperty {
  72079. sampler: string;
  72080. source: string;
  72081. format?: ETextureFormat;
  72082. internalFormat?: ETextureFormat;
  72083. target?: number;
  72084. type?: number;
  72085. babylonTexture?: Texture;
  72086. }
  72087. /** @hidden */
  72088. export interface IGLTFAmbienLight {
  72089. color?: number[];
  72090. }
  72091. /** @hidden */
  72092. export interface IGLTFDirectionalLight {
  72093. color?: number[];
  72094. }
  72095. /** @hidden */
  72096. export interface IGLTFPointLight {
  72097. color?: number[];
  72098. constantAttenuation?: number;
  72099. linearAttenuation?: number;
  72100. quadraticAttenuation?: number;
  72101. }
  72102. /** @hidden */
  72103. export interface IGLTFSpotLight {
  72104. color?: number[];
  72105. constantAttenuation?: number;
  72106. fallOfAngle?: number;
  72107. fallOffExponent?: number;
  72108. linearAttenuation?: number;
  72109. quadraticAttenuation?: number;
  72110. }
  72111. /** @hidden */
  72112. export interface IGLTFLight extends IGLTFChildRootProperty {
  72113. type: string;
  72114. }
  72115. /** @hidden */
  72116. export interface IGLTFCameraOrthographic {
  72117. xmag: number;
  72118. ymag: number;
  72119. zfar: number;
  72120. znear: number;
  72121. }
  72122. /** @hidden */
  72123. export interface IGLTFCameraPerspective {
  72124. aspectRatio: number;
  72125. yfov: number;
  72126. zfar: number;
  72127. znear: number;
  72128. }
  72129. /** @hidden */
  72130. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72131. type: string;
  72132. }
  72133. /** @hidden */
  72134. export interface IGLTFAnimationChannelTarget {
  72135. id: string;
  72136. path: string;
  72137. }
  72138. /** @hidden */
  72139. export interface IGLTFAnimationChannel {
  72140. sampler: string;
  72141. target: IGLTFAnimationChannelTarget;
  72142. }
  72143. /** @hidden */
  72144. export interface IGLTFAnimationSampler {
  72145. input: string;
  72146. output: string;
  72147. interpolation?: string;
  72148. }
  72149. /** @hidden */
  72150. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72151. channels?: IGLTFAnimationChannel[];
  72152. parameters?: {
  72153. [key: string]: string;
  72154. };
  72155. samplers?: {
  72156. [key: string]: IGLTFAnimationSampler;
  72157. };
  72158. }
  72159. /** @hidden */
  72160. export interface IGLTFNodeInstanceSkin {
  72161. skeletons: string[];
  72162. skin: string;
  72163. meshes: string[];
  72164. }
  72165. /** @hidden */
  72166. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72167. bindShapeMatrix: number[];
  72168. inverseBindMatrices: string;
  72169. jointNames: string[];
  72170. babylonSkeleton?: Skeleton;
  72171. }
  72172. /** @hidden */
  72173. export interface IGLTFNode extends IGLTFChildRootProperty {
  72174. camera?: string;
  72175. children: string[];
  72176. skin?: string;
  72177. jointName?: string;
  72178. light?: string;
  72179. matrix: number[];
  72180. mesh?: string;
  72181. meshes?: string[];
  72182. rotation?: number[];
  72183. scale?: number[];
  72184. translation?: number[];
  72185. babylonNode?: Node;
  72186. }
  72187. /** @hidden */
  72188. export interface IGLTFScene extends IGLTFChildRootProperty {
  72189. nodes: string[];
  72190. }
  72191. /** @hidden */
  72192. export interface IGLTFRuntime {
  72193. extensions: {
  72194. [key: string]: any;
  72195. };
  72196. accessors: {
  72197. [key: string]: IGLTFAccessor;
  72198. };
  72199. buffers: {
  72200. [key: string]: IGLTFBuffer;
  72201. };
  72202. bufferViews: {
  72203. [key: string]: IGLTFBufferView;
  72204. };
  72205. meshes: {
  72206. [key: string]: IGLTFMesh;
  72207. };
  72208. lights: {
  72209. [key: string]: IGLTFLight;
  72210. };
  72211. cameras: {
  72212. [key: string]: IGLTFCamera;
  72213. };
  72214. nodes: {
  72215. [key: string]: IGLTFNode;
  72216. };
  72217. images: {
  72218. [key: string]: IGLTFImage;
  72219. };
  72220. textures: {
  72221. [key: string]: IGLTFTexture;
  72222. };
  72223. shaders: {
  72224. [key: string]: IGLTFShader;
  72225. };
  72226. programs: {
  72227. [key: string]: IGLTFProgram;
  72228. };
  72229. samplers: {
  72230. [key: string]: IGLTFSampler;
  72231. };
  72232. techniques: {
  72233. [key: string]: IGLTFTechnique;
  72234. };
  72235. materials: {
  72236. [key: string]: IGLTFMaterial;
  72237. };
  72238. animations: {
  72239. [key: string]: IGLTFAnimation;
  72240. };
  72241. skins: {
  72242. [key: string]: IGLTFSkins;
  72243. };
  72244. currentScene?: Object;
  72245. scenes: {
  72246. [key: string]: IGLTFScene;
  72247. };
  72248. extensionsUsed: string[];
  72249. extensionsRequired?: string[];
  72250. buffersCount: number;
  72251. shaderscount: number;
  72252. scene: Scene;
  72253. rootUrl: string;
  72254. loadedBufferCount: number;
  72255. loadedBufferViews: {
  72256. [name: string]: ArrayBufferView;
  72257. };
  72258. loadedShaderCount: number;
  72259. importOnlyMeshes: boolean;
  72260. importMeshesNames?: string[];
  72261. dummyNodes: Node[];
  72262. }
  72263. /** @hidden */
  72264. export interface INodeToRoot {
  72265. bone: Bone;
  72266. node: IGLTFNode;
  72267. id: string;
  72268. }
  72269. /** @hidden */
  72270. export interface IJointNode {
  72271. node: IGLTFNode;
  72272. id: string;
  72273. }
  72274. }
  72275. declare module BABYLON.GLTF1 {
  72276. /**
  72277. * Utils functions for GLTF
  72278. * @hidden
  72279. */
  72280. export class GLTFUtils {
  72281. /**
  72282. * Sets the given "parameter" matrix
  72283. * @param scene: the Scene object
  72284. * @param source: the source node where to pick the matrix
  72285. * @param parameter: the GLTF technique parameter
  72286. * @param uniformName: the name of the shader's uniform
  72287. * @param shaderMaterial: the shader material
  72288. */
  72289. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72290. /**
  72291. * Sets the given "parameter" matrix
  72292. * @param shaderMaterial: the shader material
  72293. * @param uniform: the name of the shader's uniform
  72294. * @param value: the value of the uniform
  72295. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72296. */
  72297. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72298. /**
  72299. * Returns the wrap mode of the texture
  72300. * @param mode: the mode value
  72301. */
  72302. static GetWrapMode(mode: number): number;
  72303. /**
  72304. * Returns the byte stride giving an accessor
  72305. * @param accessor: the GLTF accessor objet
  72306. */
  72307. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72308. /**
  72309. * Returns the texture filter mode giving a mode value
  72310. * @param mode: the filter mode value
  72311. */
  72312. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72313. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72314. /**
  72315. * Returns a buffer from its accessor
  72316. * @param gltfRuntime: the GLTF runtime
  72317. * @param accessor: the GLTF accessor
  72318. */
  72319. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  72320. /**
  72321. * Decodes a buffer view into a string
  72322. * @param view: the buffer view
  72323. */
  72324. static DecodeBufferToText(view: ArrayBufferView): string;
  72325. /**
  72326. * Returns the default material of gltf. Related to
  72327. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  72328. * @param scene: the Babylon.js scene
  72329. */
  72330. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  72331. private static _DefaultMaterial;
  72332. }
  72333. }
  72334. declare module BABYLON.GLTF1 {
  72335. /**
  72336. * Implementation of the base glTF spec
  72337. * @hidden
  72338. */
  72339. export class GLTFLoaderBase {
  72340. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  72341. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72342. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  72343. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72344. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  72345. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72346. }
  72347. /**
  72348. * glTF V1 Loader
  72349. * @hidden
  72350. */
  72351. export class GLTFLoader implements IGLTFLoader {
  72352. static Extensions: {
  72353. [name: string]: GLTFLoaderExtension;
  72354. };
  72355. static RegisterExtension(extension: GLTFLoaderExtension): void;
  72356. state: Nullable<GLTFLoaderState>;
  72357. dispose(): void;
  72358. private _importMeshAsync;
  72359. /**
  72360. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  72361. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72362. * @param scene the scene the meshes should be added to
  72363. * @param data gltf data containing information of the meshes in a loaded file
  72364. * @param rootUrl root url to load from
  72365. * @param onProgress event that fires when loading progress has occured
  72366. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72367. */
  72368. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  72369. meshes: AbstractMesh[];
  72370. particleSystems: IParticleSystem[];
  72371. skeletons: Skeleton[];
  72372. animationGroups: AnimationGroup[];
  72373. }>;
  72374. private _loadAsync;
  72375. /**
  72376. * Imports all objects from a loaded gltf file and adds them to the scene
  72377. * @param scene the scene the objects should be added to
  72378. * @param data gltf data containing information of the meshes in a loaded file
  72379. * @param rootUrl root url to load from
  72380. * @param onProgress event that fires when loading progress has occured
  72381. * @returns a promise which completes when objects have been loaded to the scene
  72382. */
  72383. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  72384. private _loadShadersAsync;
  72385. private _loadBuffersAsync;
  72386. private _createNodes;
  72387. }
  72388. /** @hidden */
  72389. export abstract class GLTFLoaderExtension {
  72390. private _name;
  72391. constructor(name: string);
  72392. get name(): string;
  72393. /**
  72394. * Defines an override for loading the runtime
  72395. * Return true to stop further extensions from loading the runtime
  72396. */
  72397. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  72398. /**
  72399. * Defines an onverride for creating gltf runtime
  72400. * Return true to stop further extensions from creating the runtime
  72401. */
  72402. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  72403. /**
  72404. * Defines an override for loading buffers
  72405. * Return true to stop further extensions from loading this buffer
  72406. */
  72407. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  72408. /**
  72409. * Defines an override for loading texture buffers
  72410. * Return true to stop further extensions from loading this texture data
  72411. */
  72412. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72413. /**
  72414. * Defines an override for creating textures
  72415. * Return true to stop further extensions from loading this texture
  72416. */
  72417. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  72418. /**
  72419. * Defines an override for loading shader strings
  72420. * Return true to stop further extensions from loading this shader data
  72421. */
  72422. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72423. /**
  72424. * Defines an override for loading materials
  72425. * Return true to stop further extensions from loading this material
  72426. */
  72427. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72428. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  72429. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  72430. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72431. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72432. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  72433. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72434. private static LoadTextureBufferAsync;
  72435. private static CreateTextureAsync;
  72436. private static ApplyExtensions;
  72437. }
  72438. }
  72439. declare module BABYLON.GLTF1 {
  72440. /** @hidden */
  72441. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  72442. private _bin;
  72443. constructor();
  72444. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  72445. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72446. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72447. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72448. }
  72449. }
  72450. declare module BABYLON.GLTF1 {
  72451. /** @hidden */
  72452. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  72453. constructor();
  72454. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  72455. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72456. private _loadTexture;
  72457. }
  72458. }
  72459. declare module BABYLON.GLTF2.Loader {
  72460. /**
  72461. * Loader interface with an index field.
  72462. */
  72463. export interface IArrayItem {
  72464. /**
  72465. * The index of this item in the array.
  72466. */
  72467. index: number;
  72468. }
  72469. /**
  72470. * Loader interface with additional members.
  72471. */
  72472. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  72473. /** @hidden */
  72474. _data?: Promise<ArrayBufferView>;
  72475. /** @hidden */
  72476. _babylonVertexBuffer?: Promise<VertexBuffer>;
  72477. }
  72478. /**
  72479. * Loader interface with additional members.
  72480. */
  72481. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  72482. }
  72483. /** @hidden */
  72484. export interface _IAnimationSamplerData {
  72485. input: Float32Array;
  72486. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  72487. output: Float32Array;
  72488. }
  72489. /**
  72490. * Loader interface with additional members.
  72491. */
  72492. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  72493. /** @hidden */
  72494. _data?: Promise<_IAnimationSamplerData>;
  72495. }
  72496. /**
  72497. * Loader interface with additional members.
  72498. */
  72499. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  72500. channels: IAnimationChannel[];
  72501. samplers: IAnimationSampler[];
  72502. /** @hidden */
  72503. _babylonAnimationGroup?: AnimationGroup;
  72504. }
  72505. /**
  72506. * Loader interface with additional members.
  72507. */
  72508. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  72509. /** @hidden */
  72510. _data?: Promise<ArrayBufferView>;
  72511. }
  72512. /**
  72513. * Loader interface with additional members.
  72514. */
  72515. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  72516. /** @hidden */
  72517. _data?: Promise<ArrayBufferView>;
  72518. /** @hidden */
  72519. _babylonBuffer?: Promise<Buffer>;
  72520. }
  72521. /**
  72522. * Loader interface with additional members.
  72523. */
  72524. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  72525. }
  72526. /**
  72527. * Loader interface with additional members.
  72528. */
  72529. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  72530. /** @hidden */
  72531. _data?: Promise<ArrayBufferView>;
  72532. }
  72533. /**
  72534. * Loader interface with additional members.
  72535. */
  72536. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  72537. }
  72538. /**
  72539. * Loader interface with additional members.
  72540. */
  72541. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  72542. }
  72543. /**
  72544. * Loader interface with additional members.
  72545. */
  72546. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  72547. baseColorTexture?: ITextureInfo;
  72548. metallicRoughnessTexture?: ITextureInfo;
  72549. }
  72550. /**
  72551. * Loader interface with additional members.
  72552. */
  72553. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  72554. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72555. normalTexture?: IMaterialNormalTextureInfo;
  72556. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72557. emissiveTexture?: ITextureInfo;
  72558. /** @hidden */
  72559. _data?: {
  72560. [babylonDrawMode: number]: {
  72561. babylonMaterial: Material;
  72562. babylonMeshes: AbstractMesh[];
  72563. promise: Promise<void>;
  72564. };
  72565. };
  72566. }
  72567. /**
  72568. * Loader interface with additional members.
  72569. */
  72570. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  72571. primitives: IMeshPrimitive[];
  72572. }
  72573. /**
  72574. * Loader interface with additional members.
  72575. */
  72576. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  72577. /** @hidden */
  72578. _instanceData?: {
  72579. babylonSourceMesh: Mesh;
  72580. promise: Promise<any>;
  72581. };
  72582. }
  72583. /**
  72584. * Loader interface with additional members.
  72585. */
  72586. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  72587. /**
  72588. * The parent glTF node.
  72589. */
  72590. parent?: INode;
  72591. /** @hidden */
  72592. _babylonTransformNode?: TransformNode;
  72593. /** @hidden */
  72594. _primitiveBabylonMeshes?: AbstractMesh[];
  72595. /** @hidden */
  72596. _babylonBones?: Bone[];
  72597. /** @hidden */
  72598. _numMorphTargets?: number;
  72599. }
  72600. /** @hidden */
  72601. export interface _ISamplerData {
  72602. noMipMaps: boolean;
  72603. samplingMode: number;
  72604. wrapU: number;
  72605. wrapV: number;
  72606. }
  72607. /**
  72608. * Loader interface with additional members.
  72609. */
  72610. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  72611. /** @hidden */
  72612. _data?: _ISamplerData;
  72613. }
  72614. /**
  72615. * Loader interface with additional members.
  72616. */
  72617. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  72618. }
  72619. /**
  72620. * Loader interface with additional members.
  72621. */
  72622. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  72623. /** @hidden */
  72624. _data?: {
  72625. babylonSkeleton: Skeleton;
  72626. promise: Promise<void>;
  72627. };
  72628. }
  72629. /**
  72630. * Loader interface with additional members.
  72631. */
  72632. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  72633. }
  72634. /**
  72635. * Loader interface with additional members.
  72636. */
  72637. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  72638. }
  72639. /**
  72640. * Loader interface with additional members.
  72641. */
  72642. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  72643. accessors?: IAccessor[];
  72644. animations?: IAnimation[];
  72645. buffers?: IBuffer[];
  72646. bufferViews?: IBufferView[];
  72647. cameras?: ICamera[];
  72648. images?: IImage[];
  72649. materials?: IMaterial[];
  72650. meshes?: IMesh[];
  72651. nodes?: INode[];
  72652. samplers?: ISampler[];
  72653. scenes?: IScene[];
  72654. skins?: ISkin[];
  72655. textures?: ITexture[];
  72656. }
  72657. }
  72658. declare module BABYLON.GLTF2 {
  72659. /**
  72660. * Interface for a glTF loader extension.
  72661. */
  72662. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  72663. /**
  72664. * Called after the loader state changes to LOADING.
  72665. */
  72666. onLoading?(): void;
  72667. /**
  72668. * Called after the loader state changes to READY.
  72669. */
  72670. onReady?(): void;
  72671. /**
  72672. * Define this method to modify the default behavior when loading scenes.
  72673. * @param context The context when loading the asset
  72674. * @param scene The glTF scene property
  72675. * @returns A promise that resolves when the load is complete or null if not handled
  72676. */
  72677. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  72678. /**
  72679. * Define this method to modify the default behavior when loading nodes.
  72680. * @param context The context when loading the asset
  72681. * @param node The glTF node property
  72682. * @param assign A function called synchronously after parsing the glTF properties
  72683. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  72684. */
  72685. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72686. /**
  72687. * Define this method to modify the default behavior when loading cameras.
  72688. * @param context The context when loading the asset
  72689. * @param camera The glTF camera property
  72690. * @param assign A function called synchronously after parsing the glTF properties
  72691. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  72692. */
  72693. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72694. /**
  72695. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  72696. * @param context The context when loading the asset
  72697. * @param primitive The glTF mesh primitive property
  72698. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  72699. */
  72700. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72701. /**
  72702. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72703. * @param context The context when loading the asset
  72704. * @param name The mesh name when loading the asset
  72705. * @param node The glTF node when loading the asset
  72706. * @param mesh The glTF mesh when loading the asset
  72707. * @param primitive The glTF mesh primitive property
  72708. * @param assign A function called synchronously after parsing the glTF properties
  72709. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72710. */
  72711. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72712. /**
  72713. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  72714. * @param context The context when loading the asset
  72715. * @param material The glTF material property
  72716. * @param assign A function called synchronously after parsing the glTF properties
  72717. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  72718. */
  72719. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72720. /**
  72721. * Define this method to modify the default behavior when creating materials.
  72722. * @param context The context when loading the asset
  72723. * @param material The glTF material property
  72724. * @param babylonDrawMode The draw mode for the Babylon material
  72725. * @returns The Babylon material or null if not handled
  72726. */
  72727. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72728. /**
  72729. * Define this method to modify the default behavior when loading material properties.
  72730. * @param context The context when loading the asset
  72731. * @param material The glTF material property
  72732. * @param babylonMaterial The Babylon material
  72733. * @returns A promise that resolves when the load is complete or null if not handled
  72734. */
  72735. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72736. /**
  72737. * Define this method to modify the default behavior when loading texture infos.
  72738. * @param context The context when loading the asset
  72739. * @param textureInfo The glTF texture info property
  72740. * @param assign A function called synchronously after parsing the glTF properties
  72741. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  72742. */
  72743. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72744. /**
  72745. * Define this method to modify the default behavior when loading animations.
  72746. * @param context The context when loading the asset
  72747. * @param animation The glTF animation property
  72748. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  72749. */
  72750. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72751. /**
  72752. * @hidden Define this method to modify the default behavior when loading skins.
  72753. * @param context The context when loading the asset
  72754. * @param node The glTF node property
  72755. * @param skin The glTF skin property
  72756. * @returns A promise that resolves when the load is complete or null if not handled
  72757. */
  72758. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  72759. /**
  72760. * @hidden Define this method to modify the default behavior when loading uris.
  72761. * @param context The context when loading the asset
  72762. * @param property The glTF property associated with the uri
  72763. * @param uri The uri to load
  72764. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72765. */
  72766. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72767. /**
  72768. * Define this method to modify the default behavior when loading buffer views.
  72769. * @param context The context when loading the asset
  72770. * @param bufferView The glTF buffer view property
  72771. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72772. */
  72773. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  72774. /**
  72775. * Define this method to modify the default behavior when loading buffers.
  72776. * @param context The context when loading the asset
  72777. * @param buffer The glTF buffer property
  72778. * @param byteOffset The byte offset to load
  72779. * @param byteLength The byte length to load
  72780. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72781. */
  72782. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72783. }
  72784. }
  72785. declare module BABYLON.GLTF2 {
  72786. /**
  72787. * Helper class for working with arrays when loading the glTF asset
  72788. */
  72789. export class ArrayItem {
  72790. /**
  72791. * Gets an item from the given array.
  72792. * @param context The context when loading the asset
  72793. * @param array The array to get the item from
  72794. * @param index The index to the array
  72795. * @returns The array item
  72796. */
  72797. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  72798. /**
  72799. * Assign an `index` field to each item of the given array.
  72800. * @param array The array of items
  72801. */
  72802. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  72803. }
  72804. /**
  72805. * The glTF 2.0 loader
  72806. */
  72807. export class GLTFLoader implements IGLTFLoader {
  72808. /** @hidden */
  72809. _completePromises: Promise<any>[];
  72810. private _disposed;
  72811. private _parent;
  72812. private _state;
  72813. private _extensions;
  72814. private _rootUrl;
  72815. private _fileName;
  72816. private _uniqueRootUrl;
  72817. private _gltf;
  72818. private _bin;
  72819. private _babylonScene;
  72820. private _rootBabylonMesh;
  72821. private _defaultBabylonMaterialData;
  72822. private _progressCallback?;
  72823. private _requests;
  72824. private static readonly _DefaultSampler;
  72825. private static _RegisteredExtensions;
  72826. /**
  72827. * Registers a loader extension.
  72828. * @param name The name of the loader extension.
  72829. * @param factory The factory function that creates the loader extension.
  72830. */
  72831. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  72832. /**
  72833. * Unregisters a loader extension.
  72834. * @param name The name of the loader extension.
  72835. * @returns A boolean indicating whether the extension has been unregistered
  72836. */
  72837. static UnregisterExtension(name: string): boolean;
  72838. /**
  72839. * Gets the loader state.
  72840. */
  72841. get state(): Nullable<GLTFLoaderState>;
  72842. /**
  72843. * The object that represents the glTF JSON.
  72844. */
  72845. get gltf(): IGLTF;
  72846. /**
  72847. * The BIN chunk of a binary glTF.
  72848. */
  72849. get bin(): Nullable<IDataBuffer>;
  72850. /**
  72851. * The parent file loader.
  72852. */
  72853. get parent(): GLTFFileLoader;
  72854. /**
  72855. * The Babylon scene when loading the asset.
  72856. */
  72857. get babylonScene(): Scene;
  72858. /**
  72859. * The root Babylon mesh when loading the asset.
  72860. */
  72861. get rootBabylonMesh(): Mesh;
  72862. /** @hidden */
  72863. constructor(parent: GLTFFileLoader);
  72864. /** @hidden */
  72865. dispose(): void;
  72866. /** @hidden */
  72867. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72868. meshes: AbstractMesh[];
  72869. particleSystems: IParticleSystem[];
  72870. skeletons: Skeleton[];
  72871. animationGroups: AnimationGroup[];
  72872. }>;
  72873. /** @hidden */
  72874. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72875. private _loadAsync;
  72876. private _loadData;
  72877. private _setupData;
  72878. private _loadExtensions;
  72879. private _checkExtensions;
  72880. private _setState;
  72881. private _createRootNode;
  72882. /**
  72883. * Loads a glTF scene.
  72884. * @param context The context when loading the asset
  72885. * @param scene The glTF scene property
  72886. * @returns A promise that resolves when the load is complete
  72887. */
  72888. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  72889. private _forEachPrimitive;
  72890. private _getMeshes;
  72891. private _getSkeletons;
  72892. private _getAnimationGroups;
  72893. private _startAnimations;
  72894. /**
  72895. * Loads a glTF node.
  72896. * @param context The context when loading the asset
  72897. * @param node The glTF node property
  72898. * @param assign A function called synchronously after parsing the glTF properties
  72899. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  72900. */
  72901. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  72902. private _loadMeshAsync;
  72903. /**
  72904. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72905. * @param context The context when loading the asset
  72906. * @param name The mesh name when loading the asset
  72907. * @param node The glTF node when loading the asset
  72908. * @param mesh The glTF mesh when loading the asset
  72909. * @param primitive The glTF mesh primitive property
  72910. * @param assign A function called synchronously after parsing the glTF properties
  72911. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72912. */
  72913. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72914. private _loadVertexDataAsync;
  72915. private _createMorphTargets;
  72916. private _loadMorphTargetsAsync;
  72917. private _loadMorphTargetVertexDataAsync;
  72918. private static _LoadTransform;
  72919. private _loadSkinAsync;
  72920. private _loadBones;
  72921. private _loadBone;
  72922. private _loadSkinInverseBindMatricesDataAsync;
  72923. private _updateBoneMatrices;
  72924. private _getNodeMatrix;
  72925. /**
  72926. * Loads a glTF camera.
  72927. * @param context The context when loading the asset
  72928. * @param camera The glTF camera property
  72929. * @param assign A function called synchronously after parsing the glTF properties
  72930. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  72931. */
  72932. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  72933. private _loadAnimationsAsync;
  72934. /**
  72935. * Loads a glTF animation.
  72936. * @param context The context when loading the asset
  72937. * @param animation The glTF animation property
  72938. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  72939. */
  72940. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72941. /**
  72942. * @hidden Loads a glTF animation channel.
  72943. * @param context The context when loading the asset
  72944. * @param animationContext The context of the animation when loading the asset
  72945. * @param animation The glTF animation property
  72946. * @param channel The glTF animation channel property
  72947. * @param babylonAnimationGroup The babylon animation group property
  72948. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72949. * @returns A void promise when the channel load is complete
  72950. */
  72951. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72952. private _loadAnimationSamplerAsync;
  72953. private _loadBufferAsync;
  72954. /**
  72955. * Loads a glTF buffer view.
  72956. * @param context The context when loading the asset
  72957. * @param bufferView The glTF buffer view property
  72958. * @returns A promise that resolves with the loaded data when the load is complete
  72959. */
  72960. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72961. private _loadAccessorAsync;
  72962. private _loadFloatAccessorAsync;
  72963. private _loadIndicesAccessorAsync;
  72964. private _loadVertexBufferViewAsync;
  72965. private _loadVertexAccessorAsync;
  72966. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72967. /** @hidden */
  72968. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72969. private _createDefaultMaterial;
  72970. /**
  72971. * Creates a Babylon material from a glTF material.
  72972. * @param context The context when loading the asset
  72973. * @param material The glTF material property
  72974. * @param babylonDrawMode The draw mode for the Babylon material
  72975. * @returns The Babylon material
  72976. */
  72977. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72978. /**
  72979. * Loads properties from a glTF material into a Babylon material.
  72980. * @param context The context when loading the asset
  72981. * @param material The glTF material property
  72982. * @param babylonMaterial The Babylon material
  72983. * @returns A promise that resolves when the load is complete
  72984. */
  72985. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72986. /**
  72987. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72988. * @param context The context when loading the asset
  72989. * @param material The glTF material property
  72990. * @param babylonMaterial The Babylon material
  72991. * @returns A promise that resolves when the load is complete
  72992. */
  72993. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72994. /**
  72995. * Loads the alpha properties from a glTF material into a Babylon material.
  72996. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72997. * @param context The context when loading the asset
  72998. * @param material The glTF material property
  72999. * @param babylonMaterial The Babylon material
  73000. */
  73001. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  73002. /**
  73003. * Loads a glTF texture info.
  73004. * @param context The context when loading the asset
  73005. * @param textureInfo The glTF texture info property
  73006. * @param assign A function called synchronously after parsing the glTF properties
  73007. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  73008. */
  73009. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  73010. private _loadTextureAsync;
  73011. private _loadSampler;
  73012. /**
  73013. * Loads a glTF image.
  73014. * @param context The context when loading the asset
  73015. * @param image The glTF image property
  73016. * @returns A promise that resolves with the loaded data when the load is complete
  73017. */
  73018. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  73019. /**
  73020. * Loads a glTF uri.
  73021. * @param context The context when loading the asset
  73022. * @param property The glTF property associated with the uri
  73023. * @param uri The base64 or relative uri
  73024. * @returns A promise that resolves with the loaded data when the load is complete
  73025. */
  73026. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  73027. private _onProgress;
  73028. /**
  73029. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  73030. * @param babylonObject the Babylon object with metadata
  73031. * @param pointer the JSON pointer
  73032. */
  73033. static AddPointerMetadata(babylonObject: {
  73034. metadata: any;
  73035. }, pointer: string): void;
  73036. private static _GetTextureWrapMode;
  73037. private static _GetTextureSamplingMode;
  73038. private static _GetTypedArrayConstructor;
  73039. private static _GetTypedArray;
  73040. private static _GetNumComponents;
  73041. private static _ValidateUri;
  73042. private static _GetDrawMode;
  73043. private _compileMaterialsAsync;
  73044. private _compileShadowGeneratorsAsync;
  73045. private _forEachExtensions;
  73046. private _applyExtensions;
  73047. private _extensionsOnLoading;
  73048. private _extensionsOnReady;
  73049. private _extensionsLoadSceneAsync;
  73050. private _extensionsLoadNodeAsync;
  73051. private _extensionsLoadCameraAsync;
  73052. private _extensionsLoadVertexDataAsync;
  73053. private _extensionsLoadMeshPrimitiveAsync;
  73054. private _extensionsLoadMaterialAsync;
  73055. private _extensionsCreateMaterial;
  73056. private _extensionsLoadMaterialPropertiesAsync;
  73057. private _extensionsLoadTextureInfoAsync;
  73058. private _extensionsLoadAnimationAsync;
  73059. private _extensionsLoadSkinAsync;
  73060. private _extensionsLoadUriAsync;
  73061. private _extensionsLoadBufferViewAsync;
  73062. private _extensionsLoadBufferAsync;
  73063. /**
  73064. * Helper method called by a loader extension to load an glTF extension.
  73065. * @param context The context when loading the asset
  73066. * @param property The glTF property to load the extension from
  73067. * @param extensionName The name of the extension to load
  73068. * @param actionAsync The action to run
  73069. * @returns The promise returned by actionAsync or null if the extension does not exist
  73070. */
  73071. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73072. /**
  73073. * Helper method called by a loader extension to load a glTF extra.
  73074. * @param context The context when loading the asset
  73075. * @param property The glTF property to load the extra from
  73076. * @param extensionName The name of the extension to load
  73077. * @param actionAsync The action to run
  73078. * @returns The promise returned by actionAsync or null if the extra does not exist
  73079. */
  73080. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73081. /**
  73082. * Checks for presence of an extension.
  73083. * @param name The name of the extension to check
  73084. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  73085. */
  73086. isExtensionUsed(name: string): boolean;
  73087. /**
  73088. * Increments the indentation level and logs a message.
  73089. * @param message The message to log
  73090. */
  73091. logOpen(message: string): void;
  73092. /**
  73093. * Decrements the indentation level.
  73094. */
  73095. logClose(): void;
  73096. /**
  73097. * Logs a message
  73098. * @param message The message to log
  73099. */
  73100. log(message: string): void;
  73101. /**
  73102. * Starts a performance counter.
  73103. * @param counterName The name of the performance counter
  73104. */
  73105. startPerformanceCounter(counterName: string): void;
  73106. /**
  73107. * Ends a performance counter.
  73108. * @param counterName The name of the performance counter
  73109. */
  73110. endPerformanceCounter(counterName: string): void;
  73111. }
  73112. }
  73113. declare module BABYLON.GLTF2.Loader.Extensions {
  73114. /**
  73115. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  73116. */
  73117. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  73118. /**
  73119. * The name of this extension.
  73120. */
  73121. readonly name: string;
  73122. /**
  73123. * Defines whether this extension is enabled.
  73124. */
  73125. enabled: boolean;
  73126. private _loader;
  73127. private _lights?;
  73128. /** @hidden */
  73129. constructor(loader: GLTFLoader);
  73130. /** @hidden */
  73131. dispose(): void;
  73132. /** @hidden */
  73133. onLoading(): void;
  73134. /** @hidden */
  73135. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73136. private _loadLightAsync;
  73137. }
  73138. }
  73139. declare module BABYLON.GLTF2.Loader.Extensions {
  73140. /**
  73141. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73142. */
  73143. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73144. /**
  73145. * The name of this extension.
  73146. */
  73147. readonly name: string;
  73148. /**
  73149. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73150. */
  73151. dracoCompression?: DracoCompression;
  73152. /**
  73153. * Defines whether this extension is enabled.
  73154. */
  73155. enabled: boolean;
  73156. private _loader;
  73157. /** @hidden */
  73158. constructor(loader: GLTFLoader);
  73159. /** @hidden */
  73160. dispose(): void;
  73161. /** @hidden */
  73162. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73163. }
  73164. }
  73165. declare module BABYLON.GLTF2.Loader.Extensions {
  73166. /**
  73167. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73168. */
  73169. export class KHR_lights implements IGLTFLoaderExtension {
  73170. /**
  73171. * The name of this extension.
  73172. */
  73173. readonly name: string;
  73174. /**
  73175. * Defines whether this extension is enabled.
  73176. */
  73177. enabled: boolean;
  73178. private _loader;
  73179. private _lights?;
  73180. /** @hidden */
  73181. constructor(loader: GLTFLoader);
  73182. /** @hidden */
  73183. dispose(): void;
  73184. /** @hidden */
  73185. onLoading(): void;
  73186. /** @hidden */
  73187. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73188. }
  73189. }
  73190. declare module BABYLON.GLTF2.Loader.Extensions {
  73191. /**
  73192. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73193. */
  73194. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73195. /**
  73196. * The name of this extension.
  73197. */
  73198. readonly name: string;
  73199. /**
  73200. * Defines whether this extension is enabled.
  73201. */
  73202. enabled: boolean;
  73203. /**
  73204. * Defines a number that determines the order the extensions are applied.
  73205. */
  73206. order: number;
  73207. private _loader;
  73208. /** @hidden */
  73209. constructor(loader: GLTFLoader);
  73210. /** @hidden */
  73211. dispose(): void;
  73212. /** @hidden */
  73213. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73214. private _loadSpecularGlossinessPropertiesAsync;
  73215. }
  73216. }
  73217. declare module BABYLON.GLTF2.Loader.Extensions {
  73218. /**
  73219. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73220. */
  73221. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73222. /**
  73223. * The name of this extension.
  73224. */
  73225. readonly name: string;
  73226. /**
  73227. * Defines whether this extension is enabled.
  73228. */
  73229. enabled: boolean;
  73230. /**
  73231. * Defines a number that determines the order the extensions are applied.
  73232. */
  73233. order: number;
  73234. private _loader;
  73235. /** @hidden */
  73236. constructor(loader: GLTFLoader);
  73237. /** @hidden */
  73238. dispose(): void;
  73239. /** @hidden */
  73240. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73241. private _loadUnlitPropertiesAsync;
  73242. }
  73243. }
  73244. declare module BABYLON.GLTF2.Loader.Extensions {
  73245. /**
  73246. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73247. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73248. * !!! Experimental Extension Subject to Changes !!!
  73249. */
  73250. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73251. /**
  73252. * The name of this extension.
  73253. */
  73254. readonly name: string;
  73255. /**
  73256. * Defines whether this extension is enabled.
  73257. */
  73258. enabled: boolean;
  73259. /**
  73260. * Defines a number that determines the order the extensions are applied.
  73261. */
  73262. order: number;
  73263. private _loader;
  73264. /** @hidden */
  73265. constructor(loader: GLTFLoader);
  73266. /** @hidden */
  73267. dispose(): void;
  73268. /** @hidden */
  73269. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73270. private _loadClearCoatPropertiesAsync;
  73271. }
  73272. }
  73273. declare module BABYLON.GLTF2.Loader.Extensions {
  73274. /**
  73275. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73276. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73277. * !!! Experimental Extension Subject to Changes !!!
  73278. */
  73279. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73280. /**
  73281. * The name of this extension.
  73282. */
  73283. readonly name: string;
  73284. /**
  73285. * Defines whether this extension is enabled.
  73286. */
  73287. enabled: boolean;
  73288. /**
  73289. * Defines a number that determines the order the extensions are applied.
  73290. */
  73291. order: number;
  73292. private _loader;
  73293. /** @hidden */
  73294. constructor(loader: GLTFLoader);
  73295. /** @hidden */
  73296. dispose(): void;
  73297. /** @hidden */
  73298. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73299. private _loadSheenPropertiesAsync;
  73300. }
  73301. }
  73302. declare module BABYLON.GLTF2.Loader.Extensions {
  73303. /**
  73304. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73305. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73306. * !!! Experimental Extension Subject to Changes !!!
  73307. */
  73308. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73309. /**
  73310. * The name of this extension.
  73311. */
  73312. readonly name: string;
  73313. /**
  73314. * Defines whether this extension is enabled.
  73315. */
  73316. enabled: boolean;
  73317. /**
  73318. * Defines a number that determines the order the extensions are applied.
  73319. */
  73320. order: number;
  73321. private _loader;
  73322. /** @hidden */
  73323. constructor(loader: GLTFLoader);
  73324. /** @hidden */
  73325. dispose(): void;
  73326. /** @hidden */
  73327. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73328. private _loadSpecularPropertiesAsync;
  73329. }
  73330. }
  73331. declare module BABYLON.GLTF2.Loader.Extensions {
  73332. /**
  73333. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  73334. */
  73335. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  73336. /**
  73337. * The name of this extension.
  73338. */
  73339. readonly name: string;
  73340. /**
  73341. * Defines whether this extension is enabled.
  73342. */
  73343. enabled: boolean;
  73344. /** @hidden */
  73345. constructor(loader: GLTFLoader);
  73346. /** @hidden */
  73347. dispose(): void;
  73348. }
  73349. }
  73350. declare module BABYLON.GLTF2.Loader.Extensions {
  73351. /**
  73352. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  73353. */
  73354. export class KHR_texture_transform implements IGLTFLoaderExtension {
  73355. /**
  73356. * The name of this extension.
  73357. */
  73358. readonly name: string;
  73359. /**
  73360. * Defines whether this extension is enabled.
  73361. */
  73362. enabled: boolean;
  73363. private _loader;
  73364. /** @hidden */
  73365. constructor(loader: GLTFLoader);
  73366. /** @hidden */
  73367. dispose(): void;
  73368. /** @hidden */
  73369. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73370. }
  73371. }
  73372. declare module BABYLON.GLTF2.Loader.Extensions {
  73373. /**
  73374. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  73375. */
  73376. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  73377. /**
  73378. * The name of this extension.
  73379. */
  73380. readonly name: string;
  73381. /**
  73382. * Defines whether this extension is enabled.
  73383. */
  73384. enabled: boolean;
  73385. private _loader;
  73386. private _clips;
  73387. private _emitters;
  73388. /** @hidden */
  73389. constructor(loader: GLTFLoader);
  73390. /** @hidden */
  73391. dispose(): void;
  73392. /** @hidden */
  73393. onLoading(): void;
  73394. /** @hidden */
  73395. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73396. /** @hidden */
  73397. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73398. /** @hidden */
  73399. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73400. private _loadClipAsync;
  73401. private _loadEmitterAsync;
  73402. private _getEventAction;
  73403. private _loadAnimationEventAsync;
  73404. }
  73405. }
  73406. declare module BABYLON.GLTF2.Loader.Extensions {
  73407. /**
  73408. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  73409. */
  73410. export class MSFT_lod implements IGLTFLoaderExtension {
  73411. /**
  73412. * The name of this extension.
  73413. */
  73414. readonly name: string;
  73415. /**
  73416. * Defines whether this extension is enabled.
  73417. */
  73418. enabled: boolean;
  73419. /**
  73420. * Defines a number that determines the order the extensions are applied.
  73421. */
  73422. order: number;
  73423. /**
  73424. * Maximum number of LODs to load, starting from the lowest LOD.
  73425. */
  73426. maxLODsToLoad: number;
  73427. /**
  73428. * Observable raised when all node LODs of one level are loaded.
  73429. * The event data is the index of the loaded LOD starting from zero.
  73430. * Dispose the loader to cancel the loading of the next level of LODs.
  73431. */
  73432. onNodeLODsLoadedObservable: Observable<number>;
  73433. /**
  73434. * Observable raised when all material LODs of one level are loaded.
  73435. * The event data is the index of the loaded LOD starting from zero.
  73436. * Dispose the loader to cancel the loading of the next level of LODs.
  73437. */
  73438. onMaterialLODsLoadedObservable: Observable<number>;
  73439. private _loader;
  73440. private _nodeIndexLOD;
  73441. private _nodeSignalLODs;
  73442. private _nodePromiseLODs;
  73443. private _materialIndexLOD;
  73444. private _materialSignalLODs;
  73445. private _materialPromiseLODs;
  73446. private _indexLOD;
  73447. private _bufferLODs;
  73448. /** @hidden */
  73449. constructor(loader: GLTFLoader);
  73450. /** @hidden */
  73451. dispose(): void;
  73452. /** @hidden */
  73453. onReady(): void;
  73454. /** @hidden */
  73455. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73456. /** @hidden */
  73457. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73458. /** @hidden */
  73459. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73460. /** @hidden */
  73461. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73462. private _loadBufferLOD;
  73463. /**
  73464. * Gets an array of LOD properties from lowest to highest.
  73465. */
  73466. private _getLODs;
  73467. private _disposeUnusedMaterials;
  73468. }
  73469. }
  73470. declare module BABYLON.GLTF2.Loader.Extensions {
  73471. /** @hidden */
  73472. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  73473. readonly name: string;
  73474. enabled: boolean;
  73475. private _loader;
  73476. constructor(loader: GLTFLoader);
  73477. dispose(): void;
  73478. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73479. }
  73480. }
  73481. declare module BABYLON.GLTF2.Loader.Extensions {
  73482. /** @hidden */
  73483. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  73484. readonly name: string;
  73485. enabled: boolean;
  73486. private _loader;
  73487. constructor(loader: GLTFLoader);
  73488. dispose(): void;
  73489. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73490. }
  73491. }
  73492. declare module BABYLON.GLTF2.Loader.Extensions {
  73493. /**
  73494. * Store glTF extras (if present) in BJS objects' metadata
  73495. */
  73496. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  73497. /**
  73498. * The name of this extension.
  73499. */
  73500. readonly name: string;
  73501. /**
  73502. * Defines whether this extension is enabled.
  73503. */
  73504. enabled: boolean;
  73505. private _loader;
  73506. private _assignExtras;
  73507. /** @hidden */
  73508. constructor(loader: GLTFLoader);
  73509. /** @hidden */
  73510. dispose(): void;
  73511. /** @hidden */
  73512. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73513. /** @hidden */
  73514. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73515. /** @hidden */
  73516. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73517. }
  73518. }
  73519. declare module BABYLON {
  73520. /**
  73521. * Class reading and parsing the MTL file bundled with the obj file.
  73522. */
  73523. export class MTLFileLoader {
  73524. /**
  73525. * All material loaded from the mtl will be set here
  73526. */
  73527. materials: StandardMaterial[];
  73528. /**
  73529. * This function will read the mtl file and create each material described inside
  73530. * This function could be improve by adding :
  73531. * -some component missing (Ni, Tf...)
  73532. * -including the specific options available
  73533. *
  73534. * @param scene defines the scene the material will be created in
  73535. * @param data defines the mtl data to parse
  73536. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  73537. */
  73538. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  73539. /**
  73540. * Gets the texture for the material.
  73541. *
  73542. * If the material is imported from input file,
  73543. * We sanitize the url to ensure it takes the textre from aside the material.
  73544. *
  73545. * @param rootUrl The root url to load from
  73546. * @param value The value stored in the mtl
  73547. * @return The Texture
  73548. */
  73549. private static _getTexture;
  73550. }
  73551. /**
  73552. * Options for loading OBJ/MTL files
  73553. */
  73554. type MeshLoadOptions = {
  73555. /**
  73556. * Defines if UVs are optimized by default during load.
  73557. */
  73558. OptimizeWithUV: boolean;
  73559. /**
  73560. * Defines custom scaling of UV coordinates of loaded meshes.
  73561. */
  73562. UVScaling: Vector2;
  73563. /**
  73564. * Invert model on y-axis (does a model scaling inversion)
  73565. */
  73566. InvertY: boolean;
  73567. /**
  73568. * Invert Y-Axis of referenced textures on load
  73569. */
  73570. InvertTextureY: boolean;
  73571. /**
  73572. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73573. */
  73574. ImportVertexColors: boolean;
  73575. /**
  73576. * Compute the normals for the model, even if normals are present in the file.
  73577. */
  73578. ComputeNormals: boolean;
  73579. /**
  73580. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73581. */
  73582. SkipMaterials: boolean;
  73583. /**
  73584. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73585. */
  73586. MaterialLoadingFailsSilently: boolean;
  73587. };
  73588. /**
  73589. * OBJ file type loader.
  73590. * This is a babylon scene loader plugin.
  73591. */
  73592. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73593. /**
  73594. * Defines if UVs are optimized by default during load.
  73595. */
  73596. static OPTIMIZE_WITH_UV: boolean;
  73597. /**
  73598. * Invert model on y-axis (does a model scaling inversion)
  73599. */
  73600. static INVERT_Y: boolean;
  73601. /**
  73602. * Invert Y-Axis of referenced textures on load
  73603. */
  73604. static INVERT_TEXTURE_Y: boolean;
  73605. /**
  73606. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73607. */
  73608. static IMPORT_VERTEX_COLORS: boolean;
  73609. /**
  73610. * Compute the normals for the model, even if normals are present in the file.
  73611. */
  73612. static COMPUTE_NORMALS: boolean;
  73613. /**
  73614. * Defines custom scaling of UV coordinates of loaded meshes.
  73615. */
  73616. static UV_SCALING: Vector2;
  73617. /**
  73618. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73619. */
  73620. static SKIP_MATERIALS: boolean;
  73621. /**
  73622. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73623. *
  73624. * Defaults to true for backwards compatibility.
  73625. */
  73626. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  73627. /**
  73628. * Defines the name of the plugin.
  73629. */
  73630. name: string;
  73631. /**
  73632. * Defines the extension the plugin is able to load.
  73633. */
  73634. extensions: string;
  73635. /** @hidden */
  73636. obj: RegExp;
  73637. /** @hidden */
  73638. group: RegExp;
  73639. /** @hidden */
  73640. mtllib: RegExp;
  73641. /** @hidden */
  73642. usemtl: RegExp;
  73643. /** @hidden */
  73644. smooth: RegExp;
  73645. /** @hidden */
  73646. vertexPattern: RegExp;
  73647. /** @hidden */
  73648. normalPattern: RegExp;
  73649. /** @hidden */
  73650. uvPattern: RegExp;
  73651. /** @hidden */
  73652. facePattern1: RegExp;
  73653. /** @hidden */
  73654. facePattern2: RegExp;
  73655. /** @hidden */
  73656. facePattern3: RegExp;
  73657. /** @hidden */
  73658. facePattern4: RegExp;
  73659. /** @hidden */
  73660. facePattern5: RegExp;
  73661. private _meshLoadOptions;
  73662. /**
  73663. * Creates loader for .OBJ files
  73664. *
  73665. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  73666. */
  73667. constructor(meshLoadOptions?: MeshLoadOptions);
  73668. private static get currentMeshLoadOptions();
  73669. /**
  73670. * Calls synchronously the MTL file attached to this obj.
  73671. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  73672. * Without this function materials are not displayed in the first frame (but displayed after).
  73673. * In consequence it is impossible to get material information in your HTML file
  73674. *
  73675. * @param url The URL of the MTL file
  73676. * @param rootUrl
  73677. * @param onSuccess Callback function to be called when the MTL file is loaded
  73678. * @private
  73679. */
  73680. private _loadMTL;
  73681. /**
  73682. * Instantiates a OBJ file loader plugin.
  73683. * @returns the created plugin
  73684. */
  73685. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  73686. /**
  73687. * If the data string can be loaded directly.
  73688. *
  73689. * @param data string containing the file data
  73690. * @returns if the data can be loaded directly
  73691. */
  73692. canDirectLoad(data: string): boolean;
  73693. /**
  73694. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73695. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73696. * @param scene the scene the meshes should be added to
  73697. * @param data the OBJ data to load
  73698. * @param rootUrl root url to load from
  73699. * @param onProgress event that fires when loading progress has occured
  73700. * @param fileName Defines the name of the file to load
  73701. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73702. */
  73703. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73704. meshes: AbstractMesh[];
  73705. particleSystems: IParticleSystem[];
  73706. skeletons: Skeleton[];
  73707. animationGroups: AnimationGroup[];
  73708. }>;
  73709. /**
  73710. * Imports all objects from the loaded OBJ data and adds them to the scene
  73711. * @param scene the scene the objects should be added to
  73712. * @param data the OBJ data to load
  73713. * @param rootUrl root url to load from
  73714. * @param onProgress event that fires when loading progress has occured
  73715. * @param fileName Defines the name of the file to load
  73716. * @returns a promise which completes when objects have been loaded to the scene
  73717. */
  73718. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73719. /**
  73720. * Load into an asset container.
  73721. * @param scene The scene to load into
  73722. * @param data The data to import
  73723. * @param rootUrl The root url for scene and resources
  73724. * @param onProgress The callback when the load progresses
  73725. * @param fileName Defines the name of the file to load
  73726. * @returns The loaded asset container
  73727. */
  73728. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73729. /**
  73730. * Read the OBJ file and create an Array of meshes.
  73731. * Each mesh contains all information given by the OBJ and the MTL file.
  73732. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  73733. *
  73734. * @param meshesNames
  73735. * @param scene Scene The scene where are displayed the data
  73736. * @param data String The content of the obj file
  73737. * @param rootUrl String The path to the folder
  73738. * @returns Array<AbstractMesh>
  73739. * @private
  73740. */
  73741. private _parseSolid;
  73742. }
  73743. }
  73744. declare module BABYLON {
  73745. /**
  73746. * STL file type loader.
  73747. * This is a babylon scene loader plugin.
  73748. */
  73749. export class STLFileLoader implements ISceneLoaderPlugin {
  73750. /** @hidden */
  73751. solidPattern: RegExp;
  73752. /** @hidden */
  73753. facetsPattern: RegExp;
  73754. /** @hidden */
  73755. normalPattern: RegExp;
  73756. /** @hidden */
  73757. vertexPattern: RegExp;
  73758. /**
  73759. * Defines the name of the plugin.
  73760. */
  73761. name: string;
  73762. /**
  73763. * Defines the extensions the stl loader is able to load.
  73764. * force data to come in as an ArrayBuffer
  73765. * we'll convert to string if it looks like it's an ASCII .stl
  73766. */
  73767. extensions: ISceneLoaderPluginExtensions;
  73768. /**
  73769. * Import meshes into a scene.
  73770. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  73771. * @param scene The scene to import into
  73772. * @param data The data to import
  73773. * @param rootUrl The root url for scene and resources
  73774. * @param meshes The meshes array to import into
  73775. * @param particleSystems The particle systems array to import into
  73776. * @param skeletons The skeletons array to import into
  73777. * @param onError The callback when import fails
  73778. * @returns True if successful or false otherwise
  73779. */
  73780. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  73781. /**
  73782. * Load into a scene.
  73783. * @param scene The scene to load into
  73784. * @param data The data to import
  73785. * @param rootUrl The root url for scene and resources
  73786. * @param onError The callback when import fails
  73787. * @returns true if successful or false otherwise
  73788. */
  73789. load(scene: Scene, data: any, rootUrl: string): boolean;
  73790. /**
  73791. * Load into an asset container.
  73792. * @param scene The scene to load into
  73793. * @param data The data to import
  73794. * @param rootUrl The root url for scene and resources
  73795. * @param onError The callback when import fails
  73796. * @returns The loaded asset container
  73797. */
  73798. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  73799. private _isBinary;
  73800. private _parseBinary;
  73801. private _parseASCII;
  73802. }
  73803. }
  73804. declare module BABYLON {
  73805. /**
  73806. * Class for generating OBJ data from a Babylon scene.
  73807. */
  73808. export class OBJExport {
  73809. /**
  73810. * Exports the geometry of a Mesh array in .OBJ file format (text)
  73811. * @param mesh defines the list of meshes to serialize
  73812. * @param materials defines if materials should be exported
  73813. * @param matlibname defines the name of the associated mtl file
  73814. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  73815. * @returns the OBJ content
  73816. */
  73817. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  73818. /**
  73819. * Exports the material(s) of a mesh in .MTL file format (text)
  73820. * @param mesh defines the mesh to extract the material from
  73821. * @returns the mtl content
  73822. */
  73823. static MTL(mesh: Mesh): string;
  73824. }
  73825. }
  73826. declare module BABYLON {
  73827. /** @hidden */
  73828. export var __IGLTFExporterExtension: number;
  73829. /**
  73830. * Interface for extending the exporter
  73831. * @hidden
  73832. */
  73833. export interface IGLTFExporterExtension {
  73834. /**
  73835. * The name of this extension
  73836. */
  73837. readonly name: string;
  73838. /**
  73839. * Defines whether this extension is enabled
  73840. */
  73841. enabled: boolean;
  73842. /**
  73843. * Defines whether this extension is required
  73844. */
  73845. required: boolean;
  73846. }
  73847. }
  73848. declare module BABYLON.GLTF2.Exporter {
  73849. /** @hidden */
  73850. export var __IGLTFExporterExtensionV2: number;
  73851. /**
  73852. * Interface for a glTF exporter extension
  73853. * @hidden
  73854. */
  73855. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  73856. /**
  73857. * Define this method to modify the default behavior before exporting a texture
  73858. * @param context The context when loading the asset
  73859. * @param babylonTexture The Babylon.js texture
  73860. * @param mimeType The mime-type of the generated image
  73861. * @returns A promise that resolves with the exported texture
  73862. */
  73863. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73864. /**
  73865. * Define this method to get notified when a texture info is created
  73866. * @param context The context when loading the asset
  73867. * @param textureInfo The glTF texture info
  73868. * @param babylonTexture The Babylon.js texture
  73869. */
  73870. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73871. /**
  73872. * Define this method to modify the default behavior when exporting texture info
  73873. * @param context The context when loading the asset
  73874. * @param meshPrimitive glTF mesh primitive
  73875. * @param babylonSubMesh Babylon submesh
  73876. * @param binaryWriter glTF serializer binary writer instance
  73877. * @returns nullable IMeshPrimitive promise
  73878. */
  73879. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  73880. /**
  73881. * Define this method to modify the default behavior when exporting a node
  73882. * @param context The context when exporting the node
  73883. * @param node glTF node
  73884. * @param babylonNode BabylonJS node
  73885. * @returns nullable INode promise
  73886. */
  73887. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73888. /**
  73889. * Define this method to modify the default behavior when exporting a material
  73890. * @param material glTF material
  73891. * @param babylonMaterial BabylonJS material
  73892. * @returns nullable IMaterial promise
  73893. */
  73894. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73895. /**
  73896. * Define this method to return additional textures to export from a material
  73897. * @param material glTF material
  73898. * @param babylonMaterial BabylonJS material
  73899. * @returns List of textures
  73900. */
  73901. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73902. /** Gets a boolean indicating that this extension was used */
  73903. wasUsed: boolean;
  73904. /** Gets a boolean indicating that this extension is required for the file to work */
  73905. required: boolean;
  73906. /**
  73907. * Called after the exporter state changes to EXPORTING
  73908. */
  73909. onExporting?(): void;
  73910. }
  73911. }
  73912. declare module BABYLON.GLTF2.Exporter {
  73913. /**
  73914. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  73915. * @hidden
  73916. */
  73917. export class _GLTFMaterialExporter {
  73918. /**
  73919. * Represents the dielectric specular values for R, G and B
  73920. */
  73921. private static readonly _DielectricSpecular;
  73922. /**
  73923. * Allows the maximum specular power to be defined for material calculations
  73924. */
  73925. private static readonly _MaxSpecularPower;
  73926. /**
  73927. * Mapping to store textures
  73928. */
  73929. private _textureMap;
  73930. /**
  73931. * Numeric tolerance value
  73932. */
  73933. private static readonly _Epsilon;
  73934. /**
  73935. * Reference to the glTF Exporter
  73936. */
  73937. private _exporter;
  73938. constructor(exporter: _Exporter);
  73939. /**
  73940. * Specifies if two colors are approximately equal in value
  73941. * @param color1 first color to compare to
  73942. * @param color2 second color to compare to
  73943. * @param epsilon threshold value
  73944. */
  73945. private static FuzzyEquals;
  73946. /**
  73947. * Gets the materials from a Babylon scene and converts them to glTF materials
  73948. * @param scene babylonjs scene
  73949. * @param mimeType texture mime type
  73950. * @param images array of images
  73951. * @param textures array of textures
  73952. * @param materials array of materials
  73953. * @param imageData mapping of texture names to base64 textures
  73954. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73955. */
  73956. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73957. /**
  73958. * Makes a copy of the glTF material without the texture parameters
  73959. * @param originalMaterial original glTF material
  73960. * @returns glTF material without texture parameters
  73961. */
  73962. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73963. /**
  73964. * Specifies if the material has any texture parameters present
  73965. * @param material glTF Material
  73966. * @returns boolean specifying if texture parameters are present
  73967. */
  73968. _hasTexturesPresent(material: IMaterial): boolean;
  73969. /**
  73970. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73971. * @param babylonStandardMaterial
  73972. * @returns glTF Metallic Roughness Material representation
  73973. */
  73974. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73975. /**
  73976. * Computes the metallic factor
  73977. * @param diffuse diffused value
  73978. * @param specular specular value
  73979. * @param oneMinusSpecularStrength one minus the specular strength
  73980. * @returns metallic value
  73981. */
  73982. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73983. /**
  73984. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73985. * @param glTFMaterial glTF material
  73986. * @param babylonMaterial Babylon material
  73987. */
  73988. private static _SetAlphaMode;
  73989. /**
  73990. * Converts a Babylon Standard Material to a glTF Material
  73991. * @param babylonStandardMaterial BJS Standard Material
  73992. * @param mimeType mime type to use for the textures
  73993. * @param images array of glTF image interfaces
  73994. * @param textures array of glTF texture interfaces
  73995. * @param materials array of glTF material interfaces
  73996. * @param imageData map of image file name to data
  73997. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73998. */
  73999. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74000. private _finishMaterial;
  74001. /**
  74002. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74003. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  74004. * @param mimeType mime type to use for the textures
  74005. * @param images array of glTF image interfaces
  74006. * @param textures array of glTF texture interfaces
  74007. * @param materials array of glTF material interfaces
  74008. * @param imageData map of image file name to data
  74009. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74010. */
  74011. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74012. /**
  74013. * Converts an image typed array buffer to a base64 image
  74014. * @param buffer typed array buffer
  74015. * @param width width of the image
  74016. * @param height height of the image
  74017. * @param mimeType mimetype of the image
  74018. * @returns base64 image string
  74019. */
  74020. private _createBase64FromCanvasAsync;
  74021. /**
  74022. * Generates a white texture based on the specified width and height
  74023. * @param width width of the texture in pixels
  74024. * @param height height of the texture in pixels
  74025. * @param scene babylonjs scene
  74026. * @returns white texture
  74027. */
  74028. private _createWhiteTexture;
  74029. /**
  74030. * 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
  74031. * @param texture1 first texture to resize
  74032. * @param texture2 second texture to resize
  74033. * @param scene babylonjs scene
  74034. * @returns resized textures or null
  74035. */
  74036. private _resizeTexturesToSameDimensions;
  74037. /**
  74038. * Converts an array of pixels to a Float32Array
  74039. * Throws an error if the pixel format is not supported
  74040. * @param pixels - array buffer containing pixel values
  74041. * @returns Float32 of pixels
  74042. */
  74043. private _convertPixelArrayToFloat32;
  74044. /**
  74045. * Convert Specular Glossiness Textures to Metallic Roughness
  74046. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  74047. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  74048. * @param diffuseTexture texture used to store diffuse information
  74049. * @param specularGlossinessTexture texture used to store specular and glossiness information
  74050. * @param factors specular glossiness material factors
  74051. * @param mimeType the mime type to use for the texture
  74052. * @returns pbr metallic roughness interface or null
  74053. */
  74054. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  74055. /**
  74056. * Converts specular glossiness material properties to metallic roughness
  74057. * @param specularGlossiness interface with specular glossiness material properties
  74058. * @returns interface with metallic roughness material properties
  74059. */
  74060. private _convertSpecularGlossinessToMetallicRoughness;
  74061. /**
  74062. * Calculates the surface reflectance, independent of lighting conditions
  74063. * @param color Color source to calculate brightness from
  74064. * @returns number representing the perceived brightness, or zero if color is undefined
  74065. */
  74066. private _getPerceivedBrightness;
  74067. /**
  74068. * Returns the maximum color component value
  74069. * @param color
  74070. * @returns maximum color component value, or zero if color is null or undefined
  74071. */
  74072. private _getMaxComponent;
  74073. /**
  74074. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  74075. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74076. * @param mimeType mime type to use for the textures
  74077. * @param images array of glTF image interfaces
  74078. * @param textures array of glTF texture interfaces
  74079. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74080. * @param imageData map of image file name to data
  74081. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74082. * @returns glTF PBR Metallic Roughness factors
  74083. */
  74084. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  74085. private _getGLTFTextureSampler;
  74086. private _getGLTFTextureWrapMode;
  74087. private _getGLTFTextureWrapModesSampler;
  74088. /**
  74089. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  74090. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74091. * @param mimeType mime type to use for the textures
  74092. * @param images array of glTF image interfaces
  74093. * @param textures array of glTF texture interfaces
  74094. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74095. * @param imageData map of image file name to data
  74096. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74097. * @returns glTF PBR Metallic Roughness factors
  74098. */
  74099. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  74100. /**
  74101. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74102. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74103. * @param mimeType mime type to use for the textures
  74104. * @param images array of glTF image interfaces
  74105. * @param textures array of glTF texture interfaces
  74106. * @param materials array of glTF material interfaces
  74107. * @param imageData map of image file name to data
  74108. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74109. */
  74110. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74111. private setMetallicRoughnessPbrMaterial;
  74112. private getPixelsFromTexture;
  74113. /**
  74114. * Extracts a texture from a Babylon texture into file data and glTF data
  74115. * @param babylonTexture Babylon texture to extract
  74116. * @param mimeType Mime Type of the babylonTexture
  74117. * @return glTF texture info, or null if the texture format is not supported
  74118. */
  74119. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74120. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74121. /**
  74122. * Builds a texture from base64 string
  74123. * @param base64Texture base64 texture string
  74124. * @param baseTextureName Name to use for the texture
  74125. * @param mimeType image mime type for the texture
  74126. * @param images array of images
  74127. * @param textures array of textures
  74128. * @param imageData map of image data
  74129. * @returns glTF texture info, or null if the texture format is not supported
  74130. */
  74131. private _getTextureInfoFromBase64;
  74132. }
  74133. }
  74134. declare module BABYLON {
  74135. /**
  74136. * Class for holding and downloading glTF file data
  74137. */
  74138. export class GLTFData {
  74139. /**
  74140. * Object which contains the file name as the key and its data as the value
  74141. */
  74142. glTFFiles: {
  74143. [fileName: string]: string | Blob;
  74144. };
  74145. /**
  74146. * Initializes the glTF file object
  74147. */
  74148. constructor();
  74149. /**
  74150. * Downloads the glTF data as files based on their names and data
  74151. */
  74152. downloadFiles(): void;
  74153. }
  74154. }
  74155. declare module BABYLON {
  74156. /**
  74157. * Holds a collection of exporter options and parameters
  74158. */
  74159. export interface IExportOptions {
  74160. /**
  74161. * Function which indicates whether a babylon node should be exported or not
  74162. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74163. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74164. */
  74165. shouldExportNode?(node: Node): boolean;
  74166. /**
  74167. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74168. * @param metadata source metadata to read from
  74169. * @returns the data to store to glTF node extras
  74170. */
  74171. metadataSelector?(metadata: any): any;
  74172. /**
  74173. * The sample rate to bake animation curves
  74174. */
  74175. animationSampleRate?: number;
  74176. /**
  74177. * Begin serialization without waiting for the scene to be ready
  74178. */
  74179. exportWithoutWaitingForScene?: boolean;
  74180. }
  74181. /**
  74182. * Class for generating glTF data from a Babylon scene.
  74183. */
  74184. export class GLTF2Export {
  74185. /**
  74186. * Exports the geometry of the scene to .gltf file format asynchronously
  74187. * @param scene Babylon scene with scene hierarchy information
  74188. * @param filePrefix File prefix to use when generating the glTF file
  74189. * @param options Exporter options
  74190. * @returns Returns an object with a .gltf file and associates texture names
  74191. * as keys and their data and paths as values
  74192. */
  74193. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74194. private static _PreExportAsync;
  74195. private static _PostExportAsync;
  74196. /**
  74197. * Exports the geometry of the scene to .glb file format asychronously
  74198. * @param scene Babylon scene with scene hierarchy information
  74199. * @param filePrefix File prefix to use when generating glb file
  74200. * @param options Exporter options
  74201. * @returns Returns an object with a .glb filename as key and data as value
  74202. */
  74203. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74204. }
  74205. }
  74206. declare module BABYLON.GLTF2.Exporter {
  74207. /**
  74208. * @hidden
  74209. */
  74210. export class _GLTFUtilities {
  74211. /**
  74212. * Creates a buffer view based on the supplied arguments
  74213. * @param bufferIndex index value of the specified buffer
  74214. * @param byteOffset byte offset value
  74215. * @param byteLength byte length of the bufferView
  74216. * @param byteStride byte distance between conequential elements
  74217. * @param name name of the buffer view
  74218. * @returns bufferView for glTF
  74219. */
  74220. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74221. /**
  74222. * Creates an accessor based on the supplied arguments
  74223. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74224. * @param name The name of the accessor
  74225. * @param type The type of the accessor
  74226. * @param componentType The datatype of components in the attribute
  74227. * @param count The number of attributes referenced by this accessor
  74228. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74229. * @param min Minimum value of each component in this attribute
  74230. * @param max Maximum value of each component in this attribute
  74231. * @returns accessor for glTF
  74232. */
  74233. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74234. /**
  74235. * Calculates the minimum and maximum values of an array of position floats
  74236. * @param positions Positions array of a mesh
  74237. * @param vertexStart Starting vertex offset to calculate min and max values
  74238. * @param vertexCount Number of vertices to check for min and max values
  74239. * @returns min number array and max number array
  74240. */
  74241. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74242. min: number[];
  74243. max: number[];
  74244. };
  74245. /**
  74246. * Converts a new right-handed Vector3
  74247. * @param vector vector3 array
  74248. * @returns right-handed Vector3
  74249. */
  74250. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74251. /**
  74252. * Converts a Vector3 to right-handed
  74253. * @param vector Vector3 to convert to right-handed
  74254. */
  74255. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74256. /**
  74257. * Converts a three element number array to right-handed
  74258. * @param vector number array to convert to right-handed
  74259. */
  74260. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74261. /**
  74262. * Converts a new right-handed Vector3
  74263. * @param vector vector3 array
  74264. * @returns right-handed Vector3
  74265. */
  74266. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74267. /**
  74268. * Converts a Vector3 to right-handed
  74269. * @param vector Vector3 to convert to right-handed
  74270. */
  74271. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74272. /**
  74273. * Converts a three element number array to right-handed
  74274. * @param vector number array to convert to right-handed
  74275. */
  74276. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74277. /**
  74278. * Converts a Vector4 to right-handed
  74279. * @param vector Vector4 to convert to right-handed
  74280. */
  74281. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74282. /**
  74283. * Converts a Vector4 to right-handed
  74284. * @param vector Vector4 to convert to right-handed
  74285. */
  74286. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74287. /**
  74288. * Converts a Quaternion to right-handed
  74289. * @param quaternion Source quaternion to convert to right-handed
  74290. */
  74291. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74292. /**
  74293. * Converts a Quaternion to right-handed
  74294. * @param quaternion Source quaternion to convert to right-handed
  74295. */
  74296. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74297. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74298. }
  74299. }
  74300. declare module BABYLON.GLTF2.Exporter {
  74301. /**
  74302. * Converts Babylon Scene into glTF 2.0.
  74303. * @hidden
  74304. */
  74305. export class _Exporter {
  74306. /**
  74307. * Stores the glTF to export
  74308. */
  74309. _glTF: IGLTF;
  74310. /**
  74311. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74312. */
  74313. _bufferViews: IBufferView[];
  74314. /**
  74315. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  74316. */
  74317. _accessors: IAccessor[];
  74318. /**
  74319. * Stores all the generated nodes, which contains transform and/or mesh information per node
  74320. */
  74321. private _nodes;
  74322. /**
  74323. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  74324. */
  74325. private _scenes;
  74326. /**
  74327. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  74328. */
  74329. private _meshes;
  74330. /**
  74331. * Stores all the generated material information, which represents the appearance of each primitive
  74332. */
  74333. _materials: IMaterial[];
  74334. _materialMap: {
  74335. [materialID: number]: number;
  74336. };
  74337. /**
  74338. * Stores all the generated texture information, which is referenced by glTF materials
  74339. */
  74340. _textures: ITexture[];
  74341. /**
  74342. * Stores all the generated image information, which is referenced by glTF textures
  74343. */
  74344. _images: IImage[];
  74345. /**
  74346. * Stores all the texture samplers
  74347. */
  74348. _samplers: ISampler[];
  74349. /**
  74350. * Stores all the generated animation samplers, which is referenced by glTF animations
  74351. */
  74352. /**
  74353. * Stores the animations for glTF models
  74354. */
  74355. private _animations;
  74356. /**
  74357. * Stores the total amount of bytes stored in the glTF buffer
  74358. */
  74359. private _totalByteLength;
  74360. /**
  74361. * Stores a reference to the Babylon scene containing the source geometry and material information
  74362. */
  74363. _babylonScene: Scene;
  74364. /**
  74365. * Stores a map of the image data, where the key is the file name and the value
  74366. * is the image data
  74367. */
  74368. _imageData: {
  74369. [fileName: string]: {
  74370. data: Uint8Array;
  74371. mimeType: ImageMimeType;
  74372. };
  74373. };
  74374. /**
  74375. * Stores a map of the unique id of a node to its index in the node array
  74376. */
  74377. private _nodeMap;
  74378. /**
  74379. * Specifies if the Babylon scene should be converted to right-handed on export
  74380. */
  74381. _convertToRightHandedSystem: boolean;
  74382. /**
  74383. * Baked animation sample rate
  74384. */
  74385. private _animationSampleRate;
  74386. private _options;
  74387. private _localEngine;
  74388. _glTFMaterialExporter: _GLTFMaterialExporter;
  74389. private _extensions;
  74390. private static _ExtensionNames;
  74391. private static _ExtensionFactories;
  74392. private _applyExtension;
  74393. private _applyExtensions;
  74394. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  74395. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  74396. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  74397. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  74398. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  74399. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74400. private _forEachExtensions;
  74401. private _extensionsOnExporting;
  74402. /**
  74403. * Load glTF serializer extensions
  74404. */
  74405. private _loadExtensions;
  74406. /**
  74407. * Creates a glTF Exporter instance, which can accept optional exporter options
  74408. * @param babylonScene Babylon scene object
  74409. * @param options Options to modify the behavior of the exporter
  74410. */
  74411. constructor(babylonScene: Scene, options?: IExportOptions);
  74412. dispose(): void;
  74413. /**
  74414. * Registers a glTF exporter extension
  74415. * @param name Name of the extension to export
  74416. * @param factory The factory function that creates the exporter extension
  74417. */
  74418. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  74419. /**
  74420. * Un-registers an exporter extension
  74421. * @param name The name fo the exporter extension
  74422. * @returns A boolean indicating whether the extension has been un-registered
  74423. */
  74424. static UnregisterExtension(name: string): boolean;
  74425. /**
  74426. * Lazy load a local engine with premultiplied alpha set to false
  74427. */
  74428. _getLocalEngine(): Engine;
  74429. private reorderIndicesBasedOnPrimitiveMode;
  74430. /**
  74431. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  74432. * clock-wise during export to glTF
  74433. * @param submesh BabylonJS submesh
  74434. * @param primitiveMode Primitive mode of the mesh
  74435. * @param sideOrientation the winding order of the submesh
  74436. * @param vertexBufferKind The type of vertex attribute
  74437. * @param meshAttributeArray The vertex attribute data
  74438. * @param byteOffset The offset to the binary data
  74439. * @param binaryWriter The binary data for the glTF file
  74440. */
  74441. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  74442. /**
  74443. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  74444. * clock-wise during export to glTF
  74445. * @param submesh BabylonJS submesh
  74446. * @param primitiveMode Primitive mode of the mesh
  74447. * @param sideOrientation the winding order of the submesh
  74448. * @param vertexBufferKind The type of vertex attribute
  74449. * @param meshAttributeArray The vertex attribute data
  74450. * @param byteOffset The offset to the binary data
  74451. * @param binaryWriter The binary data for the glTF file
  74452. */
  74453. private reorderTriangleFillMode;
  74454. /**
  74455. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  74456. * clock-wise during export to glTF
  74457. * @param submesh BabylonJS submesh
  74458. * @param primitiveMode Primitive mode of the mesh
  74459. * @param sideOrientation the winding order of the submesh
  74460. * @param vertexBufferKind The type of vertex attribute
  74461. * @param meshAttributeArray The vertex attribute data
  74462. * @param byteOffset The offset to the binary data
  74463. * @param binaryWriter The binary data for the glTF file
  74464. */
  74465. private reorderTriangleStripDrawMode;
  74466. /**
  74467. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  74468. * clock-wise during export to glTF
  74469. * @param submesh BabylonJS submesh
  74470. * @param primitiveMode Primitive mode of the mesh
  74471. * @param sideOrientation the winding order of the submesh
  74472. * @param vertexBufferKind The type of vertex attribute
  74473. * @param meshAttributeArray The vertex attribute data
  74474. * @param byteOffset The offset to the binary data
  74475. * @param binaryWriter The binary data for the glTF file
  74476. */
  74477. private reorderTriangleFanMode;
  74478. /**
  74479. * Writes the vertex attribute data to binary
  74480. * @param vertices The vertices to write to the binary writer
  74481. * @param byteOffset The offset into the binary writer to overwrite binary data
  74482. * @param vertexAttributeKind The vertex attribute type
  74483. * @param meshAttributeArray The vertex attribute data
  74484. * @param binaryWriter The writer containing the binary data
  74485. */
  74486. private writeVertexAttributeData;
  74487. /**
  74488. * Writes mesh attribute data to a data buffer
  74489. * Returns the bytelength of the data
  74490. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  74491. * @param meshAttributeArray Array containing the attribute data
  74492. * @param binaryWriter The buffer to write the binary data to
  74493. * @param indices Used to specify the order of the vertex data
  74494. */
  74495. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  74496. /**
  74497. * Generates glTF json data
  74498. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  74499. * @param glTFPrefix Text to use when prefixing a glTF file
  74500. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  74501. * @returns json data as string
  74502. */
  74503. private generateJSON;
  74504. /**
  74505. * Generates data for .gltf and .bin files based on the glTF prefix string
  74506. * @param glTFPrefix Text to use when prefixing a glTF file
  74507. * @param dispose Dispose the exporter
  74508. * @returns GLTFData with glTF file data
  74509. */
  74510. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74511. /**
  74512. * Creates a binary buffer for glTF
  74513. * @returns array buffer for binary data
  74514. */
  74515. private _generateBinaryAsync;
  74516. /**
  74517. * Pads the number to a multiple of 4
  74518. * @param num number to pad
  74519. * @returns padded number
  74520. */
  74521. private _getPadding;
  74522. /**
  74523. * @hidden
  74524. */
  74525. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74526. /**
  74527. * Sets the TRS for each node
  74528. * @param node glTF Node for storing the transformation data
  74529. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  74530. */
  74531. private setNodeTransformation;
  74532. private getVertexBufferFromMesh;
  74533. /**
  74534. * Creates a bufferview based on the vertices type for the Babylon mesh
  74535. * @param kind Indicates the type of vertices data
  74536. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  74537. * @param binaryWriter The buffer to write the bufferview data to
  74538. */
  74539. private createBufferViewKind;
  74540. /**
  74541. * The primitive mode of the Babylon mesh
  74542. * @param babylonMesh The BabylonJS mesh
  74543. */
  74544. private getMeshPrimitiveMode;
  74545. /**
  74546. * Sets the primitive mode of the glTF mesh primitive
  74547. * @param meshPrimitive glTF mesh primitive
  74548. * @param primitiveMode The primitive mode
  74549. */
  74550. private setPrimitiveMode;
  74551. /**
  74552. * Sets the vertex attribute accessor based of the glTF mesh primitive
  74553. * @param meshPrimitive glTF mesh primitive
  74554. * @param attributeKind vertex attribute
  74555. * @returns boolean specifying if uv coordinates are present
  74556. */
  74557. private setAttributeKind;
  74558. /**
  74559. * Sets data for the primitive attributes of each submesh
  74560. * @param mesh glTF Mesh object to store the primitive attribute information
  74561. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  74562. * @param binaryWriter Buffer to write the attribute data to
  74563. */
  74564. private setPrimitiveAttributesAsync;
  74565. /**
  74566. * Creates a glTF scene based on the array of meshes
  74567. * Returns the the total byte offset
  74568. * @param babylonScene Babylon scene to get the mesh data from
  74569. * @param binaryWriter Buffer to write binary data to
  74570. */
  74571. private createSceneAsync;
  74572. /**
  74573. * Creates a mapping of Node unique id to node index and handles animations
  74574. * @param babylonScene Babylon Scene
  74575. * @param nodes Babylon transform nodes
  74576. * @param binaryWriter Buffer to write binary data to
  74577. * @returns Node mapping of unique id to index
  74578. */
  74579. private createNodeMapAndAnimationsAsync;
  74580. /**
  74581. * Creates a glTF node from a Babylon mesh
  74582. * @param babylonMesh Source Babylon mesh
  74583. * @param binaryWriter Buffer for storing geometry data
  74584. * @returns glTF node
  74585. */
  74586. private createNodeAsync;
  74587. }
  74588. /**
  74589. * @hidden
  74590. *
  74591. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  74592. */
  74593. export class _BinaryWriter {
  74594. /**
  74595. * Array buffer which stores all binary data
  74596. */
  74597. private _arrayBuffer;
  74598. /**
  74599. * View of the array buffer
  74600. */
  74601. private _dataView;
  74602. /**
  74603. * byte offset of data in array buffer
  74604. */
  74605. private _byteOffset;
  74606. /**
  74607. * Initialize binary writer with an initial byte length
  74608. * @param byteLength Initial byte length of the array buffer
  74609. */
  74610. constructor(byteLength: number);
  74611. /**
  74612. * Resize the array buffer to the specified byte length
  74613. * @param byteLength
  74614. */
  74615. private resizeBuffer;
  74616. /**
  74617. * Get an array buffer with the length of the byte offset
  74618. * @returns ArrayBuffer resized to the byte offset
  74619. */
  74620. getArrayBuffer(): ArrayBuffer;
  74621. /**
  74622. * Get the byte offset of the array buffer
  74623. * @returns byte offset
  74624. */
  74625. getByteOffset(): number;
  74626. /**
  74627. * Stores an UInt8 in the array buffer
  74628. * @param entry
  74629. * @param byteOffset If defined, specifies where to set the value as an offset.
  74630. */
  74631. setUInt8(entry: number, byteOffset?: number): void;
  74632. /**
  74633. * Gets an UInt32 in the array buffer
  74634. * @param entry
  74635. * @param byteOffset If defined, specifies where to set the value as an offset.
  74636. */
  74637. getUInt32(byteOffset: number): number;
  74638. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74639. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74640. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74641. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74642. /**
  74643. * Stores a Float32 in the array buffer
  74644. * @param entry
  74645. */
  74646. setFloat32(entry: number, byteOffset?: number): void;
  74647. /**
  74648. * Stores an UInt32 in the array buffer
  74649. * @param entry
  74650. * @param byteOffset If defined, specifies where to set the value as an offset.
  74651. */
  74652. setUInt32(entry: number, byteOffset?: number): void;
  74653. }
  74654. }
  74655. declare module BABYLON.GLTF2.Exporter {
  74656. /**
  74657. * @hidden
  74658. * Interface to store animation data.
  74659. */
  74660. export interface _IAnimationData {
  74661. /**
  74662. * Keyframe data.
  74663. */
  74664. inputs: number[];
  74665. /**
  74666. * Value data.
  74667. */
  74668. outputs: number[][];
  74669. /**
  74670. * Animation interpolation data.
  74671. */
  74672. samplerInterpolation: AnimationSamplerInterpolation;
  74673. /**
  74674. * Minimum keyframe value.
  74675. */
  74676. inputsMin: number;
  74677. /**
  74678. * Maximum keyframe value.
  74679. */
  74680. inputsMax: number;
  74681. }
  74682. /**
  74683. * @hidden
  74684. */
  74685. export interface _IAnimationInfo {
  74686. /**
  74687. * The target channel for the animation
  74688. */
  74689. animationChannelTargetPath: AnimationChannelTargetPath;
  74690. /**
  74691. * The glTF accessor type for the data.
  74692. */
  74693. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  74694. /**
  74695. * Specifies if quaternions should be used.
  74696. */
  74697. useQuaternion: boolean;
  74698. }
  74699. /**
  74700. * @hidden
  74701. * Utility class for generating glTF animation data from BabylonJS.
  74702. */
  74703. export class _GLTFAnimation {
  74704. /**
  74705. * @ignore
  74706. *
  74707. * Creates glTF channel animation from BabylonJS animation.
  74708. * @param babylonTransformNode - BabylonJS mesh.
  74709. * @param animation - animation.
  74710. * @param animationChannelTargetPath - The target animation channel.
  74711. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  74712. * @param useQuaternion - Specifies if quaternions are used.
  74713. * @returns nullable IAnimationData
  74714. */
  74715. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  74716. private static _DeduceAnimationInfo;
  74717. /**
  74718. * @ignore
  74719. * Create node animations from the transform node animations
  74720. * @param babylonNode
  74721. * @param runtimeGLTFAnimation
  74722. * @param idleGLTFAnimations
  74723. * @param nodeMap
  74724. * @param nodes
  74725. * @param binaryWriter
  74726. * @param bufferViews
  74727. * @param accessors
  74728. * @param convertToRightHandedSystem
  74729. */
  74730. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  74731. [key: number]: number;
  74732. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74733. /**
  74734. * @ignore
  74735. * Create node animations from the animation groups
  74736. * @param babylonScene
  74737. * @param glTFAnimations
  74738. * @param nodeMap
  74739. * @param nodes
  74740. * @param binaryWriter
  74741. * @param bufferViews
  74742. * @param accessors
  74743. * @param convertToRightHandedSystem
  74744. */
  74745. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  74746. [key: number]: number;
  74747. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74748. private static AddAnimation;
  74749. /**
  74750. * Create a baked animation
  74751. * @param babylonTransformNode BabylonJS mesh
  74752. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  74753. * @param animationChannelTargetPath animation target channel
  74754. * @param minFrame minimum animation frame
  74755. * @param maxFrame maximum animation frame
  74756. * @param fps frames per second of the animation
  74757. * @param inputs input key frames of the animation
  74758. * @param outputs output key frame data of the animation
  74759. * @param convertToRightHandedSystem converts the values to right-handed
  74760. * @param useQuaternion specifies if quaternions should be used
  74761. */
  74762. private static _CreateBakedAnimation;
  74763. private static _ConvertFactorToVector3OrQuaternion;
  74764. private static _SetInterpolatedValue;
  74765. /**
  74766. * Creates linear animation from the animation key frames
  74767. * @param babylonTransformNode BabylonJS mesh
  74768. * @param animation BabylonJS animation
  74769. * @param animationChannelTargetPath The target animation channel
  74770. * @param frameDelta The difference between the last and first frame of the animation
  74771. * @param inputs Array to store the key frame times
  74772. * @param outputs Array to store the key frame data
  74773. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74774. * @param useQuaternion Specifies if quaternions are used in the animation
  74775. */
  74776. private static _CreateLinearOrStepAnimation;
  74777. /**
  74778. * Creates cubic spline animation from the animation key frames
  74779. * @param babylonTransformNode BabylonJS mesh
  74780. * @param animation BabylonJS animation
  74781. * @param animationChannelTargetPath The target animation channel
  74782. * @param frameDelta The difference between the last and first frame of the animation
  74783. * @param inputs Array to store the key frame times
  74784. * @param outputs Array to store the key frame data
  74785. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74786. * @param useQuaternion Specifies if quaternions are used in the animation
  74787. */
  74788. private static _CreateCubicSplineAnimation;
  74789. private static _GetBasePositionRotationOrScale;
  74790. /**
  74791. * Adds a key frame value
  74792. * @param keyFrame
  74793. * @param animation
  74794. * @param outputs
  74795. * @param animationChannelTargetPath
  74796. * @param basePositionRotationOrScale
  74797. * @param convertToRightHandedSystem
  74798. * @param useQuaternion
  74799. */
  74800. private static _AddKeyframeValue;
  74801. /**
  74802. * Determine the interpolation based on the key frames
  74803. * @param keyFrames
  74804. * @param animationChannelTargetPath
  74805. * @param useQuaternion
  74806. */
  74807. private static _DeduceInterpolation;
  74808. /**
  74809. * Adds an input tangent or output tangent to the output data
  74810. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  74811. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  74812. * @param outputs The animation data by keyframe
  74813. * @param animationChannelTargetPath The target animation channel
  74814. * @param interpolation The interpolation type
  74815. * @param keyFrame The key frame with the animation data
  74816. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  74817. * @param useQuaternion Specifies if quaternions are used
  74818. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  74819. */
  74820. private static AddSplineTangent;
  74821. /**
  74822. * Get the minimum and maximum key frames' frame values
  74823. * @param keyFrames animation key frames
  74824. * @returns the minimum and maximum key frame value
  74825. */
  74826. private static calculateMinMaxKeyFrames;
  74827. }
  74828. }
  74829. declare module BABYLON.GLTF2.Exporter {
  74830. /** @hidden */
  74831. export var textureTransformPixelShader: {
  74832. name: string;
  74833. shader: string;
  74834. };
  74835. }
  74836. declare module BABYLON.GLTF2.Exporter.Extensions {
  74837. /**
  74838. * @hidden
  74839. */
  74840. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  74841. private _recordedTextures;
  74842. /** Name of this extension */
  74843. readonly name: string;
  74844. /** Defines whether this extension is enabled */
  74845. enabled: boolean;
  74846. /** Defines whether this extension is required */
  74847. required: boolean;
  74848. /** Reference to the glTF exporter */
  74849. private _wasUsed;
  74850. constructor(exporter: _Exporter);
  74851. dispose(): void;
  74852. /** @hidden */
  74853. get wasUsed(): boolean;
  74854. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74855. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74856. /**
  74857. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  74858. * @param babylonTexture
  74859. * @param offset
  74860. * @param rotation
  74861. * @param scale
  74862. * @param scene
  74863. */
  74864. private _textureTransformTextureAsync;
  74865. }
  74866. }
  74867. declare module BABYLON.GLTF2.Exporter.Extensions {
  74868. /**
  74869. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74870. */
  74871. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  74872. /** The name of this extension. */
  74873. readonly name: string;
  74874. /** Defines whether this extension is enabled. */
  74875. enabled: boolean;
  74876. /** Defines whether this extension is required */
  74877. required: boolean;
  74878. /** Reference to the glTF exporter */
  74879. private _exporter;
  74880. private _lights;
  74881. /** @hidden */
  74882. constructor(exporter: _Exporter);
  74883. /** @hidden */
  74884. dispose(): void;
  74885. /** @hidden */
  74886. get wasUsed(): boolean;
  74887. /** @hidden */
  74888. onExporting(): void;
  74889. /**
  74890. * Define this method to modify the default behavior when exporting a node
  74891. * @param context The context when exporting the node
  74892. * @param node glTF node
  74893. * @param babylonNode BabylonJS node
  74894. * @returns nullable INode promise
  74895. */
  74896. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74897. }
  74898. }
  74899. declare module BABYLON.GLTF2.Exporter.Extensions {
  74900. /**
  74901. * @hidden
  74902. */
  74903. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  74904. /** Name of this extension */
  74905. readonly name: string;
  74906. /** Defines whether this extension is enabled */
  74907. enabled: boolean;
  74908. /** Defines whether this extension is required */
  74909. required: boolean;
  74910. /** Reference to the glTF exporter */
  74911. private _textureInfos;
  74912. private _exportedTextures;
  74913. private _wasUsed;
  74914. constructor(exporter: _Exporter);
  74915. dispose(): void;
  74916. /** @hidden */
  74917. get wasUsed(): boolean;
  74918. private _getTextureIndex;
  74919. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74920. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74921. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74922. }
  74923. }
  74924. declare module BABYLON {
  74925. /**
  74926. * Class for generating STL data from a Babylon scene.
  74927. */
  74928. export class STLExport {
  74929. /**
  74930. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  74931. * @param meshes list defines the mesh to serialize
  74932. * @param download triggers the automatic download of the file.
  74933. * @param fileName changes the downloads fileName.
  74934. * @param binary changes the STL to a binary type.
  74935. * @param isLittleEndian toggle for binary type exporter.
  74936. * @returns the STL as UTF8 string
  74937. */
  74938. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  74939. }
  74940. }
  74941. declare module "babylonjs-gltf2interface" {
  74942. export = BABYLON.GLTF2;
  74943. }
  74944. /**
  74945. * Module for glTF 2.0 Interface
  74946. */
  74947. declare module BABYLON.GLTF2 {
  74948. /**
  74949. * The datatype of the components in the attribute
  74950. */
  74951. const enum AccessorComponentType {
  74952. /**
  74953. * Byte
  74954. */
  74955. BYTE = 5120,
  74956. /**
  74957. * Unsigned Byte
  74958. */
  74959. UNSIGNED_BYTE = 5121,
  74960. /**
  74961. * Short
  74962. */
  74963. SHORT = 5122,
  74964. /**
  74965. * Unsigned Short
  74966. */
  74967. UNSIGNED_SHORT = 5123,
  74968. /**
  74969. * Unsigned Int
  74970. */
  74971. UNSIGNED_INT = 5125,
  74972. /**
  74973. * Float
  74974. */
  74975. FLOAT = 5126,
  74976. }
  74977. /**
  74978. * Specifies if the attirbute is a scalar, vector, or matrix
  74979. */
  74980. const enum AccessorType {
  74981. /**
  74982. * Scalar
  74983. */
  74984. SCALAR = "SCALAR",
  74985. /**
  74986. * Vector2
  74987. */
  74988. VEC2 = "VEC2",
  74989. /**
  74990. * Vector3
  74991. */
  74992. VEC3 = "VEC3",
  74993. /**
  74994. * Vector4
  74995. */
  74996. VEC4 = "VEC4",
  74997. /**
  74998. * Matrix2x2
  74999. */
  75000. MAT2 = "MAT2",
  75001. /**
  75002. * Matrix3x3
  75003. */
  75004. MAT3 = "MAT3",
  75005. /**
  75006. * Matrix4x4
  75007. */
  75008. MAT4 = "MAT4",
  75009. }
  75010. /**
  75011. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75012. */
  75013. const enum AnimationChannelTargetPath {
  75014. /**
  75015. * Translation
  75016. */
  75017. TRANSLATION = "translation",
  75018. /**
  75019. * Rotation
  75020. */
  75021. ROTATION = "rotation",
  75022. /**
  75023. * Scale
  75024. */
  75025. SCALE = "scale",
  75026. /**
  75027. * Weights
  75028. */
  75029. WEIGHTS = "weights",
  75030. }
  75031. /**
  75032. * Interpolation algorithm
  75033. */
  75034. const enum AnimationSamplerInterpolation {
  75035. /**
  75036. * The animated values are linearly interpolated between keyframes
  75037. */
  75038. LINEAR = "LINEAR",
  75039. /**
  75040. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  75041. */
  75042. STEP = "STEP",
  75043. /**
  75044. * The animation's interpolation is computed using a cubic spline with specified tangents
  75045. */
  75046. CUBICSPLINE = "CUBICSPLINE",
  75047. }
  75048. /**
  75049. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75050. */
  75051. const enum CameraType {
  75052. /**
  75053. * A perspective camera containing properties to create a perspective projection matrix
  75054. */
  75055. PERSPECTIVE = "perspective",
  75056. /**
  75057. * An orthographic camera containing properties to create an orthographic projection matrix
  75058. */
  75059. ORTHOGRAPHIC = "orthographic",
  75060. }
  75061. /**
  75062. * The mime-type of the image
  75063. */
  75064. const enum ImageMimeType {
  75065. /**
  75066. * JPEG Mime-type
  75067. */
  75068. JPEG = "image/jpeg",
  75069. /**
  75070. * PNG Mime-type
  75071. */
  75072. PNG = "image/png",
  75073. }
  75074. /**
  75075. * The alpha rendering mode of the material
  75076. */
  75077. const enum MaterialAlphaMode {
  75078. /**
  75079. * The alpha value is ignored and the rendered output is fully opaque
  75080. */
  75081. OPAQUE = "OPAQUE",
  75082. /**
  75083. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  75084. */
  75085. MASK = "MASK",
  75086. /**
  75087. * 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)
  75088. */
  75089. BLEND = "BLEND",
  75090. }
  75091. /**
  75092. * The type of the primitives to render
  75093. */
  75094. const enum MeshPrimitiveMode {
  75095. /**
  75096. * Points
  75097. */
  75098. POINTS = 0,
  75099. /**
  75100. * Lines
  75101. */
  75102. LINES = 1,
  75103. /**
  75104. * Line Loop
  75105. */
  75106. LINE_LOOP = 2,
  75107. /**
  75108. * Line Strip
  75109. */
  75110. LINE_STRIP = 3,
  75111. /**
  75112. * Triangles
  75113. */
  75114. TRIANGLES = 4,
  75115. /**
  75116. * Triangle Strip
  75117. */
  75118. TRIANGLE_STRIP = 5,
  75119. /**
  75120. * Triangle Fan
  75121. */
  75122. TRIANGLE_FAN = 6,
  75123. }
  75124. /**
  75125. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75126. */
  75127. const enum TextureMagFilter {
  75128. /**
  75129. * Nearest
  75130. */
  75131. NEAREST = 9728,
  75132. /**
  75133. * Linear
  75134. */
  75135. LINEAR = 9729,
  75136. }
  75137. /**
  75138. * Minification filter. All valid values correspond to WebGL enums
  75139. */
  75140. const enum TextureMinFilter {
  75141. /**
  75142. * Nearest
  75143. */
  75144. NEAREST = 9728,
  75145. /**
  75146. * Linear
  75147. */
  75148. LINEAR = 9729,
  75149. /**
  75150. * Nearest Mip-Map Nearest
  75151. */
  75152. NEAREST_MIPMAP_NEAREST = 9984,
  75153. /**
  75154. * Linear Mipmap Nearest
  75155. */
  75156. LINEAR_MIPMAP_NEAREST = 9985,
  75157. /**
  75158. * Nearest Mipmap Linear
  75159. */
  75160. NEAREST_MIPMAP_LINEAR = 9986,
  75161. /**
  75162. * Linear Mipmap Linear
  75163. */
  75164. LINEAR_MIPMAP_LINEAR = 9987,
  75165. }
  75166. /**
  75167. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75168. */
  75169. const enum TextureWrapMode {
  75170. /**
  75171. * Clamp to Edge
  75172. */
  75173. CLAMP_TO_EDGE = 33071,
  75174. /**
  75175. * Mirrored Repeat
  75176. */
  75177. MIRRORED_REPEAT = 33648,
  75178. /**
  75179. * Repeat
  75180. */
  75181. REPEAT = 10497,
  75182. }
  75183. /**
  75184. * glTF Property
  75185. */
  75186. interface IProperty {
  75187. /**
  75188. * Dictionary object with extension-specific objects
  75189. */
  75190. extensions?: {
  75191. [key: string]: any;
  75192. };
  75193. /**
  75194. * Application-Specific data
  75195. */
  75196. extras?: any;
  75197. }
  75198. /**
  75199. * glTF Child of Root Property
  75200. */
  75201. interface IChildRootProperty extends IProperty {
  75202. /**
  75203. * The user-defined name of this object
  75204. */
  75205. name?: string;
  75206. }
  75207. /**
  75208. * Indices of those attributes that deviate from their initialization value
  75209. */
  75210. interface IAccessorSparseIndices extends IProperty {
  75211. /**
  75212. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75213. */
  75214. bufferView: number;
  75215. /**
  75216. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75217. */
  75218. byteOffset?: number;
  75219. /**
  75220. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75221. */
  75222. componentType: AccessorComponentType;
  75223. }
  75224. /**
  75225. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75226. */
  75227. interface IAccessorSparseValues extends IProperty {
  75228. /**
  75229. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75230. */
  75231. bufferView: number;
  75232. /**
  75233. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75234. */
  75235. byteOffset?: number;
  75236. }
  75237. /**
  75238. * Sparse storage of attributes that deviate from their initialization value
  75239. */
  75240. interface IAccessorSparse extends IProperty {
  75241. /**
  75242. * The number of attributes encoded in this sparse accessor
  75243. */
  75244. count: number;
  75245. /**
  75246. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75247. */
  75248. indices: IAccessorSparseIndices;
  75249. /**
  75250. * 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
  75251. */
  75252. values: IAccessorSparseValues;
  75253. }
  75254. /**
  75255. * 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
  75256. */
  75257. interface IAccessor extends IChildRootProperty {
  75258. /**
  75259. * The index of the bufferview
  75260. */
  75261. bufferView?: number;
  75262. /**
  75263. * The offset relative to the start of the bufferView in bytes
  75264. */
  75265. byteOffset?: number;
  75266. /**
  75267. * The datatype of components in the attribute
  75268. */
  75269. componentType: AccessorComponentType;
  75270. /**
  75271. * Specifies whether integer data values should be normalized
  75272. */
  75273. normalized?: boolean;
  75274. /**
  75275. * The number of attributes referenced by this accessor
  75276. */
  75277. count: number;
  75278. /**
  75279. * Specifies if the attribute is a scalar, vector, or matrix
  75280. */
  75281. type: AccessorType;
  75282. /**
  75283. * Maximum value of each component in this attribute
  75284. */
  75285. max?: number[];
  75286. /**
  75287. * Minimum value of each component in this attribute
  75288. */
  75289. min?: number[];
  75290. /**
  75291. * Sparse storage of attributes that deviate from their initialization value
  75292. */
  75293. sparse?: IAccessorSparse;
  75294. }
  75295. /**
  75296. * Targets an animation's sampler at a node's property
  75297. */
  75298. interface IAnimationChannel extends IProperty {
  75299. /**
  75300. * The index of a sampler in this animation used to compute the value for the target
  75301. */
  75302. sampler: number;
  75303. /**
  75304. * The index of the node and TRS property to target
  75305. */
  75306. target: IAnimationChannelTarget;
  75307. }
  75308. /**
  75309. * The index of the node and TRS property that an animation channel targets
  75310. */
  75311. interface IAnimationChannelTarget extends IProperty {
  75312. /**
  75313. * The index of the node to target
  75314. */
  75315. node: number;
  75316. /**
  75317. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75318. */
  75319. path: AnimationChannelTargetPath;
  75320. }
  75321. /**
  75322. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75323. */
  75324. interface IAnimationSampler extends IProperty {
  75325. /**
  75326. * The index of an accessor containing keyframe input values, e.g., time
  75327. */
  75328. input: number;
  75329. /**
  75330. * Interpolation algorithm
  75331. */
  75332. interpolation?: AnimationSamplerInterpolation;
  75333. /**
  75334. * The index of an accessor, containing keyframe output values
  75335. */
  75336. output: number;
  75337. }
  75338. /**
  75339. * A keyframe animation
  75340. */
  75341. interface IAnimation extends IChildRootProperty {
  75342. /**
  75343. * An array of channels, each of which targets an animation's sampler at a node's property
  75344. */
  75345. channels: IAnimationChannel[];
  75346. /**
  75347. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75348. */
  75349. samplers: IAnimationSampler[];
  75350. }
  75351. /**
  75352. * Metadata about the glTF asset
  75353. */
  75354. interface IAsset extends IChildRootProperty {
  75355. /**
  75356. * A copyright message suitable for display to credit the content creator
  75357. */
  75358. copyright?: string;
  75359. /**
  75360. * Tool that generated this glTF model. Useful for debugging
  75361. */
  75362. generator?: string;
  75363. /**
  75364. * The glTF version that this asset targets
  75365. */
  75366. version: string;
  75367. /**
  75368. * The minimum glTF version that this asset targets
  75369. */
  75370. minVersion?: string;
  75371. }
  75372. /**
  75373. * A buffer points to binary geometry, animation, or skins
  75374. */
  75375. interface IBuffer extends IChildRootProperty {
  75376. /**
  75377. * 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
  75378. */
  75379. uri?: string;
  75380. /**
  75381. * The length of the buffer in bytes
  75382. */
  75383. byteLength: number;
  75384. }
  75385. /**
  75386. * A view into a buffer generally representing a subset of the buffer
  75387. */
  75388. interface IBufferView extends IChildRootProperty {
  75389. /**
  75390. * The index of the buffer
  75391. */
  75392. buffer: number;
  75393. /**
  75394. * The offset into the buffer in bytes
  75395. */
  75396. byteOffset?: number;
  75397. /**
  75398. * The lenth of the bufferView in bytes
  75399. */
  75400. byteLength: number;
  75401. /**
  75402. * The stride, in bytes
  75403. */
  75404. byteStride?: number;
  75405. }
  75406. /**
  75407. * An orthographic camera containing properties to create an orthographic projection matrix
  75408. */
  75409. interface ICameraOrthographic extends IProperty {
  75410. /**
  75411. * The floating-point horizontal magnification of the view. Must not be zero
  75412. */
  75413. xmag: number;
  75414. /**
  75415. * The floating-point vertical magnification of the view. Must not be zero
  75416. */
  75417. ymag: number;
  75418. /**
  75419. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  75420. */
  75421. zfar: number;
  75422. /**
  75423. * The floating-point distance to the near clipping plane
  75424. */
  75425. znear: number;
  75426. }
  75427. /**
  75428. * A perspective camera containing properties to create a perspective projection matrix
  75429. */
  75430. interface ICameraPerspective extends IProperty {
  75431. /**
  75432. * The floating-point aspect ratio of the field of view
  75433. */
  75434. aspectRatio?: number;
  75435. /**
  75436. * The floating-point vertical field of view in radians
  75437. */
  75438. yfov: number;
  75439. /**
  75440. * The floating-point distance to the far clipping plane
  75441. */
  75442. zfar?: number;
  75443. /**
  75444. * The floating-point distance to the near clipping plane
  75445. */
  75446. znear: number;
  75447. }
  75448. /**
  75449. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75450. */
  75451. interface ICamera extends IChildRootProperty {
  75452. /**
  75453. * An orthographic camera containing properties to create an orthographic projection matrix
  75454. */
  75455. orthographic?: ICameraOrthographic;
  75456. /**
  75457. * A perspective camera containing properties to create a perspective projection matrix
  75458. */
  75459. perspective?: ICameraPerspective;
  75460. /**
  75461. * Specifies if the camera uses a perspective or orthographic projection
  75462. */
  75463. type: CameraType;
  75464. }
  75465. /**
  75466. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  75467. */
  75468. interface IImage extends IChildRootProperty {
  75469. /**
  75470. * 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
  75471. */
  75472. uri?: string;
  75473. /**
  75474. * The image's MIME type
  75475. */
  75476. mimeType?: ImageMimeType;
  75477. /**
  75478. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  75479. */
  75480. bufferView?: number;
  75481. }
  75482. /**
  75483. * Material Normal Texture Info
  75484. */
  75485. interface IMaterialNormalTextureInfo extends ITextureInfo {
  75486. /**
  75487. * The scalar multiplier applied to each normal vector of the normal texture
  75488. */
  75489. scale?: number;
  75490. }
  75491. /**
  75492. * Material Occlusion Texture Info
  75493. */
  75494. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  75495. /**
  75496. * A scalar multiplier controlling the amount of occlusion applied
  75497. */
  75498. strength?: number;
  75499. }
  75500. /**
  75501. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  75502. */
  75503. interface IMaterialPbrMetallicRoughness {
  75504. /**
  75505. * The material's base color factor
  75506. */
  75507. baseColorFactor?: number[];
  75508. /**
  75509. * The base color texture
  75510. */
  75511. baseColorTexture?: ITextureInfo;
  75512. /**
  75513. * The metalness of the material
  75514. */
  75515. metallicFactor?: number;
  75516. /**
  75517. * The roughness of the material
  75518. */
  75519. roughnessFactor?: number;
  75520. /**
  75521. * The metallic-roughness texture
  75522. */
  75523. metallicRoughnessTexture?: ITextureInfo;
  75524. }
  75525. /**
  75526. * The material appearance of a primitive
  75527. */
  75528. interface IMaterial extends IChildRootProperty {
  75529. /**
  75530. * 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
  75531. */
  75532. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75533. /**
  75534. * The normal map texture
  75535. */
  75536. normalTexture?: IMaterialNormalTextureInfo;
  75537. /**
  75538. * The occlusion map texture
  75539. */
  75540. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75541. /**
  75542. * The emissive map texture
  75543. */
  75544. emissiveTexture?: ITextureInfo;
  75545. /**
  75546. * 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
  75547. */
  75548. emissiveFactor?: number[];
  75549. /**
  75550. * The alpha rendering mode of the material
  75551. */
  75552. alphaMode?: MaterialAlphaMode;
  75553. /**
  75554. * The alpha cutoff value of the material
  75555. */
  75556. alphaCutoff?: number;
  75557. /**
  75558. * Specifies whether the material is double sided
  75559. */
  75560. doubleSided?: boolean;
  75561. }
  75562. /**
  75563. * Geometry to be rendered with the given material
  75564. */
  75565. interface IMeshPrimitive extends IProperty {
  75566. /**
  75567. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  75568. */
  75569. attributes: {
  75570. [name: string]: number;
  75571. };
  75572. /**
  75573. * The index of the accessor that contains the indices
  75574. */
  75575. indices?: number;
  75576. /**
  75577. * The index of the material to apply to this primitive when rendering
  75578. */
  75579. material?: number;
  75580. /**
  75581. * The type of primitives to render. All valid values correspond to WebGL enums
  75582. */
  75583. mode?: MeshPrimitiveMode;
  75584. /**
  75585. * 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
  75586. */
  75587. targets?: {
  75588. [name: string]: number;
  75589. }[];
  75590. }
  75591. /**
  75592. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  75593. */
  75594. interface IMesh extends IChildRootProperty {
  75595. /**
  75596. * An array of primitives, each defining geometry to be rendered with a material
  75597. */
  75598. primitives: IMeshPrimitive[];
  75599. /**
  75600. * Array of weights to be applied to the Morph Targets
  75601. */
  75602. weights?: number[];
  75603. }
  75604. /**
  75605. * A node in the node hierarchy
  75606. */
  75607. interface INode extends IChildRootProperty {
  75608. /**
  75609. * The index of the camera referenced by this node
  75610. */
  75611. camera?: number;
  75612. /**
  75613. * The indices of this node's children
  75614. */
  75615. children?: number[];
  75616. /**
  75617. * The index of the skin referenced by this node
  75618. */
  75619. skin?: number;
  75620. /**
  75621. * A floating-point 4x4 transformation matrix stored in column-major order
  75622. */
  75623. matrix?: number[];
  75624. /**
  75625. * The index of the mesh in this node
  75626. */
  75627. mesh?: number;
  75628. /**
  75629. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  75630. */
  75631. rotation?: number[];
  75632. /**
  75633. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  75634. */
  75635. scale?: number[];
  75636. /**
  75637. * The node's translation along the x, y, and z axes
  75638. */
  75639. translation?: number[];
  75640. /**
  75641. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  75642. */
  75643. weights?: number[];
  75644. }
  75645. /**
  75646. * Texture sampler properties for filtering and wrapping modes
  75647. */
  75648. interface ISampler extends IChildRootProperty {
  75649. /**
  75650. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75651. */
  75652. magFilter?: TextureMagFilter;
  75653. /**
  75654. * Minification filter. All valid values correspond to WebGL enums
  75655. */
  75656. minFilter?: TextureMinFilter;
  75657. /**
  75658. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75659. */
  75660. wrapS?: TextureWrapMode;
  75661. /**
  75662. * T (V) wrapping mode. All valid values correspond to WebGL enums
  75663. */
  75664. wrapT?: TextureWrapMode;
  75665. }
  75666. /**
  75667. * The root nodes of a scene
  75668. */
  75669. interface IScene extends IChildRootProperty {
  75670. /**
  75671. * The indices of each root node
  75672. */
  75673. nodes: number[];
  75674. }
  75675. /**
  75676. * Joints and matrices defining a skin
  75677. */
  75678. interface ISkin extends IChildRootProperty {
  75679. /**
  75680. * 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
  75681. */
  75682. inverseBindMatrices?: number;
  75683. /**
  75684. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  75685. */
  75686. skeleton?: number;
  75687. /**
  75688. * 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)
  75689. */
  75690. joints: number[];
  75691. }
  75692. /**
  75693. * A texture and its sampler
  75694. */
  75695. interface ITexture extends IChildRootProperty {
  75696. /**
  75697. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  75698. */
  75699. sampler?: number;
  75700. /**
  75701. * The index of the image used by this texture
  75702. */
  75703. source: number;
  75704. }
  75705. /**
  75706. * Reference to a texture
  75707. */
  75708. interface ITextureInfo extends IProperty {
  75709. /**
  75710. * The index of the texture
  75711. */
  75712. index: number;
  75713. /**
  75714. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  75715. */
  75716. texCoord?: number;
  75717. }
  75718. /**
  75719. * The root object for a glTF asset
  75720. */
  75721. interface IGLTF extends IProperty {
  75722. /**
  75723. * An array of accessors. An accessor is a typed view into a bufferView
  75724. */
  75725. accessors?: IAccessor[];
  75726. /**
  75727. * An array of keyframe animations
  75728. */
  75729. animations?: IAnimation[];
  75730. /**
  75731. * Metadata about the glTF asset
  75732. */
  75733. asset: IAsset;
  75734. /**
  75735. * An array of buffers. A buffer points to binary geometry, animation, or skins
  75736. */
  75737. buffers?: IBuffer[];
  75738. /**
  75739. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  75740. */
  75741. bufferViews?: IBufferView[];
  75742. /**
  75743. * An array of cameras
  75744. */
  75745. cameras?: ICamera[];
  75746. /**
  75747. * Names of glTF extensions used somewhere in this asset
  75748. */
  75749. extensionsUsed?: string[];
  75750. /**
  75751. * Names of glTF extensions required to properly load this asset
  75752. */
  75753. extensionsRequired?: string[];
  75754. /**
  75755. * An array of images. An image defines data used to create a texture
  75756. */
  75757. images?: IImage[];
  75758. /**
  75759. * An array of materials. A material defines the appearance of a primitive
  75760. */
  75761. materials?: IMaterial[];
  75762. /**
  75763. * An array of meshes. A mesh is a set of primitives to be rendered
  75764. */
  75765. meshes?: IMesh[];
  75766. /**
  75767. * An array of nodes
  75768. */
  75769. nodes?: INode[];
  75770. /**
  75771. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  75772. */
  75773. samplers?: ISampler[];
  75774. /**
  75775. * The index of the default scene
  75776. */
  75777. scene?: number;
  75778. /**
  75779. * An array of scenes
  75780. */
  75781. scenes?: IScene[];
  75782. /**
  75783. * An array of skins. A skin is defined by joints and matrices
  75784. */
  75785. skins?: ISkin[];
  75786. /**
  75787. * An array of textures
  75788. */
  75789. textures?: ITexture[];
  75790. }
  75791. /**
  75792. * The glTF validation results
  75793. * @ignore
  75794. */
  75795. interface IGLTFValidationResults {
  75796. info: {
  75797. generator: string;
  75798. hasAnimations: boolean;
  75799. hasDefaultScene: boolean;
  75800. hasMaterials: boolean;
  75801. hasMorphTargets: boolean;
  75802. hasSkins: boolean;
  75803. hasTextures: boolean;
  75804. maxAttributesUsed: number;
  75805. primitivesCount: number
  75806. };
  75807. issues: {
  75808. messages: Array<string>;
  75809. numErrors: number;
  75810. numHints: number;
  75811. numInfos: number;
  75812. numWarnings: number;
  75813. truncated: boolean
  75814. };
  75815. mimeType: string;
  75816. uri: string;
  75817. validatedAt: string;
  75818. validatorVersion: string;
  75819. }
  75820. /**
  75821. * The glTF validation options
  75822. */
  75823. interface IGLTFValidationOptions {
  75824. /** Uri to use */
  75825. uri?: string;
  75826. /** Function used to load external resources */
  75827. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  75828. /** Boolean indicating that we need to validate accessor data */
  75829. validateAccessorData?: boolean;
  75830. /** max number of issues allowed */
  75831. maxIssues?: number;
  75832. /** Ignored issues */
  75833. ignoredIssues?: Array<string>;
  75834. /** Value to override severy settings */
  75835. severityOverrides?: Object;
  75836. }
  75837. /**
  75838. * The glTF validator object
  75839. * @ignore
  75840. */
  75841. interface IGLTFValidator {
  75842. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75843. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75844. }
  75845. }
  75846. declare module BABYLON {
  75847. /** @hidden */
  75848. export var cellPixelShader: {
  75849. name: string;
  75850. shader: string;
  75851. };
  75852. }
  75853. declare module BABYLON {
  75854. /** @hidden */
  75855. export var cellVertexShader: {
  75856. name: string;
  75857. shader: string;
  75858. };
  75859. }
  75860. declare module BABYLON {
  75861. export class CellMaterial extends BABYLON.PushMaterial {
  75862. private _diffuseTexture;
  75863. diffuseTexture: BABYLON.BaseTexture;
  75864. diffuseColor: BABYLON.Color3;
  75865. _computeHighLevel: boolean;
  75866. computeHighLevel: boolean;
  75867. private _disableLighting;
  75868. disableLighting: boolean;
  75869. private _maxSimultaneousLights;
  75870. maxSimultaneousLights: number;
  75871. private _renderId;
  75872. constructor(name: string, scene: BABYLON.Scene);
  75873. needAlphaBlending(): boolean;
  75874. needAlphaTesting(): boolean;
  75875. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75876. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75877. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75878. getAnimatables(): BABYLON.IAnimatable[];
  75879. getActiveTextures(): BABYLON.BaseTexture[];
  75880. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75881. dispose(forceDisposeEffect?: boolean): void;
  75882. getClassName(): string;
  75883. clone(name: string): CellMaterial;
  75884. serialize(): any;
  75885. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  75886. }
  75887. }
  75888. declare module BABYLON {
  75889. export class CustomShaderStructure {
  75890. FragmentStore: string;
  75891. VertexStore: string;
  75892. constructor();
  75893. }
  75894. export class ShaderSpecialParts {
  75895. constructor();
  75896. Fragment_Begin: string;
  75897. Fragment_Definitions: string;
  75898. Fragment_MainBegin: string;
  75899. Fragment_Custom_Diffuse: string;
  75900. Fragment_Before_Lights: string;
  75901. Fragment_Before_Fog: string;
  75902. Fragment_Custom_Alpha: string;
  75903. Fragment_Before_FragColor: string;
  75904. Vertex_Begin: string;
  75905. Vertex_Definitions: string;
  75906. Vertex_MainBegin: string;
  75907. Vertex_Before_PositionUpdated: string;
  75908. Vertex_Before_NormalUpdated: string;
  75909. Vertex_MainEnd: string;
  75910. }
  75911. export class CustomMaterial extends BABYLON.StandardMaterial {
  75912. static ShaderIndexer: number;
  75913. CustomParts: ShaderSpecialParts;
  75914. _isCreatedShader: boolean;
  75915. _createdShaderName: string;
  75916. _customUniform: string[];
  75917. _newUniforms: string[];
  75918. _newUniformInstances: any[];
  75919. _newSamplerInstances: BABYLON.Texture[];
  75920. FragmentShader: string;
  75921. VertexShader: string;
  75922. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75923. ReviewUniform(name: string, arr: string[]): string[];
  75924. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  75925. constructor(name: string, scene: BABYLON.Scene);
  75926. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  75927. Fragment_Begin(shaderPart: string): CustomMaterial;
  75928. Fragment_Definitions(shaderPart: string): CustomMaterial;
  75929. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  75930. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  75931. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  75932. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  75933. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  75934. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  75935. Vertex_Begin(shaderPart: string): CustomMaterial;
  75936. Vertex_Definitions(shaderPart: string): CustomMaterial;
  75937. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  75938. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  75939. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  75940. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75941. }
  75942. }
  75943. declare module BABYLON {
  75944. export class ShaderAlebdoParts {
  75945. constructor();
  75946. Fragment_Begin: string;
  75947. Fragment_Definitions: string;
  75948. Fragment_MainBegin: string;
  75949. Fragment_Custom_Albedo: string;
  75950. Fragment_Before_Lights: string;
  75951. Fragment_Custom_MetallicRoughness: string;
  75952. Fragment_Custom_MicroSurface: string;
  75953. Fragment_Before_Fog: string;
  75954. Fragment_Custom_Alpha: string;
  75955. Fragment_Before_FragColor: string;
  75956. Vertex_Begin: string;
  75957. Vertex_Definitions: string;
  75958. Vertex_MainBegin: string;
  75959. Vertex_Before_PositionUpdated: string;
  75960. Vertex_Before_NormalUpdated: string;
  75961. Vertex_MainEnd: string;
  75962. }
  75963. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75964. static ShaderIndexer: number;
  75965. CustomParts: ShaderAlebdoParts;
  75966. _isCreatedShader: boolean;
  75967. _createdShaderName: string;
  75968. _customUniform: string[];
  75969. _newUniforms: string[];
  75970. _newUniformInstances: any[];
  75971. _newSamplerInstances: BABYLON.Texture[];
  75972. FragmentShader: string;
  75973. VertexShader: string;
  75974. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75975. ReviewUniform(name: string, arr: string[]): string[];
  75976. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75977. constructor(name: string, scene: BABYLON.Scene);
  75978. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75979. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75980. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75981. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75982. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75983. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75984. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75985. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75986. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75987. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75988. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75989. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75990. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75991. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75992. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75993. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75994. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75995. }
  75996. }
  75997. declare module BABYLON {
  75998. /** @hidden */
  75999. export var firePixelShader: {
  76000. name: string;
  76001. shader: string;
  76002. };
  76003. }
  76004. declare module BABYLON {
  76005. /** @hidden */
  76006. export var fireVertexShader: {
  76007. name: string;
  76008. shader: string;
  76009. };
  76010. }
  76011. declare module BABYLON {
  76012. export class FireMaterial extends BABYLON.PushMaterial {
  76013. private _diffuseTexture;
  76014. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76015. private _distortionTexture;
  76016. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76017. private _opacityTexture;
  76018. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76019. diffuseColor: BABYLON.Color3;
  76020. speed: number;
  76021. private _scaledDiffuse;
  76022. private _renderId;
  76023. private _lastTime;
  76024. constructor(name: string, scene: BABYLON.Scene);
  76025. needAlphaBlending(): boolean;
  76026. needAlphaTesting(): boolean;
  76027. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76028. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76029. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76030. getAnimatables(): BABYLON.IAnimatable[];
  76031. getActiveTextures(): BABYLON.BaseTexture[];
  76032. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76033. getClassName(): string;
  76034. dispose(forceDisposeEffect?: boolean): void;
  76035. clone(name: string): FireMaterial;
  76036. serialize(): any;
  76037. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  76038. }
  76039. }
  76040. declare module BABYLON {
  76041. /** @hidden */
  76042. export var furPixelShader: {
  76043. name: string;
  76044. shader: string;
  76045. };
  76046. }
  76047. declare module BABYLON {
  76048. /** @hidden */
  76049. export var furVertexShader: {
  76050. name: string;
  76051. shader: string;
  76052. };
  76053. }
  76054. declare module BABYLON {
  76055. export class FurMaterial extends BABYLON.PushMaterial {
  76056. private _diffuseTexture;
  76057. diffuseTexture: BABYLON.BaseTexture;
  76058. private _heightTexture;
  76059. heightTexture: BABYLON.BaseTexture;
  76060. diffuseColor: BABYLON.Color3;
  76061. furLength: number;
  76062. furAngle: number;
  76063. furColor: BABYLON.Color3;
  76064. furOffset: number;
  76065. furSpacing: number;
  76066. furGravity: BABYLON.Vector3;
  76067. furSpeed: number;
  76068. furDensity: number;
  76069. furOcclusion: number;
  76070. furTexture: BABYLON.DynamicTexture;
  76071. private _disableLighting;
  76072. disableLighting: boolean;
  76073. private _maxSimultaneousLights;
  76074. maxSimultaneousLights: number;
  76075. highLevelFur: boolean;
  76076. _meshes: BABYLON.AbstractMesh[];
  76077. private _renderId;
  76078. private _furTime;
  76079. constructor(name: string, scene: BABYLON.Scene);
  76080. get furTime(): number;
  76081. set furTime(furTime: number);
  76082. needAlphaBlending(): boolean;
  76083. needAlphaTesting(): boolean;
  76084. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76085. updateFur(): void;
  76086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76088. getAnimatables(): BABYLON.IAnimatable[];
  76089. getActiveTextures(): BABYLON.BaseTexture[];
  76090. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76091. dispose(forceDisposeEffect?: boolean): void;
  76092. clone(name: string): FurMaterial;
  76093. serialize(): any;
  76094. getClassName(): string;
  76095. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  76096. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  76097. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  76098. }
  76099. }
  76100. declare module BABYLON {
  76101. /** @hidden */
  76102. export var gradientPixelShader: {
  76103. name: string;
  76104. shader: string;
  76105. };
  76106. }
  76107. declare module BABYLON {
  76108. /** @hidden */
  76109. export var gradientVertexShader: {
  76110. name: string;
  76111. shader: string;
  76112. };
  76113. }
  76114. declare module BABYLON {
  76115. export class GradientMaterial extends BABYLON.PushMaterial {
  76116. private _maxSimultaneousLights;
  76117. maxSimultaneousLights: number;
  76118. topColor: BABYLON.Color3;
  76119. topColorAlpha: number;
  76120. bottomColor: BABYLON.Color3;
  76121. bottomColorAlpha: number;
  76122. offset: number;
  76123. scale: number;
  76124. smoothness: number;
  76125. private _disableLighting;
  76126. disableLighting: boolean;
  76127. private _renderId;
  76128. constructor(name: string, scene: BABYLON.Scene);
  76129. needAlphaBlending(): boolean;
  76130. needAlphaTesting(): boolean;
  76131. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76132. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76133. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76134. getAnimatables(): BABYLON.IAnimatable[];
  76135. dispose(forceDisposeEffect?: boolean): void;
  76136. clone(name: string): GradientMaterial;
  76137. serialize(): any;
  76138. getClassName(): string;
  76139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76140. }
  76141. }
  76142. declare module BABYLON {
  76143. /** @hidden */
  76144. export var gridPixelShader: {
  76145. name: string;
  76146. shader: string;
  76147. };
  76148. }
  76149. declare module BABYLON {
  76150. /** @hidden */
  76151. export var gridVertexShader: {
  76152. name: string;
  76153. shader: string;
  76154. };
  76155. }
  76156. declare module BABYLON {
  76157. /**
  76158. * The grid materials allows you to wrap any shape with a grid.
  76159. * Colors are customizable.
  76160. */
  76161. export class GridMaterial extends BABYLON.PushMaterial {
  76162. /**
  76163. * Main color of the grid (e.g. between lines)
  76164. */
  76165. mainColor: BABYLON.Color3;
  76166. /**
  76167. * Color of the grid lines.
  76168. */
  76169. lineColor: BABYLON.Color3;
  76170. /**
  76171. * The scale of the grid compared to unit.
  76172. */
  76173. gridRatio: number;
  76174. /**
  76175. * Allows setting an offset for the grid lines.
  76176. */
  76177. gridOffset: BABYLON.Vector3;
  76178. /**
  76179. * The frequency of thicker lines.
  76180. */
  76181. majorUnitFrequency: number;
  76182. /**
  76183. * The visibility of minor units in the grid.
  76184. */
  76185. minorUnitVisibility: number;
  76186. /**
  76187. * The grid opacity outside of the lines.
  76188. */
  76189. opacity: number;
  76190. /**
  76191. * Determine RBG output is premultiplied by alpha value.
  76192. */
  76193. preMultiplyAlpha: boolean;
  76194. private _opacityTexture;
  76195. opacityTexture: BABYLON.BaseTexture;
  76196. private _gridControl;
  76197. private _renderId;
  76198. /**
  76199. * constructor
  76200. * @param name The name given to the material in order to identify it afterwards.
  76201. * @param scene The scene the material is used in.
  76202. */
  76203. constructor(name: string, scene: BABYLON.Scene);
  76204. /**
  76205. * Returns wehter or not the grid requires alpha blending.
  76206. */
  76207. needAlphaBlending(): boolean;
  76208. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76209. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76210. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76211. /**
  76212. * Dispose the material and its associated resources.
  76213. * @param forceDisposeEffect will also dispose the used effect when true
  76214. */
  76215. dispose(forceDisposeEffect?: boolean): void;
  76216. clone(name: string): GridMaterial;
  76217. serialize(): any;
  76218. getClassName(): string;
  76219. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76220. }
  76221. }
  76222. declare module BABYLON {
  76223. /** @hidden */
  76224. export var lavaPixelShader: {
  76225. name: string;
  76226. shader: string;
  76227. };
  76228. }
  76229. declare module BABYLON {
  76230. /** @hidden */
  76231. export var lavaVertexShader: {
  76232. name: string;
  76233. shader: string;
  76234. };
  76235. }
  76236. declare module BABYLON {
  76237. export class LavaMaterial extends BABYLON.PushMaterial {
  76238. private _diffuseTexture;
  76239. diffuseTexture: BABYLON.BaseTexture;
  76240. noiseTexture: BABYLON.BaseTexture;
  76241. fogColor: BABYLON.Color3;
  76242. speed: number;
  76243. movingSpeed: number;
  76244. lowFrequencySpeed: number;
  76245. fogDensity: number;
  76246. private _lastTime;
  76247. diffuseColor: BABYLON.Color3;
  76248. private _disableLighting;
  76249. disableLighting: boolean;
  76250. private _unlit;
  76251. unlit: boolean;
  76252. private _maxSimultaneousLights;
  76253. maxSimultaneousLights: number;
  76254. private _scaledDiffuse;
  76255. private _renderId;
  76256. constructor(name: string, scene: BABYLON.Scene);
  76257. needAlphaBlending(): boolean;
  76258. needAlphaTesting(): boolean;
  76259. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76261. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76262. getAnimatables(): BABYLON.IAnimatable[];
  76263. getActiveTextures(): BABYLON.BaseTexture[];
  76264. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76265. dispose(forceDisposeEffect?: boolean): void;
  76266. clone(name: string): LavaMaterial;
  76267. serialize(): any;
  76268. getClassName(): string;
  76269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76270. }
  76271. }
  76272. declare module BABYLON {
  76273. /** @hidden */
  76274. export var mixPixelShader: {
  76275. name: string;
  76276. shader: string;
  76277. };
  76278. }
  76279. declare module BABYLON {
  76280. /** @hidden */
  76281. export var mixVertexShader: {
  76282. name: string;
  76283. shader: string;
  76284. };
  76285. }
  76286. declare module BABYLON {
  76287. export class MixMaterial extends BABYLON.PushMaterial {
  76288. /**
  76289. * Mix textures
  76290. */
  76291. private _mixTexture1;
  76292. mixTexture1: BABYLON.BaseTexture;
  76293. private _mixTexture2;
  76294. mixTexture2: BABYLON.BaseTexture;
  76295. /**
  76296. * Diffuse textures
  76297. */
  76298. private _diffuseTexture1;
  76299. diffuseTexture1: BABYLON.Texture;
  76300. private _diffuseTexture2;
  76301. diffuseTexture2: BABYLON.Texture;
  76302. private _diffuseTexture3;
  76303. diffuseTexture3: BABYLON.Texture;
  76304. private _diffuseTexture4;
  76305. diffuseTexture4: BABYLON.Texture;
  76306. private _diffuseTexture5;
  76307. diffuseTexture5: BABYLON.Texture;
  76308. private _diffuseTexture6;
  76309. diffuseTexture6: BABYLON.Texture;
  76310. private _diffuseTexture7;
  76311. diffuseTexture7: BABYLON.Texture;
  76312. private _diffuseTexture8;
  76313. diffuseTexture8: BABYLON.Texture;
  76314. /**
  76315. * Uniforms
  76316. */
  76317. diffuseColor: BABYLON.Color3;
  76318. specularColor: BABYLON.Color3;
  76319. specularPower: number;
  76320. private _disableLighting;
  76321. disableLighting: boolean;
  76322. private _maxSimultaneousLights;
  76323. maxSimultaneousLights: number;
  76324. private _renderId;
  76325. constructor(name: string, scene: BABYLON.Scene);
  76326. needAlphaBlending(): boolean;
  76327. needAlphaTesting(): boolean;
  76328. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76329. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76330. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76331. getAnimatables(): BABYLON.IAnimatable[];
  76332. getActiveTextures(): BABYLON.BaseTexture[];
  76333. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76334. dispose(forceDisposeEffect?: boolean): void;
  76335. clone(name: string): MixMaterial;
  76336. serialize(): any;
  76337. getClassName(): string;
  76338. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  76339. }
  76340. }
  76341. declare module BABYLON {
  76342. /** @hidden */
  76343. export var normalPixelShader: {
  76344. name: string;
  76345. shader: string;
  76346. };
  76347. }
  76348. declare module BABYLON {
  76349. /** @hidden */
  76350. export var normalVertexShader: {
  76351. name: string;
  76352. shader: string;
  76353. };
  76354. }
  76355. declare module BABYLON {
  76356. export class NormalMaterial extends BABYLON.PushMaterial {
  76357. private _diffuseTexture;
  76358. diffuseTexture: BABYLON.BaseTexture;
  76359. diffuseColor: BABYLON.Color3;
  76360. private _disableLighting;
  76361. disableLighting: boolean;
  76362. private _maxSimultaneousLights;
  76363. maxSimultaneousLights: number;
  76364. private _renderId;
  76365. constructor(name: string, scene: BABYLON.Scene);
  76366. needAlphaBlending(): boolean;
  76367. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76368. needAlphaTesting(): boolean;
  76369. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76370. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76371. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76372. getAnimatables(): BABYLON.IAnimatable[];
  76373. getActiveTextures(): BABYLON.BaseTexture[];
  76374. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76375. dispose(forceDisposeEffect?: boolean): void;
  76376. clone(name: string): NormalMaterial;
  76377. serialize(): any;
  76378. getClassName(): string;
  76379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  76380. }
  76381. }
  76382. declare module BABYLON {
  76383. /** @hidden */
  76384. export var shadowOnlyPixelShader: {
  76385. name: string;
  76386. shader: string;
  76387. };
  76388. }
  76389. declare module BABYLON {
  76390. /** @hidden */
  76391. export var shadowOnlyVertexShader: {
  76392. name: string;
  76393. shader: string;
  76394. };
  76395. }
  76396. declare module BABYLON {
  76397. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  76398. private _renderId;
  76399. private _activeLight;
  76400. constructor(name: string, scene: BABYLON.Scene);
  76401. shadowColor: BABYLON.Color3;
  76402. needAlphaBlending(): boolean;
  76403. needAlphaTesting(): boolean;
  76404. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76405. get activeLight(): BABYLON.IShadowLight;
  76406. set activeLight(light: BABYLON.IShadowLight);
  76407. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76408. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76409. clone(name: string): ShadowOnlyMaterial;
  76410. serialize(): any;
  76411. getClassName(): string;
  76412. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  76413. }
  76414. }
  76415. declare module BABYLON {
  76416. /** @hidden */
  76417. export var simplePixelShader: {
  76418. name: string;
  76419. shader: string;
  76420. };
  76421. }
  76422. declare module BABYLON {
  76423. /** @hidden */
  76424. export var simpleVertexShader: {
  76425. name: string;
  76426. shader: string;
  76427. };
  76428. }
  76429. declare module BABYLON {
  76430. export class SimpleMaterial extends BABYLON.PushMaterial {
  76431. private _diffuseTexture;
  76432. diffuseTexture: BABYLON.BaseTexture;
  76433. diffuseColor: BABYLON.Color3;
  76434. private _disableLighting;
  76435. disableLighting: boolean;
  76436. private _maxSimultaneousLights;
  76437. maxSimultaneousLights: number;
  76438. private _renderId;
  76439. constructor(name: string, scene: BABYLON.Scene);
  76440. needAlphaBlending(): boolean;
  76441. needAlphaTesting(): boolean;
  76442. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76443. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76444. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76445. getAnimatables(): BABYLON.IAnimatable[];
  76446. getActiveTextures(): BABYLON.BaseTexture[];
  76447. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76448. dispose(forceDisposeEffect?: boolean): void;
  76449. clone(name: string): SimpleMaterial;
  76450. serialize(): any;
  76451. getClassName(): string;
  76452. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  76453. }
  76454. }
  76455. declare module BABYLON {
  76456. /** @hidden */
  76457. export var skyPixelShader: {
  76458. name: string;
  76459. shader: string;
  76460. };
  76461. }
  76462. declare module BABYLON {
  76463. /** @hidden */
  76464. export var skyVertexShader: {
  76465. name: string;
  76466. shader: string;
  76467. };
  76468. }
  76469. declare module BABYLON {
  76470. /**
  76471. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  76472. * @see https://doc.babylonjs.com/extensions/sky
  76473. */
  76474. export class SkyMaterial extends BABYLON.PushMaterial {
  76475. /**
  76476. * Defines the overall luminance of sky in interval ]0, 1[.
  76477. */
  76478. luminance: number;
  76479. /**
  76480. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  76481. */
  76482. turbidity: number;
  76483. /**
  76484. * Defines the sky appearance (light intensity).
  76485. */
  76486. rayleigh: number;
  76487. /**
  76488. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  76489. */
  76490. mieCoefficient: number;
  76491. /**
  76492. * Defines the amount of haze particles following the Mie scattering theory.
  76493. */
  76494. mieDirectionalG: number;
  76495. /**
  76496. * Defines the distance of the sun according to the active scene camera.
  76497. */
  76498. distance: number;
  76499. /**
  76500. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  76501. * "inclined".
  76502. */
  76503. inclination: number;
  76504. /**
  76505. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  76506. * an object direction and a reference direction.
  76507. */
  76508. azimuth: number;
  76509. /**
  76510. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  76511. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  76512. */
  76513. sunPosition: BABYLON.Vector3;
  76514. /**
  76515. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  76516. * .sunPosition property.
  76517. */
  76518. useSunPosition: boolean;
  76519. /**
  76520. * Defines an offset vector used to get a horizon offset.
  76521. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  76522. */
  76523. cameraOffset: BABYLON.Vector3;
  76524. private _cameraPosition;
  76525. private _renderId;
  76526. /**
  76527. * Instantiates a new sky material.
  76528. * This material allows to create dynamic and texture free
  76529. * effects for skyboxes by taking care of the atmosphere state.
  76530. * @see https://doc.babylonjs.com/extensions/sky
  76531. * @param name Define the name of the material in the scene
  76532. * @param scene Define the scene the material belong to
  76533. */
  76534. constructor(name: string, scene: BABYLON.Scene);
  76535. /**
  76536. * Specifies if the material will require alpha blending
  76537. * @returns a boolean specifying if alpha blending is needed
  76538. */
  76539. needAlphaBlending(): boolean;
  76540. /**
  76541. * Specifies if this material should be rendered in alpha test mode
  76542. * @returns false as the sky material doesn't need alpha testing.
  76543. */
  76544. needAlphaTesting(): boolean;
  76545. /**
  76546. * Get the texture used for alpha test purpose.
  76547. * @returns null as the sky material has no texture.
  76548. */
  76549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76550. /**
  76551. * Get if the submesh is ready to be used and all its information available.
  76552. * Child classes can use it to update shaders
  76553. * @param mesh defines the mesh to check
  76554. * @param subMesh defines which submesh to check
  76555. * @param useInstances specifies that instances should be used
  76556. * @returns a boolean indicating that the submesh is ready or not
  76557. */
  76558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76559. /**
  76560. * Binds the submesh to this material by preparing the effect and shader to draw
  76561. * @param world defines the world transformation matrix
  76562. * @param mesh defines the mesh containing the submesh
  76563. * @param subMesh defines the submesh to bind the material to
  76564. */
  76565. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76566. /**
  76567. * Get the list of animatables in the material.
  76568. * @returns the list of animatables object used in the material
  76569. */
  76570. getAnimatables(): BABYLON.IAnimatable[];
  76571. /**
  76572. * Disposes the material
  76573. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76574. */
  76575. dispose(forceDisposeEffect?: boolean): void;
  76576. /**
  76577. * Makes a duplicate of the material, and gives it a new name
  76578. * @param name defines the new name for the duplicated material
  76579. * @returns the cloned material
  76580. */
  76581. clone(name: string): SkyMaterial;
  76582. /**
  76583. * Serializes this material in a JSON representation
  76584. * @returns the serialized material object
  76585. */
  76586. serialize(): any;
  76587. /**
  76588. * Gets the current class name of the material e.g. "SkyMaterial"
  76589. * Mainly use in serialization.
  76590. * @returns the class name
  76591. */
  76592. getClassName(): string;
  76593. /**
  76594. * Creates a sky material from parsed material data
  76595. * @param source defines the JSON representation of the material
  76596. * @param scene defines the hosting scene
  76597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76598. * @returns a new sky material
  76599. */
  76600. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  76601. }
  76602. }
  76603. declare module BABYLON {
  76604. /** @hidden */
  76605. export var terrainPixelShader: {
  76606. name: string;
  76607. shader: string;
  76608. };
  76609. }
  76610. declare module BABYLON {
  76611. /** @hidden */
  76612. export var terrainVertexShader: {
  76613. name: string;
  76614. shader: string;
  76615. };
  76616. }
  76617. declare module BABYLON {
  76618. export class TerrainMaterial extends BABYLON.PushMaterial {
  76619. private _mixTexture;
  76620. mixTexture: BABYLON.BaseTexture;
  76621. private _diffuseTexture1;
  76622. diffuseTexture1: BABYLON.Texture;
  76623. private _diffuseTexture2;
  76624. diffuseTexture2: BABYLON.Texture;
  76625. private _diffuseTexture3;
  76626. diffuseTexture3: BABYLON.Texture;
  76627. private _bumpTexture1;
  76628. bumpTexture1: BABYLON.Texture;
  76629. private _bumpTexture2;
  76630. bumpTexture2: BABYLON.Texture;
  76631. private _bumpTexture3;
  76632. bumpTexture3: BABYLON.Texture;
  76633. diffuseColor: BABYLON.Color3;
  76634. specularColor: BABYLON.Color3;
  76635. specularPower: number;
  76636. private _disableLighting;
  76637. disableLighting: boolean;
  76638. private _maxSimultaneousLights;
  76639. maxSimultaneousLights: number;
  76640. private _renderId;
  76641. constructor(name: string, scene: BABYLON.Scene);
  76642. needAlphaBlending(): boolean;
  76643. needAlphaTesting(): boolean;
  76644. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76645. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76646. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76647. getAnimatables(): BABYLON.IAnimatable[];
  76648. getActiveTextures(): BABYLON.BaseTexture[];
  76649. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76650. dispose(forceDisposeEffect?: boolean): void;
  76651. clone(name: string): TerrainMaterial;
  76652. serialize(): any;
  76653. getClassName(): string;
  76654. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  76655. }
  76656. }
  76657. declare module BABYLON {
  76658. /** @hidden */
  76659. export var triplanarPixelShader: {
  76660. name: string;
  76661. shader: string;
  76662. };
  76663. }
  76664. declare module BABYLON {
  76665. /** @hidden */
  76666. export var triplanarVertexShader: {
  76667. name: string;
  76668. shader: string;
  76669. };
  76670. }
  76671. declare module BABYLON {
  76672. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  76673. mixTexture: BABYLON.BaseTexture;
  76674. private _diffuseTextureX;
  76675. diffuseTextureX: BABYLON.BaseTexture;
  76676. private _diffuseTextureY;
  76677. diffuseTextureY: BABYLON.BaseTexture;
  76678. private _diffuseTextureZ;
  76679. diffuseTextureZ: BABYLON.BaseTexture;
  76680. private _normalTextureX;
  76681. normalTextureX: BABYLON.BaseTexture;
  76682. private _normalTextureY;
  76683. normalTextureY: BABYLON.BaseTexture;
  76684. private _normalTextureZ;
  76685. normalTextureZ: BABYLON.BaseTexture;
  76686. tileSize: number;
  76687. diffuseColor: BABYLON.Color3;
  76688. specularColor: BABYLON.Color3;
  76689. specularPower: number;
  76690. private _disableLighting;
  76691. disableLighting: boolean;
  76692. private _maxSimultaneousLights;
  76693. maxSimultaneousLights: number;
  76694. private _renderId;
  76695. constructor(name: string, scene: BABYLON.Scene);
  76696. needAlphaBlending(): boolean;
  76697. needAlphaTesting(): boolean;
  76698. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76699. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76700. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76701. getAnimatables(): BABYLON.IAnimatable[];
  76702. getActiveTextures(): BABYLON.BaseTexture[];
  76703. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76704. dispose(forceDisposeEffect?: boolean): void;
  76705. clone(name: string): TriPlanarMaterial;
  76706. serialize(): any;
  76707. getClassName(): string;
  76708. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  76709. }
  76710. }
  76711. declare module BABYLON {
  76712. /** @hidden */
  76713. export var waterPixelShader: {
  76714. name: string;
  76715. shader: string;
  76716. };
  76717. }
  76718. declare module BABYLON {
  76719. /** @hidden */
  76720. export var waterVertexShader: {
  76721. name: string;
  76722. shader: string;
  76723. };
  76724. }
  76725. declare module BABYLON {
  76726. export class WaterMaterial extends BABYLON.PushMaterial {
  76727. renderTargetSize: BABYLON.Vector2;
  76728. private _bumpTexture;
  76729. bumpTexture: BABYLON.BaseTexture;
  76730. diffuseColor: BABYLON.Color3;
  76731. specularColor: BABYLON.Color3;
  76732. specularPower: number;
  76733. private _disableLighting;
  76734. disableLighting: boolean;
  76735. private _maxSimultaneousLights;
  76736. maxSimultaneousLights: number;
  76737. /**
  76738. * @param {number}: Represents the wind force
  76739. */
  76740. windForce: number;
  76741. /**
  76742. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  76743. */
  76744. windDirection: BABYLON.Vector2;
  76745. /**
  76746. * @param {number}: Wave height, represents the height of the waves
  76747. */
  76748. waveHeight: number;
  76749. /**
  76750. * @param {number}: Bump height, represents the bump height related to the bump map
  76751. */
  76752. bumpHeight: number;
  76753. /**
  76754. * @param {boolean}: Add a smaller moving bump to less steady waves.
  76755. */
  76756. private _bumpSuperimpose;
  76757. bumpSuperimpose: boolean;
  76758. /**
  76759. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  76760. */
  76761. private _fresnelSeparate;
  76762. fresnelSeparate: boolean;
  76763. /**
  76764. * @param {boolean}: bump Waves modify the reflection.
  76765. */
  76766. private _bumpAffectsReflection;
  76767. bumpAffectsReflection: boolean;
  76768. /**
  76769. * @param {number}: The water color blended with the refraction (near)
  76770. */
  76771. waterColor: BABYLON.Color3;
  76772. /**
  76773. * @param {number}: The blend factor related to the water color
  76774. */
  76775. colorBlendFactor: number;
  76776. /**
  76777. * @param {number}: The water color blended with the reflection (far)
  76778. */
  76779. waterColor2: BABYLON.Color3;
  76780. /**
  76781. * @param {number}: The blend factor related to the water color (reflection, far)
  76782. */
  76783. colorBlendFactor2: number;
  76784. /**
  76785. * @param {number}: Represents the maximum length of a wave
  76786. */
  76787. waveLength: number;
  76788. /**
  76789. * @param {number}: Defines the waves speed
  76790. */
  76791. waveSpeed: number;
  76792. /**
  76793. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  76794. * will avoid calculating useless pixels in the pixel shader of the water material.
  76795. */
  76796. disableClipPlane: boolean;
  76797. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  76798. private _mesh;
  76799. private _refractionRTT;
  76800. private _reflectionRTT;
  76801. private _reflectionTransform;
  76802. private _lastTime;
  76803. private _lastDeltaTime;
  76804. private _renderId;
  76805. private _useLogarithmicDepth;
  76806. private _waitingRenderList;
  76807. private _imageProcessingConfiguration;
  76808. private _imageProcessingObserver;
  76809. /**
  76810. * Gets a boolean indicating that current material needs to register RTT
  76811. */
  76812. get hasRenderTargetTextures(): boolean;
  76813. /**
  76814. * Constructor
  76815. */
  76816. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  76817. get useLogarithmicDepth(): boolean;
  76818. set useLogarithmicDepth(value: boolean);
  76819. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76820. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76821. addToRenderList(node: any): void;
  76822. enableRenderTargets(enable: boolean): void;
  76823. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  76824. get renderTargetsEnabled(): boolean;
  76825. needAlphaBlending(): boolean;
  76826. needAlphaTesting(): boolean;
  76827. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76828. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76829. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76830. private _createRenderTargets;
  76831. getAnimatables(): BABYLON.IAnimatable[];
  76832. getActiveTextures(): BABYLON.BaseTexture[];
  76833. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76834. dispose(forceDisposeEffect?: boolean): void;
  76835. clone(name: string): WaterMaterial;
  76836. serialize(): any;
  76837. getClassName(): string;
  76838. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  76839. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  76840. }
  76841. }
  76842. declare module BABYLON {
  76843. /** @hidden */
  76844. export var asciiartPixelShader: {
  76845. name: string;
  76846. shader: string;
  76847. };
  76848. }
  76849. declare module BABYLON {
  76850. /**
  76851. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  76852. *
  76853. * It basically takes care rendering the font front the given font size to a texture.
  76854. * This is used later on in the postprocess.
  76855. */
  76856. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  76857. private _font;
  76858. private _text;
  76859. private _charSize;
  76860. /**
  76861. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76862. */
  76863. get charSize(): number;
  76864. /**
  76865. * Create a new instance of the Ascii Art FontTexture class
  76866. * @param name the name of the texture
  76867. * @param font the font to use, use the W3C CSS notation
  76868. * @param text the caracter set to use in the rendering.
  76869. * @param scene the scene that owns the texture
  76870. */
  76871. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76872. /**
  76873. * Gets the max char width of a font.
  76874. * @param font the font to use, use the W3C CSS notation
  76875. * @return the max char width
  76876. */
  76877. private getFontWidth;
  76878. /**
  76879. * Gets the max char height of a font.
  76880. * @param font the font to use, use the W3C CSS notation
  76881. * @return the max char height
  76882. */
  76883. private getFontHeight;
  76884. /**
  76885. * Clones the current AsciiArtTexture.
  76886. * @return the clone of the texture.
  76887. */
  76888. clone(): AsciiArtFontTexture;
  76889. /**
  76890. * Parses a json object representing the texture and returns an instance of it.
  76891. * @param source the source JSON representation
  76892. * @param scene the scene to create the texture for
  76893. * @return the parsed texture
  76894. */
  76895. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  76896. }
  76897. /**
  76898. * Option available in the Ascii Art Post Process.
  76899. */
  76900. export interface IAsciiArtPostProcessOptions {
  76901. /**
  76902. * The font to use following the w3c font definition.
  76903. */
  76904. font?: string;
  76905. /**
  76906. * The character set to use in the postprocess.
  76907. */
  76908. characterSet?: string;
  76909. /**
  76910. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76911. * This number is defined between 0 and 1;
  76912. */
  76913. mixToTile?: number;
  76914. /**
  76915. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76916. * This number is defined between 0 and 1;
  76917. */
  76918. mixToNormal?: number;
  76919. }
  76920. /**
  76921. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  76922. *
  76923. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76924. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  76925. */
  76926. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  76927. /**
  76928. * The font texture used to render the char in the post process.
  76929. */
  76930. private _asciiArtFontTexture;
  76931. /**
  76932. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76933. * This number is defined between 0 and 1;
  76934. */
  76935. mixToTile: number;
  76936. /**
  76937. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76938. * This number is defined between 0 and 1;
  76939. */
  76940. mixToNormal: number;
  76941. /**
  76942. * Instantiates a new Ascii Art Post Process.
  76943. * @param name the name to give to the postprocess
  76944. * @camera the camera to apply the post process to.
  76945. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76946. */
  76947. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76948. }
  76949. }
  76950. declare module BABYLON {
  76951. /** @hidden */
  76952. export var digitalrainPixelShader: {
  76953. name: string;
  76954. shader: string;
  76955. };
  76956. }
  76957. declare module BABYLON {
  76958. /**
  76959. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76960. *
  76961. * It basically takes care rendering the font front the given font size to a texture.
  76962. * This is used later on in the postprocess.
  76963. */
  76964. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76965. private _font;
  76966. private _text;
  76967. private _charSize;
  76968. /**
  76969. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76970. */
  76971. get charSize(): number;
  76972. /**
  76973. * Create a new instance of the Digital Rain FontTexture class
  76974. * @param name the name of the texture
  76975. * @param font the font to use, use the W3C CSS notation
  76976. * @param text the caracter set to use in the rendering.
  76977. * @param scene the scene that owns the texture
  76978. */
  76979. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76980. /**
  76981. * Gets the max char width of a font.
  76982. * @param font the font to use, use the W3C CSS notation
  76983. * @return the max char width
  76984. */
  76985. private getFontWidth;
  76986. /**
  76987. * Gets the max char height of a font.
  76988. * @param font the font to use, use the W3C CSS notation
  76989. * @return the max char height
  76990. */
  76991. private getFontHeight;
  76992. /**
  76993. * Clones the current DigitalRainFontTexture.
  76994. * @return the clone of the texture.
  76995. */
  76996. clone(): DigitalRainFontTexture;
  76997. /**
  76998. * Parses a json object representing the texture and returns an instance of it.
  76999. * @param source the source JSON representation
  77000. * @param scene the scene to create the texture for
  77001. * @return the parsed texture
  77002. */
  77003. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  77004. }
  77005. /**
  77006. * Option available in the Digital Rain Post Process.
  77007. */
  77008. export interface IDigitalRainPostProcessOptions {
  77009. /**
  77010. * The font to use following the w3c font definition.
  77011. */
  77012. font?: string;
  77013. /**
  77014. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77015. * This number is defined between 0 and 1;
  77016. */
  77017. mixToTile?: number;
  77018. /**
  77019. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77020. * This number is defined between 0 and 1;
  77021. */
  77022. mixToNormal?: number;
  77023. }
  77024. /**
  77025. * DigitalRainPostProcess helps rendering everithing in digital rain.
  77026. *
  77027. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77028. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  77029. */
  77030. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  77031. /**
  77032. * The font texture used to render the char in the post process.
  77033. */
  77034. private _digitalRainFontTexture;
  77035. /**
  77036. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77037. * This number is defined between 0 and 1;
  77038. */
  77039. mixToTile: number;
  77040. /**
  77041. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77042. * This number is defined between 0 and 1;
  77043. */
  77044. mixToNormal: number;
  77045. /**
  77046. * Instantiates a new Digital Rain Post Process.
  77047. * @param name the name to give to the postprocess
  77048. * @camera the camera to apply the post process to.
  77049. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  77050. */
  77051. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  77052. }
  77053. }
  77054. declare module BABYLON {
  77055. /** @hidden */
  77056. export var oceanPostProcessPixelShader: {
  77057. name: string;
  77058. shader: string;
  77059. };
  77060. }
  77061. declare module BABYLON {
  77062. /**
  77063. * Option available in the Ocean Post Process.
  77064. */
  77065. export interface IOceanPostProcessOptions {
  77066. /**
  77067. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77068. */
  77069. reflectionSize?: number | {
  77070. width: number;
  77071. height: number;
  77072. } | {
  77073. ratio: number;
  77074. };
  77075. /**
  77076. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77077. */
  77078. refractionSize?: number | {
  77079. width: number;
  77080. height: number;
  77081. } | {
  77082. ratio: number;
  77083. };
  77084. }
  77085. /**
  77086. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  77087. *
  77088. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77089. * Example usage:
  77090. * var pp = new OceanPostProcess("myOcean", camera);
  77091. * pp.reflectionEnabled = true;
  77092. * pp.refractionEnabled = true;
  77093. */
  77094. export class OceanPostProcess extends BABYLON.PostProcess {
  77095. /**
  77096. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  77097. */
  77098. get reflectionEnabled(): boolean;
  77099. /**
  77100. * Sets weither or not the real-time reflection is enabled on the ocean.
  77101. * Is set to true, the reflection mirror texture will be used as reflection texture.
  77102. */
  77103. set reflectionEnabled(enabled: boolean);
  77104. /**
  77105. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  77106. */
  77107. get refractionEnabled(): boolean;
  77108. /**
  77109. * Sets weither or not the real-time refraction is enabled on the ocean.
  77110. * Is set to true, the refraction render target texture will be used as refraction texture.
  77111. */
  77112. set refractionEnabled(enabled: boolean);
  77113. /**
  77114. * Gets wether or not the post-processes is supported by the running hardware.
  77115. * This requires draw buffer supports.
  77116. */
  77117. get isSupported(): boolean;
  77118. /**
  77119. * This is the reflection mirror texture used to display reflections on the ocean.
  77120. * By default, render list is empty.
  77121. */
  77122. reflectionTexture: BABYLON.MirrorTexture;
  77123. /**
  77124. * This is the refraction render target texture used to display refraction on the ocean.
  77125. * By default, render list is empty.
  77126. */
  77127. refractionTexture: BABYLON.RenderTargetTexture;
  77128. private _time;
  77129. private _cameraRotation;
  77130. private _cameraViewMatrix;
  77131. private _reflectionEnabled;
  77132. private _refractionEnabled;
  77133. private _geometryRenderer;
  77134. /**
  77135. * Instantiates a new Ocean Post Process.
  77136. * @param name the name to give to the postprocess.
  77137. * @camera the camera to apply the post process to.
  77138. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77139. */
  77140. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77141. /**
  77142. * Returns the appropriate defines according to the current configuration.
  77143. */
  77144. private _getDefines;
  77145. /**
  77146. * Computes the current camera rotation as the shader requires a camera rotation.
  77147. */
  77148. private _computeCameraRotation;
  77149. }
  77150. }
  77151. declare module BABYLON {
  77152. /** @hidden */
  77153. export var brickProceduralTexturePixelShader: {
  77154. name: string;
  77155. shader: string;
  77156. };
  77157. }
  77158. declare module BABYLON {
  77159. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77160. private _numberOfBricksHeight;
  77161. private _numberOfBricksWidth;
  77162. private _jointColor;
  77163. private _brickColor;
  77164. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77165. updateShaderUniforms(): void;
  77166. get numberOfBricksHeight(): number;
  77167. set numberOfBricksHeight(value: number);
  77168. get numberOfBricksWidth(): number;
  77169. set numberOfBricksWidth(value: number);
  77170. get jointColor(): BABYLON.Color3;
  77171. set jointColor(value: BABYLON.Color3);
  77172. get brickColor(): BABYLON.Color3;
  77173. set brickColor(value: BABYLON.Color3);
  77174. /**
  77175. * Serializes this brick procedural texture
  77176. * @returns a serialized brick procedural texture object
  77177. */
  77178. serialize(): any;
  77179. /**
  77180. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77181. * @param parsedTexture defines parsed texture data
  77182. * @param scene defines the current scene
  77183. * @param rootUrl defines the root URL containing brick procedural texture information
  77184. * @returns a parsed Brick Procedural BABYLON.Texture
  77185. */
  77186. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77187. }
  77188. }
  77189. declare module BABYLON {
  77190. /** @hidden */
  77191. export var cloudProceduralTexturePixelShader: {
  77192. name: string;
  77193. shader: string;
  77194. };
  77195. }
  77196. declare module BABYLON {
  77197. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77198. private _skyColor;
  77199. private _cloudColor;
  77200. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77201. updateShaderUniforms(): void;
  77202. get skyColor(): BABYLON.Color4;
  77203. set skyColor(value: BABYLON.Color4);
  77204. get cloudColor(): BABYLON.Color4;
  77205. set cloudColor(value: BABYLON.Color4);
  77206. /**
  77207. * Serializes this cloud procedural texture
  77208. * @returns a serialized cloud procedural texture object
  77209. */
  77210. serialize(): any;
  77211. /**
  77212. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77213. * @param parsedTexture defines parsed texture data
  77214. * @param scene defines the current scene
  77215. * @param rootUrl defines the root URL containing cloud procedural texture information
  77216. * @returns a parsed Cloud Procedural BABYLON.Texture
  77217. */
  77218. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77219. }
  77220. }
  77221. declare module BABYLON {
  77222. /** @hidden */
  77223. export var fireProceduralTexturePixelShader: {
  77224. name: string;
  77225. shader: string;
  77226. };
  77227. }
  77228. declare module BABYLON {
  77229. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77230. private _time;
  77231. private _speed;
  77232. private _autoGenerateTime;
  77233. private _fireColors;
  77234. private _alphaThreshold;
  77235. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77236. updateShaderUniforms(): void;
  77237. render(useCameraPostProcess?: boolean): void;
  77238. static get PurpleFireColors(): BABYLON.Color3[];
  77239. static get GreenFireColors(): BABYLON.Color3[];
  77240. static get RedFireColors(): BABYLON.Color3[];
  77241. static get BlueFireColors(): BABYLON.Color3[];
  77242. get autoGenerateTime(): boolean;
  77243. set autoGenerateTime(value: boolean);
  77244. get fireColors(): BABYLON.Color3[];
  77245. set fireColors(value: BABYLON.Color3[]);
  77246. get time(): number;
  77247. set time(value: number);
  77248. get speed(): BABYLON.Vector2;
  77249. set speed(value: BABYLON.Vector2);
  77250. get alphaThreshold(): number;
  77251. set alphaThreshold(value: number);
  77252. /**
  77253. * Serializes this fire procedural texture
  77254. * @returns a serialized fire procedural texture object
  77255. */
  77256. serialize(): any;
  77257. /**
  77258. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77259. * @param parsedTexture defines parsed texture data
  77260. * @param scene defines the current scene
  77261. * @param rootUrl defines the root URL containing fire procedural texture information
  77262. * @returns a parsed Fire Procedural BABYLON.Texture
  77263. */
  77264. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77265. }
  77266. }
  77267. declare module BABYLON {
  77268. /** @hidden */
  77269. export var grassProceduralTexturePixelShader: {
  77270. name: string;
  77271. shader: string;
  77272. };
  77273. }
  77274. declare module BABYLON {
  77275. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77276. private _grassColors;
  77277. private _groundColor;
  77278. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77279. updateShaderUniforms(): void;
  77280. get grassColors(): BABYLON.Color3[];
  77281. set grassColors(value: BABYLON.Color3[]);
  77282. get groundColor(): BABYLON.Color3;
  77283. set groundColor(value: BABYLON.Color3);
  77284. /**
  77285. * Serializes this grass procedural texture
  77286. * @returns a serialized grass procedural texture object
  77287. */
  77288. serialize(): any;
  77289. /**
  77290. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77291. * @param parsedTexture defines parsed texture data
  77292. * @param scene defines the current scene
  77293. * @param rootUrl defines the root URL containing grass procedural texture information
  77294. * @returns a parsed Grass Procedural BABYLON.Texture
  77295. */
  77296. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77297. }
  77298. }
  77299. declare module BABYLON {
  77300. /** @hidden */
  77301. export var marbleProceduralTexturePixelShader: {
  77302. name: string;
  77303. shader: string;
  77304. };
  77305. }
  77306. declare module BABYLON {
  77307. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77308. private _numberOfTilesHeight;
  77309. private _numberOfTilesWidth;
  77310. private _amplitude;
  77311. private _jointColor;
  77312. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77313. updateShaderUniforms(): void;
  77314. get numberOfTilesHeight(): number;
  77315. set numberOfTilesHeight(value: number);
  77316. get amplitude(): number;
  77317. set amplitude(value: number);
  77318. get numberOfTilesWidth(): number;
  77319. set numberOfTilesWidth(value: number);
  77320. get jointColor(): BABYLON.Color3;
  77321. set jointColor(value: BABYLON.Color3);
  77322. /**
  77323. * Serializes this marble procedural texture
  77324. * @returns a serialized marble procedural texture object
  77325. */
  77326. serialize(): any;
  77327. /**
  77328. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  77329. * @param parsedTexture defines parsed texture data
  77330. * @param scene defines the current scene
  77331. * @param rootUrl defines the root URL containing marble procedural texture information
  77332. * @returns a parsed Marble Procedural BABYLON.Texture
  77333. */
  77334. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  77335. }
  77336. }
  77337. declare module BABYLON {
  77338. /** @hidden */
  77339. export var normalMapProceduralTexturePixelShader: {
  77340. name: string;
  77341. shader: string;
  77342. };
  77343. }
  77344. declare module BABYLON {
  77345. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  77346. private _baseTexture;
  77347. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77348. updateShaderUniforms(): void;
  77349. render(useCameraPostProcess?: boolean): void;
  77350. resize(size: any, generateMipMaps: any): void;
  77351. get baseTexture(): BABYLON.Texture;
  77352. set baseTexture(texture: BABYLON.Texture);
  77353. /**
  77354. * Serializes this normal map procedural texture
  77355. * @returns a serialized normal map procedural texture object
  77356. */
  77357. serialize(): any;
  77358. /**
  77359. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  77360. * @param parsedTexture defines parsed texture data
  77361. * @param scene defines the current scene
  77362. * @param rootUrl defines the root URL containing normal map procedural texture information
  77363. * @returns a parsed Normal Map Procedural BABYLON.Texture
  77364. */
  77365. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  77366. }
  77367. }
  77368. declare module BABYLON {
  77369. /** @hidden */
  77370. export var perlinNoiseProceduralTexturePixelShader: {
  77371. name: string;
  77372. shader: string;
  77373. };
  77374. }
  77375. declare module BABYLON {
  77376. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  77377. time: number;
  77378. timeScale: number;
  77379. translationSpeed: number;
  77380. private _currentTranslation;
  77381. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77382. updateShaderUniforms(): void;
  77383. render(useCameraPostProcess?: boolean): void;
  77384. resize(size: any, generateMipMaps: any): void;
  77385. /**
  77386. * Serializes this perlin noise procedural texture
  77387. * @returns a serialized perlin noise procedural texture object
  77388. */
  77389. serialize(): any;
  77390. /**
  77391. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  77392. * @param parsedTexture defines parsed texture data
  77393. * @param scene defines the current scene
  77394. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  77395. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  77396. */
  77397. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  77398. }
  77399. }
  77400. declare module BABYLON {
  77401. /** @hidden */
  77402. export var roadProceduralTexturePixelShader: {
  77403. name: string;
  77404. shader: string;
  77405. };
  77406. }
  77407. declare module BABYLON {
  77408. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  77409. private _roadColor;
  77410. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77411. updateShaderUniforms(): void;
  77412. get roadColor(): BABYLON.Color3;
  77413. set roadColor(value: BABYLON.Color3);
  77414. /**
  77415. * Serializes this road procedural texture
  77416. * @returns a serialized road procedural texture object
  77417. */
  77418. serialize(): any;
  77419. /**
  77420. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  77421. * @param parsedTexture defines parsed texture data
  77422. * @param scene defines the current scene
  77423. * @param rootUrl defines the root URL containing road procedural texture information
  77424. * @returns a parsed Road Procedural BABYLON.Texture
  77425. */
  77426. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  77427. }
  77428. }
  77429. declare module BABYLON {
  77430. /** @hidden */
  77431. export var starfieldProceduralTexturePixelShader: {
  77432. name: string;
  77433. shader: string;
  77434. };
  77435. }
  77436. declare module BABYLON {
  77437. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  77438. private _time;
  77439. private _alpha;
  77440. private _beta;
  77441. private _zoom;
  77442. private _formuparam;
  77443. private _stepsize;
  77444. private _tile;
  77445. private _brightness;
  77446. private _darkmatter;
  77447. private _distfading;
  77448. private _saturation;
  77449. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77450. updateShaderUniforms(): void;
  77451. get time(): number;
  77452. set time(value: number);
  77453. get alpha(): number;
  77454. set alpha(value: number);
  77455. get beta(): number;
  77456. set beta(value: number);
  77457. get formuparam(): number;
  77458. set formuparam(value: number);
  77459. get stepsize(): number;
  77460. set stepsize(value: number);
  77461. get zoom(): number;
  77462. set zoom(value: number);
  77463. get tile(): number;
  77464. set tile(value: number);
  77465. get brightness(): number;
  77466. set brightness(value: number);
  77467. get darkmatter(): number;
  77468. set darkmatter(value: number);
  77469. get distfading(): number;
  77470. set distfading(value: number);
  77471. get saturation(): number;
  77472. set saturation(value: number);
  77473. /**
  77474. * Serializes this starfield procedural texture
  77475. * @returns a serialized starfield procedural texture object
  77476. */
  77477. serialize(): any;
  77478. /**
  77479. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  77480. * @param parsedTexture defines parsed texture data
  77481. * @param scene defines the current scene
  77482. * @param rootUrl defines the root URL containing startfield procedural texture information
  77483. * @returns a parsed Starfield Procedural BABYLON.Texture
  77484. */
  77485. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  77486. }
  77487. }
  77488. declare module BABYLON {
  77489. /** @hidden */
  77490. export var woodProceduralTexturePixelShader: {
  77491. name: string;
  77492. shader: string;
  77493. };
  77494. }
  77495. declare module BABYLON {
  77496. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  77497. private _ampScale;
  77498. private _woodColor;
  77499. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77500. updateShaderUniforms(): void;
  77501. get ampScale(): number;
  77502. set ampScale(value: number);
  77503. get woodColor(): BABYLON.Color3;
  77504. set woodColor(value: BABYLON.Color3);
  77505. /**
  77506. * Serializes this wood procedural texture
  77507. * @returns a serialized wood procedural texture object
  77508. */
  77509. serialize(): any;
  77510. /**
  77511. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  77512. * @param parsedTexture defines parsed texture data
  77513. * @param scene defines the current scene
  77514. * @param rootUrl defines the root URL containing wood procedural texture information
  77515. * @returns a parsed Wood Procedural BABYLON.Texture
  77516. */
  77517. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  77518. }
  77519. }