documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  688. static readonly GEQUAL: number;
  689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Multiplies the Vector3 coordinates by the float "scale"
  2433. * @param scale defines the multiplier factor
  2434. * @returns the current updated Vector3
  2435. */
  2436. scaleInPlace(scale: number): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns a new Vector3
  2441. */
  2442. scale(scale: number): Vector3;
  2443. /**
  2444. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2445. * @param scale defines the multiplier factor
  2446. * @param result defines the Vector3 object where to store the result
  2447. * @returns the current Vector3
  2448. */
  2449. scaleToRef(scale: number, result: Vector3): Vector3;
  2450. /**
  2451. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2452. * @param scale defines the scale factor
  2453. * @param result defines the Vector3 object where to store the result
  2454. * @returns the unmodified current Vector3
  2455. */
  2456. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2457. /**
  2458. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2459. * @param otherVector defines the second operand
  2460. * @returns true if both vectors are equals
  2461. */
  2462. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2465. * @param otherVector defines the second operand
  2466. * @param epsilon defines the minimal distance to define values as equals
  2467. * @returns true if both vectors are distant less than epsilon
  2468. */
  2469. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2470. /**
  2471. * Returns true if the current Vector3 coordinates equals the given floats
  2472. * @param x defines the x coordinate of the operand
  2473. * @param y defines the y coordinate of the operand
  2474. * @param z defines the z coordinate of the operand
  2475. * @returns true if both vectors are equals
  2476. */
  2477. equalsToFloats(x: number, y: number, z: number): boolean;
  2478. /**
  2479. * Multiplies the current Vector3 coordinates by the given ones
  2480. * @param otherVector defines the second operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2484. /**
  2485. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2486. * @param otherVector defines the second operand
  2487. * @returns the new Vector3
  2488. */
  2489. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2492. * @param otherVector defines the second operand
  2493. * @param result defines the Vector3 object where to store the result
  2494. * @returns the current Vector3
  2495. */
  2496. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2499. * @param x defines the x coordinate of the operand
  2500. * @param y defines the y coordinate of the operand
  2501. * @param z defines the z coordinate of the operand
  2502. * @returns the new Vector3
  2503. */
  2504. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Divides the current Vector3 coordinates by the given ones.
  2520. * @param otherVector defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. divideInPlace(otherVector: Vector3): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2526. * @param other defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2554. * Check if is non uniform within a certain amount of decimal places to account for this
  2555. * @param epsilon the amount the values can differ
  2556. * @returns if the the vector is non uniform to a certain number of decimal places
  2557. */
  2558. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2559. /**
  2560. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2561. */
  2562. get isNonUniform(): boolean;
  2563. /**
  2564. * Gets a new Vector3 from current Vector3 floored values
  2565. * @returns a new Vector3
  2566. */
  2567. floor(): Vector3;
  2568. /**
  2569. * Gets a new Vector3 from current Vector3 floored values
  2570. * @returns a new Vector3
  2571. */
  2572. fract(): Vector3;
  2573. /**
  2574. * Gets the length of the Vector3
  2575. * @returns the length of the Vector3
  2576. */
  2577. length(): number;
  2578. /**
  2579. * Gets the squared length of the Vector3
  2580. * @returns squared length of the Vector3
  2581. */
  2582. lengthSquared(): number;
  2583. /**
  2584. * Normalize the current Vector3.
  2585. * Please note that this is an in place operation.
  2586. * @returns the current updated Vector3
  2587. */
  2588. normalize(): Vector3;
  2589. /**
  2590. * Reorders the x y z properties of the vector in place
  2591. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2592. * @returns the current updated vector
  2593. */
  2594. reorderInPlace(order: string): this;
  2595. /**
  2596. * Rotates the vector around 0,0,0 by a quaternion
  2597. * @param quaternion the rotation quaternion
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2602. /**
  2603. * Rotates a vector around a given point
  2604. * @param quaternion the rotation quaternion
  2605. * @param point the point to rotate around
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2610. /**
  2611. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2612. * The cross product is then orthogonal to both current and "other"
  2613. * @param other defines the right operand
  2614. * @returns the cross product
  2615. */
  2616. cross(other: Vector3): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 with the given input length.
  2619. * Please note that this is an in place operation.
  2620. * @param len the length of the vector
  2621. * @returns the current updated Vector3
  2622. */
  2623. normalizeFromLength(len: number): Vector3;
  2624. /**
  2625. * Normalize the current Vector3 to a new vector
  2626. * @returns the new Vector3
  2627. */
  2628. normalizeToNew(): Vector3;
  2629. /**
  2630. * Normalize the current Vector3 to the reference
  2631. * @param reference define the Vector3 to update
  2632. * @returns the updated Vector3
  2633. */
  2634. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2635. /**
  2636. * Creates a new Vector3 copied from the current Vector3
  2637. * @returns the new Vector3
  2638. */
  2639. clone(): Vector3;
  2640. /**
  2641. * Copies the given vector coordinates to the current Vector3 ones
  2642. * @param source defines the source Vector3
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFromFloats(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. set(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given float to the current Vector3 coordinates
  2664. * @param v defines the x, y and z coordinates of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. setAll(v: number): Vector3;
  2668. /**
  2669. * Get the clip factor between two vectors
  2670. * @param vector0 defines the first operand
  2671. * @param vector1 defines the second operand
  2672. * @param axis defines the axis to use
  2673. * @param size defines the size along the axis
  2674. * @returns the clip factor
  2675. */
  2676. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2677. /**
  2678. * Get angle between two vectors
  2679. * @param vector0 angle between vector0 and vector1
  2680. * @param vector1 angle between vector0 and vector1
  2681. * @param normal direction of the normal
  2682. * @return the angle between vector0 and vector1
  2683. */
  2684. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2685. /**
  2686. * Returns a new Vector3 set from the index "offset" of the given array
  2687. * @param array defines the source array
  2688. * @param offset defines the offset in the source array
  2689. * @returns the new Vector3
  2690. */
  2691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2692. /**
  2693. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @returns the new Vector3
  2697. * @deprecated Please use FromArray instead.
  2698. */
  2699. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2700. /**
  2701. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @param result defines the Vector3 where to store the result
  2705. */
  2706. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2709. * @param array defines the source array
  2710. * @param offset defines the offset in the source array
  2711. * @param result defines the Vector3 where to store the result
  2712. * @deprecated Please use FromArrayToRef instead.
  2713. */
  2714. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the given floats.
  2717. * @param x defines the x coordinate of the source
  2718. * @param y defines the y coordinate of the source
  2719. * @param z defines the z coordinate of the source
  2720. * @param result defines the Vector3 where to store the result
  2721. */
  2722. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2723. /**
  2724. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2725. * @returns a new empty Vector3
  2726. */
  2727. static Zero(): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2730. * @returns a new unit Vector3
  2731. */
  2732. static One(): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2735. * @returns a new up Vector3
  2736. */
  2737. static Up(): Vector3;
  2738. /**
  2739. * Gets a up Vector3 that must not be updated
  2740. */
  2741. static get UpReadOnly(): DeepImmutable<Vector3>;
  2742. /**
  2743. * Gets a zero Vector3 that must not be updated
  2744. */
  2745. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2748. * @returns a new down Vector3
  2749. */
  2750. static Down(): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2753. * @returns a new forward Vector3
  2754. */
  2755. static Forward(): Vector3;
  2756. /**
  2757. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2758. * @returns a new forward Vector3
  2759. */
  2760. static Backward(): Vector3;
  2761. /**
  2762. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2763. * @returns a new right Vector3
  2764. */
  2765. static Right(): Vector3;
  2766. /**
  2767. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2768. * @returns a new left Vector3
  2769. */
  2770. static Left(): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @returns the transformed Vector3
  2777. */
  2778. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @param result defines the Vector3 where to store the result
  2785. */
  2786. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2789. * This method computes tranformed coordinates only, not transformed direction vectors
  2790. * @param x define the x coordinate of the source vector
  2791. * @param y define the y coordinate of the source vector
  2792. * @param z define the z coordinate of the source vector
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @returns the new Vector3
  2803. */
  2804. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @param result defines the Vector3 where to store the result
  2811. */
  2812. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param x define the x coordinate of the source vector
  2817. * @param y define the y coordinate of the source vector
  2818. * @param z define the z coordinate of the source vector
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2825. * @param value1 defines the first control point
  2826. * @param value2 defines the second control point
  2827. * @param value3 defines the third control point
  2828. * @param value4 defines the fourth control point
  2829. * @param amount defines the amount on the spline to use
  2830. * @returns the new Vector3
  2831. */
  2832. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2833. /**
  2834. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2835. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2836. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2837. * @param value defines the current value
  2838. * @param min defines the lower range value
  2839. * @param max defines the upper range value
  2840. * @returns the new Vector3
  2841. */
  2842. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2843. /**
  2844. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2853. /**
  2854. * Checks if a given vector is inside a specific range
  2855. * @param v defines the vector to test
  2856. * @param min defines the minimum range
  2857. * @param max defines the maximum range
  2858. */
  2859. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2860. /**
  2861. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2862. * @param value1 defines the first control point
  2863. * @param tangent1 defines the first tangent vector
  2864. * @param value2 defines the second control point
  2865. * @param tangent2 defines the second tangent vector
  2866. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2886. /**
  2887. * Returns the dot product (float) between the vectors "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the dot product
  2891. */
  2892. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the cross product
  2899. */
  2900. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2901. /**
  2902. * Sets the given vector "result" with the cross product of "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2909. /**
  2910. * Returns a new Vector3 as the normalization of the given vector
  2911. * @param vector defines the Vector3 to normalize
  2912. * @returns the new Vector3
  2913. */
  2914. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2915. /**
  2916. * Sets the given vector "result" with the normalization of the given first vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @param result defines the Vector3 where to store the result
  2919. */
  2920. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2921. /**
  2922. * Project a Vector3 onto screen space
  2923. * @param vector defines the Vector3 to project
  2924. * @param world defines the world matrix to use
  2925. * @param transform defines the transform (view x projection) matrix to use
  2926. * @param viewport defines the screen viewport to use
  2927. * @returns the new Vector3
  2928. */
  2929. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2930. /** @hidden */
  2931. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2932. /**
  2933. * Unproject from screen space to object space
  2934. * @param source defines the screen space Vector3 to use
  2935. * @param viewportWidth defines the current width of the viewport
  2936. * @param viewportHeight defines the current height of the viewport
  2937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @returns the new Vector3
  2940. */
  2941. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @param result defines the Vector3 where to store the result
  2962. */
  2963. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param sourceX defines the screen space x coordinate to use
  2967. * @param sourceY defines the screen space y coordinate to use
  2968. * @param sourceZ defines the screen space z coordinate to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Gets the minimal coordinate values between two Vector3
  2979. * @param left defines the first operand
  2980. * @param right defines the second operand
  2981. * @returns the new Vector3
  2982. */
  2983. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2984. /**
  2985. * Gets the maximal coordinate values between two Vector3
  2986. * @param left defines the first operand
  2987. * @param right defines the second operand
  2988. * @returns the new Vector3
  2989. */
  2990. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2991. /**
  2992. * Returns the distance between the vectors "value1" and "value2"
  2993. * @param value1 defines the first operand
  2994. * @param value2 defines the second operand
  2995. * @returns the distance
  2996. */
  2997. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2998. /**
  2999. * Returns the squared distance between the vectors "value1" and "value2"
  3000. * @param value1 defines the first operand
  3001. * @param value2 defines the second operand
  3002. * @returns the squared distance
  3003. */
  3004. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3005. /**
  3006. * Returns a new Vector3 located at the center between "value1" and "value2"
  3007. * @param value1 defines the first operand
  3008. * @param value2 defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3014. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3015. * to something in order to rotate it from its local system to the given target system
  3016. * Note: axis1, axis2 and axis3 are normalized during this operation
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @returns a new Vector3
  3021. */
  3022. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @param ref defines the Vector3 where to store the result
  3029. */
  3030. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3031. }
  3032. /**
  3033. * Vector4 class created for EulerAngle class conversion to Quaternion
  3034. */
  3035. export class Vector4 {
  3036. /** x value of the vector */
  3037. x: number;
  3038. /** y value of the vector */
  3039. y: number;
  3040. /** z value of the vector */
  3041. z: number;
  3042. /** w value of the vector */
  3043. w: number;
  3044. /**
  3045. * Creates a Vector4 object from the given floats.
  3046. * @param x x value of the vector
  3047. * @param y y value of the vector
  3048. * @param z z value of the vector
  3049. * @param w w value of the vector
  3050. */
  3051. constructor(
  3052. /** x value of the vector */
  3053. x: number,
  3054. /** y value of the vector */
  3055. y: number,
  3056. /** z value of the vector */
  3057. z: number,
  3058. /** w value of the vector */
  3059. w: number);
  3060. /**
  3061. * Returns the string with the Vector4 coordinates.
  3062. * @returns a string containing all the vector values
  3063. */
  3064. toString(): string;
  3065. /**
  3066. * Returns the string "Vector4".
  3067. * @returns "Vector4"
  3068. */
  3069. getClassName(): string;
  3070. /**
  3071. * Returns the Vector4 hash code.
  3072. * @returns a unique hash code
  3073. */
  3074. getHashCode(): number;
  3075. /**
  3076. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3077. * @returns the resulting array
  3078. */
  3079. asArray(): number[];
  3080. /**
  3081. * Populates the given array from the given index with the Vector4 coordinates.
  3082. * @param array array to populate
  3083. * @param index index of the array to start at (default: 0)
  3084. * @returns the Vector4.
  3085. */
  3086. toArray(array: FloatArray, index?: number): Vector4;
  3087. /**
  3088. * Adds the given vector to the current Vector4.
  3089. * @param otherVector the vector to add
  3090. * @returns the updated Vector4.
  3091. */
  3092. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3095. * @param otherVector the vector to add
  3096. * @returns the resulting vector
  3097. */
  3098. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Subtract in place the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @returns the updated Vector4.
  3110. */
  3111. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the new vector with the result
  3116. */
  3117. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to subtract
  3121. * @param result the vector to store the result
  3122. * @returns the current Vector4.
  3123. */
  3124. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. */
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. * @param x value to subtract
  3131. * @param y value to subtract
  3132. * @param z value to subtract
  3133. * @param w value to subtract
  3134. * @returns new vector containing the result
  3135. */
  3136. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3137. /**
  3138. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3139. * @param x value to subtract
  3140. * @param y value to subtract
  3141. * @param z value to subtract
  3142. * @param w value to subtract
  3143. * @param result the vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3147. /**
  3148. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3149. * @returns a new vector with the negated values
  3150. */
  3151. negate(): Vector4;
  3152. /**
  3153. * Multiplies the current Vector4 coordinates by scale (float).
  3154. * @param scale the number to scale with
  3155. * @returns the updated Vector4.
  3156. */
  3157. scaleInPlace(scale: number): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns a new vector with the result
  3162. */
  3163. scale(scale: number): Vector4;
  3164. /**
  3165. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @param result a vector to store the result in
  3168. * @returns the current Vector4.
  3169. */
  3170. scaleToRef(scale: number, result: Vector4): Vector4;
  3171. /**
  3172. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3173. * @param scale defines the scale factor
  3174. * @param result defines the Vector4 object where to store the result
  3175. * @returns the unmodified current Vector4
  3176. */
  3177. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3178. /**
  3179. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3180. * @param otherVector the vector to compare against
  3181. * @returns true if they are equal
  3182. */
  3183. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3186. * @param otherVector vector to compare against
  3187. * @param epsilon (Default: very small number)
  3188. * @returns true if they are equal
  3189. */
  3190. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3191. /**
  3192. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3193. * @param x x value to compare against
  3194. * @param y y value to compare against
  3195. * @param z z value to compare against
  3196. * @param w w value to compare against
  3197. * @returns true if equal
  3198. */
  3199. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3200. /**
  3201. * Multiplies in place the current Vector4 by the given one.
  3202. * @param otherVector vector to multiple with
  3203. * @returns the updated Vector4.
  3204. */
  3205. multiplyInPlace(otherVector: Vector4): Vector4;
  3206. /**
  3207. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns resulting new vector
  3210. */
  3211. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3212. /**
  3213. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @param result vector to store the result
  3216. * @returns the current Vector4.
  3217. */
  3218. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3221. * @param x x value multiply with
  3222. * @param y y value multiply with
  3223. * @param z z value multiply with
  3224. * @param w w value multiply with
  3225. * @returns resulting new vector
  3226. */
  3227. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3228. /**
  3229. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3230. * @param otherVector vector to devide with
  3231. * @returns resulting new vector
  3232. */
  3233. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @param result vector to store the result
  3238. * @returns the current Vector4.
  3239. */
  3240. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3241. /**
  3242. * Divides the current Vector3 coordinates by the given ones.
  3243. * @param otherVector vector to devide with
  3244. * @returns the updated Vector3.
  3245. */
  3246. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3249. * @param other defines the second operand
  3250. * @returns the current updated Vector4
  3251. */
  3252. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Gets a new Vector4 from current Vector4 floored values
  3261. * @returns a new Vector4
  3262. */
  3263. floor(): Vector4;
  3264. /**
  3265. * Gets a new Vector4 from current Vector3 floored values
  3266. * @returns a new Vector4
  3267. */
  3268. fract(): Vector4;
  3269. /**
  3270. * Returns the Vector4 length (float).
  3271. * @returns the length
  3272. */
  3273. length(): number;
  3274. /**
  3275. * Returns the Vector4 squared length (float).
  3276. * @returns the length squared
  3277. */
  3278. lengthSquared(): number;
  3279. /**
  3280. * Normalizes in place the Vector4.
  3281. * @returns the updated Vector4.
  3282. */
  3283. normalize(): Vector4;
  3284. /**
  3285. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3286. * @returns this converted to a new vector3
  3287. */
  3288. toVector3(): Vector3;
  3289. /**
  3290. * Returns a new Vector4 copied from the current one.
  3291. * @returns the new cloned vector
  3292. */
  3293. clone(): Vector4;
  3294. /**
  3295. * Updates the current Vector4 with the given one coordinates.
  3296. * @param source the source vector to copy from
  3297. * @returns the updated Vector4.
  3298. */
  3299. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the current Vector4 coordinates with the given floats.
  3302. * @param x float to copy from
  3303. * @param y float to copy from
  3304. * @param z float to copy from
  3305. * @param w float to copy from
  3306. * @returns the updated Vector4.
  3307. */
  3308. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3309. /**
  3310. * Updates the current Vector4 coordinates with the given floats.
  3311. * @param x float to set from
  3312. * @param y float to set from
  3313. * @param z float to set from
  3314. * @param w float to set from
  3315. * @returns the updated Vector4.
  3316. */
  3317. set(x: number, y: number, z: number, w: number): Vector4;
  3318. /**
  3319. * Copies the given float to the current Vector3 coordinates
  3320. * @param v defines the x, y, z and w coordinates of the operand
  3321. * @returns the current updated Vector3
  3322. */
  3323. setAll(v: number): Vector4;
  3324. /**
  3325. * Returns a new Vector4 set from the starting index of the given array.
  3326. * @param array the array to pull values from
  3327. * @param offset the offset into the array to start at
  3328. * @returns the new vector
  3329. */
  3330. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3331. /**
  3332. * Updates the given vector "result" from the starting index of the given array.
  3333. * @param array the array to pull values from
  3334. * @param offset the offset into the array to start at
  3335. * @param result the vector to store the result in
  3336. */
  3337. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3338. /**
  3339. * Updates the given vector "result" from the starting index of the given Float32Array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @param result the vector to store the result in
  3343. */
  3344. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3345. /**
  3346. * Updates the given vector "result" coordinates from the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @param result the vector to the floats in
  3352. */
  3353. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3354. /**
  3355. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3356. * @returns the new vector
  3357. */
  3358. static Zero(): Vector4;
  3359. /**
  3360. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3361. * @returns the new vector
  3362. */
  3363. static One(): Vector4;
  3364. /**
  3365. * Returns a new normalized Vector4 from the given one.
  3366. * @param vector the vector to normalize
  3367. * @returns the vector
  3368. */
  3369. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3370. /**
  3371. * Updates the given vector "result" from the normalization of the given one.
  3372. * @param vector the vector to normalize
  3373. * @param result the vector to store the result in
  3374. */
  3375. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3376. /**
  3377. * Returns a vector with the minimum values from the left and right vectors
  3378. * @param left left vector to minimize
  3379. * @param right right vector to minimize
  3380. * @returns a new vector with the minimum of the left and right vector values
  3381. */
  3382. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Returns a vector with the maximum values from the left and right vectors
  3385. * @param left left vector to maximize
  3386. * @param right right vector to maximize
  3387. * @returns a new vector with the maximum of the left and right vector values
  3388. */
  3389. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Returns the distance (float) between the vectors "value1" and "value2".
  3392. * @param value1 value to calulate the distance between
  3393. * @param value2 value to calulate the distance between
  3394. * @return the distance between the two vectors
  3395. */
  3396. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3397. /**
  3398. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3399. * @param value1 value to calulate the distance between
  3400. * @param value2 value to calulate the distance between
  3401. * @return the distance between the two vectors squared
  3402. */
  3403. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3404. /**
  3405. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the center between
  3407. * @param value2 value to calulate the center between
  3408. * @return the center between the two vectors
  3409. */
  3410. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3413. * This methods computes transformed normalized direction vectors only.
  3414. * @param vector the vector to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @returns the new vector
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3421. * This methods computes transformed normalized direction vectors only.
  3422. * @param vector the vector to transform
  3423. * @param transformation the transformation matrix to apply
  3424. * @param result the vector to store the result in
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3429. * This methods computes transformed normalized direction vectors only.
  3430. * @param x value to transform
  3431. * @param y value to transform
  3432. * @param z value to transform
  3433. * @param w value to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the results in
  3436. */
  3437. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Creates a new Vector4 from a Vector3
  3440. * @param source defines the source data
  3441. * @param w defines the 4th component (default is 0)
  3442. * @returns a new Vector4
  3443. */
  3444. static FromVector3(source: Vector3, w?: number): Vector4;
  3445. }
  3446. /**
  3447. * Class used to store quaternion data
  3448. * @see https://en.wikipedia.org/wiki/Quaternion
  3449. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3450. */
  3451. export class Quaternion {
  3452. /** defines the first component (0 by default) */
  3453. x: number;
  3454. /** defines the second component (0 by default) */
  3455. y: number;
  3456. /** defines the third component (0 by default) */
  3457. z: number;
  3458. /** defines the fourth component (1.0 by default) */
  3459. w: number;
  3460. /**
  3461. * Creates a new Quaternion from the given floats
  3462. * @param x defines the first component (0 by default)
  3463. * @param y defines the second component (0 by default)
  3464. * @param z defines the third component (0 by default)
  3465. * @param w defines the fourth component (1.0 by default)
  3466. */
  3467. constructor(
  3468. /** defines the first component (0 by default) */
  3469. x?: number,
  3470. /** defines the second component (0 by default) */
  3471. y?: number,
  3472. /** defines the third component (0 by default) */
  3473. z?: number,
  3474. /** defines the fourth component (1.0 by default) */
  3475. w?: number);
  3476. /**
  3477. * Gets a string representation for the current quaternion
  3478. * @returns a string with the Quaternion coordinates
  3479. */
  3480. toString(): string;
  3481. /**
  3482. * Gets the class name of the quaternion
  3483. * @returns the string "Quaternion"
  3484. */
  3485. getClassName(): string;
  3486. /**
  3487. * Gets a hash code for this quaternion
  3488. * @returns the quaternion hash code
  3489. */
  3490. getHashCode(): number;
  3491. /**
  3492. * Copy the quaternion to an array
  3493. * @returns a new array populated with 4 elements from the quaternion coordinates
  3494. */
  3495. asArray(): number[];
  3496. /**
  3497. * Check if two quaternions are equals
  3498. * @param otherQuaternion defines the second operand
  3499. * @return true if the current quaternion and the given one coordinates are strictly equals
  3500. */
  3501. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3502. /**
  3503. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3504. * @param otherQuaternion defines the other quaternion
  3505. * @param epsilon defines the minimal distance to consider equality
  3506. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3507. */
  3508. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3509. /**
  3510. * Clone the current quaternion
  3511. * @returns a new quaternion copied from the current one
  3512. */
  3513. clone(): Quaternion;
  3514. /**
  3515. * Copy a quaternion to the current one
  3516. * @param other defines the other quaternion
  3517. * @returns the updated current quaternion
  3518. */
  3519. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Updates the current quaternion with the given float coordinates
  3522. * @param x defines the x coordinate
  3523. * @param y defines the y coordinate
  3524. * @param z defines the z coordinate
  3525. * @param w defines the w coordinate
  3526. * @returns the updated current quaternion
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3529. /**
  3530. * Updates the current quaternion from the given float coordinates
  3531. * @param x defines the x coordinate
  3532. * @param y defines the y coordinate
  3533. * @param z defines the z coordinate
  3534. * @param w defines the w coordinate
  3535. * @returns the updated current quaternion
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Quaternion;
  3538. /**
  3539. * Adds two quaternions
  3540. * @param other defines the second operand
  3541. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3542. */
  3543. add(other: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Add a quaternion to the current one
  3546. * @param other defines the quaternion to add
  3547. * @returns the current quaternion
  3548. */
  3549. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Subtract two quaternions
  3552. * @param other defines the second operand
  3553. * @returns a new quaternion as the subtraction result of the given one from the current one
  3554. */
  3555. subtract(other: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies the current quaternion by a scale factor
  3558. * @param value defines the scale factor
  3559. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3560. */
  3561. scale(value: number): Quaternion;
  3562. /**
  3563. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3564. * @param scale defines the scale factor
  3565. * @param result defines the Quaternion object where to store the result
  3566. * @returns the unmodified current quaternion
  3567. */
  3568. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3569. /**
  3570. * Multiplies in place the current quaternion by a scale factor
  3571. * @param value defines the scale factor
  3572. * @returns the current modified quaternion
  3573. */
  3574. scaleInPlace(value: number): Quaternion;
  3575. /**
  3576. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3577. * @param scale defines the scale factor
  3578. * @param result defines the Quaternion object where to store the result
  3579. * @returns the unmodified current quaternion
  3580. */
  3581. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3582. /**
  3583. * Multiplies two quaternions
  3584. * @param q1 defines the second operand
  3585. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3586. */
  3587. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3588. /**
  3589. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3590. * @param q1 defines the second operand
  3591. * @param result defines the target quaternion
  3592. * @returns the current quaternion
  3593. */
  3594. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3595. /**
  3596. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3597. * @param q1 defines the second operand
  3598. * @returns the currentupdated quaternion
  3599. */
  3600. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3601. /**
  3602. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3603. * @param ref defines the target quaternion
  3604. * @returns the current quaternion
  3605. */
  3606. conjugateToRef(ref: Quaternion): Quaternion;
  3607. /**
  3608. * Conjugates in place (1-q) the current quaternion
  3609. * @returns the current updated quaternion
  3610. */
  3611. conjugateInPlace(): Quaternion;
  3612. /**
  3613. * Conjugates in place (1-q) the current quaternion
  3614. * @returns a new quaternion
  3615. */
  3616. conjugate(): Quaternion;
  3617. /**
  3618. * Gets length of current quaternion
  3619. * @returns the quaternion length (float)
  3620. */
  3621. length(): number;
  3622. /**
  3623. * Normalize in place the current quaternion
  3624. * @returns the current updated quaternion
  3625. */
  3626. normalize(): Quaternion;
  3627. /**
  3628. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3629. * @param order is a reserved parameter and is ignore for now
  3630. * @returns a new Vector3 containing the Euler angles
  3631. */
  3632. toEulerAngles(order?: string): Vector3;
  3633. /**
  3634. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3635. * @param result defines the vector which will be filled with the Euler angles
  3636. * @param order is a reserved parameter and is ignore for now
  3637. * @returns the current unchanged quaternion
  3638. */
  3639. toEulerAnglesToRef(result: Vector3): Quaternion;
  3640. /**
  3641. * Updates the given rotation matrix with the current quaternion values
  3642. * @param result defines the target matrix
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toRotationMatrix(result: Matrix): Quaternion;
  3646. /**
  3647. * Updates the current quaternion from the given rotation matrix values
  3648. * @param matrix defines the source matrix
  3649. * @returns the current updated quaternion
  3650. */
  3651. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3652. /**
  3653. * Creates a new quaternion from a rotation matrix
  3654. * @param matrix defines the source matrix
  3655. * @returns a new quaternion created from the given rotation matrix values
  3656. */
  3657. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Updates the given quaternion with the given rotation matrix values
  3660. * @param matrix defines the source matrix
  3661. * @param result defines the target quaternion
  3662. */
  3663. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3664. /**
  3665. * Returns the dot product (float) between the quaternions "left" and "right"
  3666. * @param left defines the left operand
  3667. * @param right defines the right operand
  3668. * @returns the dot product
  3669. */
  3670. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3671. /**
  3672. * Checks if the two quaternions are close to each other
  3673. * @param quat0 defines the first quaternion to check
  3674. * @param quat1 defines the second quaternion to check
  3675. * @returns true if the two quaternions are close to each other
  3676. */
  3677. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3678. /**
  3679. * Creates an empty quaternion
  3680. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3681. */
  3682. static Zero(): Quaternion;
  3683. /**
  3684. * Inverse a given quaternion
  3685. * @param q defines the source quaternion
  3686. * @returns a new quaternion as the inverted current quaternion
  3687. */
  3688. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @param result the quaternion the result will be stored in
  3693. * @returns the result quaternion
  3694. */
  3695. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates an identity quaternion
  3698. * @returns the identity quaternion
  3699. */
  3700. static Identity(): Quaternion;
  3701. /**
  3702. * Gets a boolean indicating if the given quaternion is identity
  3703. * @param quaternion defines the quaternion to check
  3704. * @returns true if the quaternion is identity
  3705. */
  3706. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3707. /**
  3708. * Creates a quaternion from a rotation around an axis
  3709. * @param axis defines the axis to use
  3710. * @param angle defines the angle to use
  3711. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3712. */
  3713. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3714. /**
  3715. * Creates a rotation around an axis and stores it into the given quaternion
  3716. * @param axis defines the axis to use
  3717. * @param angle defines the angle to use
  3718. * @param result defines the target quaternion
  3719. * @returns the target quaternion
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Creates a new quaternion from data stored into an array
  3724. * @param array defines the data source
  3725. * @param offset defines the offset in the source array where the data starts
  3726. * @returns a new quaternion
  3727. */
  3728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3729. /**
  3730. * Create a quaternion from Euler rotation angles
  3731. * @param x Pitch
  3732. * @param y Yaw
  3733. * @param z Roll
  3734. * @returns the new Quaternion
  3735. */
  3736. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3737. /**
  3738. * Updates a quaternion from Euler rotation angles
  3739. * @param x Pitch
  3740. * @param y Yaw
  3741. * @param z Roll
  3742. * @param result the quaternion to store the result
  3743. * @returns the updated quaternion
  3744. */
  3745. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation vector
  3748. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3749. * @returns the new Quaternion
  3750. */
  3751. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3752. /**
  3753. * Updates a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @param result the quaternion to store the result
  3756. * @returns the updated quaternion
  3757. */
  3758. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3761. * @param yaw defines the rotation around Y axis
  3762. * @param pitch defines the rotation around X axis
  3763. * @param roll defines the rotation around Z axis
  3764. * @returns the new quaternion
  3765. */
  3766. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3767. /**
  3768. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3769. * @param yaw defines the rotation around Y axis
  3770. * @param pitch defines the rotation around X axis
  3771. * @param roll defines the rotation around Z axis
  3772. * @param result defines the target quaternion
  3773. */
  3774. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3775. /**
  3776. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3777. * @param alpha defines the rotation around first axis
  3778. * @param beta defines the rotation around second axis
  3779. * @param gamma defines the rotation around third axis
  3780. * @returns the new quaternion
  3781. */
  3782. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3783. /**
  3784. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3785. * @param alpha defines the rotation around first axis
  3786. * @param beta defines the rotation around second axis
  3787. * @param gamma defines the rotation around third axis
  3788. * @param result defines the target quaternion
  3789. */
  3790. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3791. /**
  3792. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3793. * @param axis1 defines the first axis
  3794. * @param axis2 defines the second axis
  3795. * @param axis3 defines the third axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3799. /**
  3800. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3801. * @param axis1 defines the first axis
  3802. * @param axis2 defines the second axis
  3803. * @param axis3 defines the third axis
  3804. * @param ref defines the target quaternion
  3805. */
  3806. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3807. /**
  3808. * Interpolates between two quaternions
  3809. * @param left defines first quaternion
  3810. * @param right defines second quaternion
  3811. * @param amount defines the gradient to use
  3812. * @returns the new interpolated quaternion
  3813. */
  3814. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3815. /**
  3816. * Interpolates between two quaternions and stores it into a target quaternion
  3817. * @param left defines first quaternion
  3818. * @param right defines second quaternion
  3819. * @param amount defines the gradient to use
  3820. * @param result defines the target quaternion
  3821. */
  3822. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3823. /**
  3824. * Interpolate between two quaternions using Hermite interpolation
  3825. * @param value1 defines first quaternion
  3826. * @param tangent1 defines the incoming tangent
  3827. * @param value2 defines second quaternion
  3828. * @param tangent2 defines the outgoing tangent
  3829. * @param amount defines the target quaternion
  3830. * @returns the new interpolated quaternion
  3831. */
  3832. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3833. }
  3834. /**
  3835. * Class used to store matrix data (4x4)
  3836. */
  3837. export class Matrix {
  3838. private static _updateFlagSeed;
  3839. private static _identityReadOnly;
  3840. private _isIdentity;
  3841. private _isIdentityDirty;
  3842. private _isIdentity3x2;
  3843. private _isIdentity3x2Dirty;
  3844. /**
  3845. * Gets the update flag of the matrix which is an unique number for the matrix.
  3846. * It will be incremented every time the matrix data change.
  3847. * You can use it to speed the comparison between two versions of the same matrix.
  3848. */
  3849. updateFlag: number;
  3850. private readonly _m;
  3851. /**
  3852. * Gets the internal data of the matrix
  3853. */
  3854. get m(): DeepImmutable<Float32Array>;
  3855. /** @hidden */
  3856. _markAsUpdated(): void;
  3857. /** @hidden */
  3858. private _updateIdentityStatus;
  3859. /**
  3860. * Creates an empty matrix (filled with zeros)
  3861. */
  3862. constructor();
  3863. /**
  3864. * Check if the current matrix is identity
  3865. * @returns true is the matrix is the identity matrix
  3866. */
  3867. isIdentity(): boolean;
  3868. /**
  3869. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3870. * @returns true is the matrix is the identity matrix
  3871. */
  3872. isIdentityAs3x2(): boolean;
  3873. /**
  3874. * Gets the determinant of the matrix
  3875. * @returns the matrix determinant
  3876. */
  3877. determinant(): number;
  3878. /**
  3879. * Returns the matrix as a Float32Array
  3880. * @returns the matrix underlying array
  3881. */
  3882. toArray(): DeepImmutable<Float32Array>;
  3883. /**
  3884. * Returns the matrix as a Float32Array
  3885. * @returns the matrix underlying array.
  3886. */
  3887. asArray(): DeepImmutable<Float32Array>;
  3888. /**
  3889. * Inverts the current matrix in place
  3890. * @returns the current inverted matrix
  3891. */
  3892. invert(): Matrix;
  3893. /**
  3894. * Sets all the matrix elements to zero
  3895. * @returns the current matrix
  3896. */
  3897. reset(): Matrix;
  3898. /**
  3899. * Adds the current matrix with a second one
  3900. * @param other defines the matrix to add
  3901. * @returns a new matrix as the addition of the current matrix and the given one
  3902. */
  3903. add(other: DeepImmutable<Matrix>): Matrix;
  3904. /**
  3905. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3906. * @param other defines the matrix to add
  3907. * @param result defines the target matrix
  3908. * @returns the current matrix
  3909. */
  3910. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3911. /**
  3912. * Adds in place the given matrix to the current matrix
  3913. * @param other defines the second operand
  3914. * @returns the current updated matrix
  3915. */
  3916. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3917. /**
  3918. * Sets the given matrix to the current inverted Matrix
  3919. * @param other defines the target matrix
  3920. * @returns the unmodified current matrix
  3921. */
  3922. invertToRef(other: Matrix): Matrix;
  3923. /**
  3924. * add a value at the specified position in the current Matrix
  3925. * @param index the index of the value within the matrix. between 0 and 15.
  3926. * @param value the value to be added
  3927. * @returns the current updated matrix
  3928. */
  3929. addAtIndex(index: number, value: number): Matrix;
  3930. /**
  3931. * mutiply the specified position in the current Matrix by a value
  3932. * @param index the index of the value within the matrix. between 0 and 15.
  3933. * @param value the value to be added
  3934. * @returns the current updated matrix
  3935. */
  3936. multiplyAtIndex(index: number, value: number): Matrix;
  3937. /**
  3938. * Inserts the translation vector (using 3 floats) in the current matrix
  3939. * @param x defines the 1st component of the translation
  3940. * @param y defines the 2nd component of the translation
  3941. * @param z defines the 3rd component of the translation
  3942. * @returns the current updated matrix
  3943. */
  3944. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3945. /**
  3946. * Adds the translation vector (using 3 floats) in the current matrix
  3947. * @param x defines the 1st component of the translation
  3948. * @param y defines the 2nd component of the translation
  3949. * @param z defines the 3rd component of the translation
  3950. * @returns the current updated matrix
  3951. */
  3952. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3953. /**
  3954. * Inserts the translation vector in the current matrix
  3955. * @param vector3 defines the translation to insert
  3956. * @returns the current updated matrix
  3957. */
  3958. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3959. /**
  3960. * Gets the translation value of the current matrix
  3961. * @returns a new Vector3 as the extracted translation from the matrix
  3962. */
  3963. getTranslation(): Vector3;
  3964. /**
  3965. * Fill a Vector3 with the extracted translation from the matrix
  3966. * @param result defines the Vector3 where to store the translation
  3967. * @returns the current matrix
  3968. */
  3969. getTranslationToRef(result: Vector3): Matrix;
  3970. /**
  3971. * Remove rotation and scaling part from the matrix
  3972. * @returns the updated matrix
  3973. */
  3974. removeRotationAndScaling(): Matrix;
  3975. /**
  3976. * Multiply two matrices
  3977. * @param other defines the second operand
  3978. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3979. */
  3980. multiply(other: DeepImmutable<Matrix>): Matrix;
  3981. /**
  3982. * Copy the current matrix from the given one
  3983. * @param other defines the source matrix
  3984. * @returns the current updated matrix
  3985. */
  3986. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Populates the given array from the starting index with the current matrix values
  3989. * @param array defines the target array
  3990. * @param offset defines the offset in the target array where to start storing values
  3991. * @returns the current matrix
  3992. */
  3993. copyToArray(array: Float32Array, offset?: number): Matrix;
  3994. /**
  3995. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3996. * @param other defines the second operand
  3997. * @param result defines the matrix where to store the multiplication
  3998. * @returns the current matrix
  3999. */
  4000. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4001. /**
  4002. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4003. * @param other defines the second operand
  4004. * @param result defines the array where to store the multiplication
  4005. * @param offset defines the offset in the target array where to start storing values
  4006. * @returns the current matrix
  4007. */
  4008. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4009. /**
  4010. * Check equality between this matrix and a second one
  4011. * @param value defines the second matrix to compare
  4012. * @returns true is the current matrix and the given one values are strictly equal
  4013. */
  4014. equals(value: DeepImmutable<Matrix>): boolean;
  4015. /**
  4016. * Clone the current matrix
  4017. * @returns a new matrix from the current matrix
  4018. */
  4019. clone(): Matrix;
  4020. /**
  4021. * Returns the name of the current matrix class
  4022. * @returns the string "Matrix"
  4023. */
  4024. getClassName(): string;
  4025. /**
  4026. * Gets the hash code of the current matrix
  4027. * @returns the hash code
  4028. */
  4029. getHashCode(): number;
  4030. /**
  4031. * Decomposes the current Matrix into a translation, rotation and scaling components
  4032. * @param scale defines the scale vector3 given as a reference to update
  4033. * @param rotation defines the rotation quaternion given as a reference to update
  4034. * @param translation defines the translation vector3 given as a reference to update
  4035. * @returns true if operation was successful
  4036. */
  4037. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4038. /**
  4039. * Gets specific row of the matrix
  4040. * @param index defines the number of the row to get
  4041. * @returns the index-th row of the current matrix as a new Vector4
  4042. */
  4043. getRow(index: number): Nullable<Vector4>;
  4044. /**
  4045. * Sets the index-th row of the current matrix to the vector4 values
  4046. * @param index defines the number of the row to set
  4047. * @param row defines the target vector4
  4048. * @returns the updated current matrix
  4049. */
  4050. setRow(index: number, row: Vector4): Matrix;
  4051. /**
  4052. * Compute the transpose of the matrix
  4053. * @returns the new transposed matrix
  4054. */
  4055. transpose(): Matrix;
  4056. /**
  4057. * Compute the transpose of the matrix and store it in a given matrix
  4058. * @param result defines the target matrix
  4059. * @returns the current matrix
  4060. */
  4061. transposeToRef(result: Matrix): Matrix;
  4062. /**
  4063. * Sets the index-th row of the current matrix with the given 4 x float values
  4064. * @param index defines the row index
  4065. * @param x defines the x component to set
  4066. * @param y defines the y component to set
  4067. * @param z defines the z component to set
  4068. * @param w defines the w component to set
  4069. * @returns the updated current matrix
  4070. */
  4071. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4072. /**
  4073. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4074. * @param scale defines the scale factor
  4075. * @returns a new matrix
  4076. */
  4077. scale(scale: number): Matrix;
  4078. /**
  4079. * Scale the current matrix values by a factor to a given result matrix
  4080. * @param scale defines the scale factor
  4081. * @param result defines the matrix to store the result
  4082. * @returns the current matrix
  4083. */
  4084. scaleToRef(scale: number, result: Matrix): Matrix;
  4085. /**
  4086. * Scale the current matrix values by a factor and add the result to a given matrix
  4087. * @param scale defines the scale factor
  4088. * @param result defines the Matrix to store the result
  4089. * @returns the current matrix
  4090. */
  4091. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4092. /**
  4093. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4094. * @param ref matrix to store the result
  4095. */
  4096. toNormalMatrix(ref: Matrix): void;
  4097. /**
  4098. * Gets only rotation part of the current matrix
  4099. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4100. */
  4101. getRotationMatrix(): Matrix;
  4102. /**
  4103. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4104. * @param result defines the target matrix to store data to
  4105. * @returns the current matrix
  4106. */
  4107. getRotationMatrixToRef(result: Matrix): Matrix;
  4108. /**
  4109. * Toggles model matrix from being right handed to left handed in place and vice versa
  4110. */
  4111. toggleModelMatrixHandInPlace(): void;
  4112. /**
  4113. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleProjectionMatrixHandInPlace(): void;
  4116. /**
  4117. * Creates a matrix from an array
  4118. * @param array defines the source array
  4119. * @param offset defines an offset in the source array
  4120. * @returns a new Matrix set from the starting index of the given array
  4121. */
  4122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4123. /**
  4124. * Copy the content of an array into a given matrix
  4125. * @param array defines the source array
  4126. * @param offset defines an offset in the source array
  4127. * @param result defines the target matrix
  4128. */
  4129. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4130. /**
  4131. * Stores an array into a matrix after having multiplied each component by a given factor
  4132. * @param array defines the source array
  4133. * @param offset defines the offset in the source array
  4134. * @param scale defines the scaling factor
  4135. * @param result defines the target matrix
  4136. */
  4137. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4138. /**
  4139. * Gets an identity matrix that must not be updated
  4140. */
  4141. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4142. /**
  4143. * Stores a list of values (16) inside a given matrix
  4144. * @param initialM11 defines 1st value of 1st row
  4145. * @param initialM12 defines 2nd value of 1st row
  4146. * @param initialM13 defines 3rd value of 1st row
  4147. * @param initialM14 defines 4th value of 1st row
  4148. * @param initialM21 defines 1st value of 2nd row
  4149. * @param initialM22 defines 2nd value of 2nd row
  4150. * @param initialM23 defines 3rd value of 2nd row
  4151. * @param initialM24 defines 4th value of 2nd row
  4152. * @param initialM31 defines 1st value of 3rd row
  4153. * @param initialM32 defines 2nd value of 3rd row
  4154. * @param initialM33 defines 3rd value of 3rd row
  4155. * @param initialM34 defines 4th value of 3rd row
  4156. * @param initialM41 defines 1st value of 4th row
  4157. * @param initialM42 defines 2nd value of 4th row
  4158. * @param initialM43 defines 3rd value of 4th row
  4159. * @param initialM44 defines 4th value of 4th row
  4160. * @param result defines the target matrix
  4161. */
  4162. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4163. /**
  4164. * Creates new matrix from a list of values (16)
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @returns the new matrix
  4182. */
  4183. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4184. /**
  4185. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4186. * @param scale defines the scale vector3
  4187. * @param rotation defines the rotation quaternion
  4188. * @param translation defines the translation vector3
  4189. * @returns a new matrix
  4190. */
  4191. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4192. /**
  4193. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4194. * @param scale defines the scale vector3
  4195. * @param rotation defines the rotation quaternion
  4196. * @param translation defines the translation vector3
  4197. * @param result defines the target matrix
  4198. */
  4199. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4200. /**
  4201. * Creates a new identity matrix
  4202. * @returns a new identity matrix
  4203. */
  4204. static Identity(): Matrix;
  4205. /**
  4206. * Creates a new identity matrix and stores the result in a given matrix
  4207. * @param result defines the target matrix
  4208. */
  4209. static IdentityToRef(result: Matrix): void;
  4210. /**
  4211. * Creates a new zero matrix
  4212. * @returns a new zero matrix
  4213. */
  4214. static Zero(): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the X axis
  4217. * @param angle defines the angle (in radians) to use
  4218. * @return the new matrix
  4219. */
  4220. static RotationX(angle: number): Matrix;
  4221. /**
  4222. * Creates a new matrix as the invert of a given matrix
  4223. * @param source defines the source matrix
  4224. * @returns the new matrix
  4225. */
  4226. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationXToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Y axis
  4235. * @param angle defines the angle (in radians) to use
  4236. * @return the new matrix
  4237. */
  4238. static RotationY(angle: number): Matrix;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationYToRef(angle: number, result: Matrix): void;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Z axis
  4247. * @param angle defines the angle (in radians) to use
  4248. * @return the new matrix
  4249. */
  4250. static RotationZ(angle: number): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4253. * @param angle defines the angle (in radians) to use
  4254. * @param result defines the target matrix
  4255. */
  4256. static RotationZToRef(angle: number, result: Matrix): void;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the given axis
  4259. * @param axis defines the axis to use
  4260. * @param angle defines the angle (in radians) to use
  4261. * @return the new matrix
  4262. */
  4263. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4264. /**
  4265. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4266. * @param axis defines the axis to use
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4271. /**
  4272. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4273. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4274. * @param from defines the vector to align
  4275. * @param to defines the vector to align to
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4279. /**
  4280. * Creates a rotation matrix
  4281. * @param yaw defines the yaw angle in radians (Y axis)
  4282. * @param pitch defines the pitch angle in radians (X axis)
  4283. * @param roll defines the roll angle in radians (X axis)
  4284. * @returns the new rotation matrix
  4285. */
  4286. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4287. /**
  4288. * Creates a rotation matrix and stores it in a given matrix
  4289. * @param yaw defines the yaw angle in radians (Y axis)
  4290. * @param pitch defines the pitch angle in radians (X axis)
  4291. * @param roll defines the roll angle in radians (X axis)
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4295. /**
  4296. * Creates a scaling matrix
  4297. * @param x defines the scale factor on X axis
  4298. * @param y defines the scale factor on Y axis
  4299. * @param z defines the scale factor on Z axis
  4300. * @returns the new matrix
  4301. */
  4302. static Scaling(x: number, y: number, z: number): Matrix;
  4303. /**
  4304. * Creates a scaling matrix and stores it in a given matrix
  4305. * @param x defines the scale factor on X axis
  4306. * @param y defines the scale factor on Y axis
  4307. * @param z defines the scale factor on Z axis
  4308. * @param result defines the target matrix
  4309. */
  4310. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4311. /**
  4312. * Creates a translation matrix
  4313. * @param x defines the translation on X axis
  4314. * @param y defines the translation on Y axis
  4315. * @param z defines the translationon Z axis
  4316. * @returns the new matrix
  4317. */
  4318. static Translation(x: number, y: number, z: number): Matrix;
  4319. /**
  4320. * Creates a translation matrix and stores it in a given matrix
  4321. * @param x defines the translation on X axis
  4322. * @param y defines the translation on Y axis
  4323. * @param z defines the translationon Z axis
  4324. * @param result defines the target matrix
  4325. */
  4326. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4327. /**
  4328. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4329. * @param startValue defines the start value
  4330. * @param endValue defines the end value
  4331. * @param gradient defines the gradient factor
  4332. * @returns the new matrix
  4333. */
  4334. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4335. /**
  4336. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4337. * @param startValue defines the start value
  4338. * @param endValue defines the end value
  4339. * @param gradient defines the gradient factor
  4340. * @param result defines the Matrix object where to store data
  4341. */
  4342. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4343. /**
  4344. * Builds a new matrix whose values are computed by:
  4345. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4346. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4347. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4348. * @param startValue defines the first matrix
  4349. * @param endValue defines the second matrix
  4350. * @param gradient defines the gradient between the two matrices
  4351. * @returns the new matrix
  4352. */
  4353. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4354. /**
  4355. * Update a matrix to values which are computed by:
  4356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4359. * @param startValue defines the first matrix
  4360. * @param endValue defines the second matrix
  4361. * @param gradient defines the gradient between the two matrices
  4362. * @param result defines the target matrix
  4363. */
  4364. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4365. /**
  4366. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4367. * This function works in left handed mode
  4368. * @param eye defines the final position of the entity
  4369. * @param target defines where the entity should look at
  4370. * @param up defines the up vector for the entity
  4371. * @returns the new matrix
  4372. */
  4373. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4374. /**
  4375. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4376. * This function works in left handed mode
  4377. * @param eye defines the final position of the entity
  4378. * @param target defines where the entity should look at
  4379. * @param up defines the up vector for the entity
  4380. * @param result defines the target matrix
  4381. */
  4382. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4383. /**
  4384. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4385. * This function works in right handed mode
  4386. * @param eye defines the final position of the entity
  4387. * @param target defines where the entity should look at
  4388. * @param up defines the up vector for the entity
  4389. * @returns the new matrix
  4390. */
  4391. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4392. /**
  4393. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4394. * This function works in right handed mode
  4395. * @param eye defines the final position of the entity
  4396. * @param target defines where the entity should look at
  4397. * @param up defines the up vector for the entity
  4398. * @param result defines the target matrix
  4399. */
  4400. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4401. /**
  4402. * Create a left-handed orthographic projection matrix
  4403. * @param width defines the viewport width
  4404. * @param height defines the viewport height
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @returns a new matrix as a left-handed orthographic projection matrix
  4408. */
  4409. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4410. /**
  4411. * Store a left-handed orthographic projection to a given matrix
  4412. * @param width defines the viewport width
  4413. * @param height defines the viewport height
  4414. * @param znear defines the near clip plane
  4415. * @param zfar defines the far clip plane
  4416. * @param result defines the target matrix
  4417. */
  4418. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4419. /**
  4420. * Create a left-handed orthographic projection matrix
  4421. * @param left defines the viewport left coordinate
  4422. * @param right defines the viewport right coordinate
  4423. * @param bottom defines the viewport bottom coordinate
  4424. * @param top defines the viewport top coordinate
  4425. * @param znear defines the near clip plane
  4426. * @param zfar defines the far clip plane
  4427. * @returns a new matrix as a left-handed orthographic projection matrix
  4428. */
  4429. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4430. /**
  4431. * Stores a left-handed orthographic projection into a given matrix
  4432. * @param left defines the viewport left coordinate
  4433. * @param right defines the viewport right coordinate
  4434. * @param bottom defines the viewport bottom coordinate
  4435. * @param top defines the viewport top coordinate
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @param result defines the target matrix
  4439. */
  4440. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4441. /**
  4442. * Creates a right-handed orthographic projection matrix
  4443. * @param left defines the viewport left coordinate
  4444. * @param right defines the viewport right coordinate
  4445. * @param bottom defines the viewport bottom coordinate
  4446. * @param top defines the viewport top coordinate
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @returns a new matrix as a right-handed orthographic projection matrix
  4450. */
  4451. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4452. /**
  4453. * Stores a right-handed orthographic projection into a given matrix
  4454. * @param left defines the viewport left coordinate
  4455. * @param right defines the viewport right coordinate
  4456. * @param bottom defines the viewport bottom coordinate
  4457. * @param top defines the viewport top coordinate
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. */
  4462. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4463. /**
  4464. * Creates a left-handed perspective projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed perspective projection matrix
  4470. */
  4471. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Creates a left-handed perspective projection matrix
  4474. * @param fov defines the horizontal field of view
  4475. * @param aspect defines the aspect ratio
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @returns a new matrix as a left-handed perspective projection matrix
  4479. */
  4480. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4481. /**
  4482. * Stores a left-handed perspective projection into a given matrix
  4483. * @param fov defines the horizontal field of view
  4484. * @param aspect defines the aspect ratio
  4485. * @param znear defines the near clip plane
  4486. * @param zfar defines the far clip plane
  4487. * @param result defines the target matrix
  4488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4489. */
  4490. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4491. /**
  4492. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4493. * @param fov defines the horizontal field of view
  4494. * @param aspect defines the aspect ratio
  4495. * @param znear defines the near clip plane
  4496. * @param zfar not used as infinity is used as far clip
  4497. * @param result defines the target matrix
  4498. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4499. */
  4500. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4501. /**
  4502. * Creates a right-handed perspective projection matrix
  4503. * @param fov defines the horizontal field of view
  4504. * @param aspect defines the aspect ratio
  4505. * @param znear defines the near clip plane
  4506. * @param zfar defines the far clip plane
  4507. * @returns a new matrix as a right-handed perspective projection matrix
  4508. */
  4509. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4510. /**
  4511. * Stores a right-handed perspective projection into a given matrix
  4512. * @param fov defines the horizontal field of view
  4513. * @param aspect defines the aspect ratio
  4514. * @param znear defines the near clip plane
  4515. * @param zfar defines the far clip plane
  4516. * @param result defines the target matrix
  4517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4518. */
  4519. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4520. /**
  4521. * Stores a right-handed perspective projection into a given matrix
  4522. * @param fov defines the horizontal field of view
  4523. * @param aspect defines the aspect ratio
  4524. * @param znear defines the near clip plane
  4525. * @param zfar not used as infinity is used as far clip
  4526. * @param result defines the target matrix
  4527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4528. */
  4529. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4530. /**
  4531. * Stores a perspective projection for WebVR info a given matrix
  4532. * @param fov defines the field of view
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @param result defines the target matrix
  4536. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4537. */
  4538. static PerspectiveFovWebVRToRef(fov: {
  4539. upDegrees: number;
  4540. downDegrees: number;
  4541. leftDegrees: number;
  4542. rightDegrees: number;
  4543. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4544. /**
  4545. * Computes a complete transformation matrix
  4546. * @param viewport defines the viewport to use
  4547. * @param world defines the world matrix
  4548. * @param view defines the view matrix
  4549. * @param projection defines the projection matrix
  4550. * @param zmin defines the near clip plane
  4551. * @param zmax defines the far clip plane
  4552. * @returns the transformation matrix
  4553. */
  4554. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4555. /**
  4556. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4557. * @param matrix defines the matrix to use
  4558. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4559. */
  4560. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4561. /**
  4562. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Compute the transpose of a given matrix
  4569. * @param matrix defines the matrix to transpose
  4570. * @returns the new matrix
  4571. */
  4572. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4573. /**
  4574. * Compute the transpose of a matrix and store it in a target matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @param result defines the target matrix
  4577. */
  4578. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4579. /**
  4580. * Computes a reflection matrix from a plane
  4581. * @param plane defines the reflection plane
  4582. * @returns a new matrix
  4583. */
  4584. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4591. /**
  4592. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4593. * @param xaxis defines the value of the 1st axis
  4594. * @param yaxis defines the value of the 2nd axis
  4595. * @param zaxis defines the value of the 3rd axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4599. /**
  4600. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4601. * @param quat defines the quaternion to use
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4605. }
  4606. /**
  4607. * @hidden
  4608. */
  4609. export class TmpVectors {
  4610. static Vector2: Vector2[];
  4611. static Vector3: Vector3[];
  4612. static Vector4: Vector4[];
  4613. static Quaternion: Quaternion[];
  4614. static Matrix: Matrix[];
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /**
  4619. * Defines potential orientation for back face culling
  4620. */
  4621. export enum Orientation {
  4622. /**
  4623. * Clockwise
  4624. */
  4625. CW = 0,
  4626. /** Counter clockwise */
  4627. CCW = 1
  4628. }
  4629. /** Class used to represent a Bezier curve */
  4630. export class BezierCurve {
  4631. /**
  4632. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4633. * @param t defines the time
  4634. * @param x1 defines the left coordinate on X axis
  4635. * @param y1 defines the left coordinate on Y axis
  4636. * @param x2 defines the right coordinate on X axis
  4637. * @param y2 defines the right coordinate on Y axis
  4638. * @returns the interpolated value
  4639. */
  4640. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4641. }
  4642. /**
  4643. * Defines angle representation
  4644. */
  4645. export class Angle {
  4646. private _radians;
  4647. /**
  4648. * Creates an Angle object of "radians" radians (float).
  4649. * @param radians the angle in radians
  4650. */
  4651. constructor(radians: number);
  4652. /**
  4653. * Get value in degrees
  4654. * @returns the Angle value in degrees (float)
  4655. */
  4656. degrees(): number;
  4657. /**
  4658. * Get value in radians
  4659. * @returns the Angle value in radians (float)
  4660. */
  4661. radians(): number;
  4662. /**
  4663. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4664. * @param a defines first vector
  4665. * @param b defines second vector
  4666. * @returns a new Angle
  4667. */
  4668. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4669. /**
  4670. * Gets a new Angle object from the given float in radians
  4671. * @param radians defines the angle value in radians
  4672. * @returns a new Angle
  4673. */
  4674. static FromRadians(radians: number): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in degrees
  4677. * @param degrees defines the angle value in degrees
  4678. * @returns a new Angle
  4679. */
  4680. static FromDegrees(degrees: number): Angle;
  4681. }
  4682. /**
  4683. * This represents an arc in a 2d space.
  4684. */
  4685. export class Arc2 {
  4686. /** Defines the start point of the arc */
  4687. startPoint: Vector2;
  4688. /** Defines the mid point of the arc */
  4689. midPoint: Vector2;
  4690. /** Defines the end point of the arc */
  4691. endPoint: Vector2;
  4692. /**
  4693. * Defines the center point of the arc.
  4694. */
  4695. centerPoint: Vector2;
  4696. /**
  4697. * Defines the radius of the arc.
  4698. */
  4699. radius: number;
  4700. /**
  4701. * Defines the angle of the arc (from mid point to end point).
  4702. */
  4703. angle: Angle;
  4704. /**
  4705. * Defines the start angle of the arc (from start point to middle point).
  4706. */
  4707. startAngle: Angle;
  4708. /**
  4709. * Defines the orientation of the arc (clock wise/counter clock wise).
  4710. */
  4711. orientation: Orientation;
  4712. /**
  4713. * Creates an Arc object from the three given points : start, middle and end.
  4714. * @param startPoint Defines the start point of the arc
  4715. * @param midPoint Defines the midlle point of the arc
  4716. * @param endPoint Defines the end point of the arc
  4717. */
  4718. constructor(
  4719. /** Defines the start point of the arc */
  4720. startPoint: Vector2,
  4721. /** Defines the mid point of the arc */
  4722. midPoint: Vector2,
  4723. /** Defines the end point of the arc */
  4724. endPoint: Vector2);
  4725. }
  4726. /**
  4727. * Represents a 2D path made up of multiple 2D points
  4728. */
  4729. export class Path2 {
  4730. private _points;
  4731. private _length;
  4732. /**
  4733. * If the path start and end point are the same
  4734. */
  4735. closed: boolean;
  4736. /**
  4737. * Creates a Path2 object from the starting 2D coordinates x and y.
  4738. * @param x the starting points x value
  4739. * @param y the starting points y value
  4740. */
  4741. constructor(x: number, y: number);
  4742. /**
  4743. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4744. * @param x the added points x value
  4745. * @param y the added points y value
  4746. * @returns the updated Path2.
  4747. */
  4748. addLineTo(x: number, y: number): Path2;
  4749. /**
  4750. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4751. * @param midX middle point x value
  4752. * @param midY middle point y value
  4753. * @param endX end point x value
  4754. * @param endY end point y value
  4755. * @param numberOfSegments (default: 36)
  4756. * @returns the updated Path2.
  4757. */
  4758. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4759. /**
  4760. * Closes the Path2.
  4761. * @returns the Path2.
  4762. */
  4763. close(): Path2;
  4764. /**
  4765. * Gets the sum of the distance between each sequential point in the path
  4766. * @returns the Path2 total length (float).
  4767. */
  4768. length(): number;
  4769. /**
  4770. * Gets the points which construct the path
  4771. * @returns the Path2 internal array of points.
  4772. */
  4773. getPoints(): Vector2[];
  4774. /**
  4775. * Retreives the point at the distance aways from the starting point
  4776. * @param normalizedLengthPosition the length along the path to retreive the point from
  4777. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4778. */
  4779. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4780. /**
  4781. * Creates a new path starting from an x and y position
  4782. * @param x starting x value
  4783. * @param y starting y value
  4784. * @returns a new Path2 starting at the coordinates (x, y).
  4785. */
  4786. static StartingAt(x: number, y: number): Path2;
  4787. }
  4788. /**
  4789. * Represents a 3D path made up of multiple 3D points
  4790. */
  4791. export class Path3D {
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[];
  4796. private _curve;
  4797. private _distances;
  4798. private _tangents;
  4799. private _normals;
  4800. private _binormals;
  4801. private _raw;
  4802. private _alignTangentsWithPath;
  4803. private readonly _pointAtData;
  4804. /**
  4805. * new Path3D(path, normal, raw)
  4806. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4807. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4808. * @param path an array of Vector3, the curve axis of the Path3D
  4809. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4810. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4812. */
  4813. constructor(
  4814. /**
  4815. * an array of Vector3, the curve axis of the Path3D
  4816. */
  4817. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4818. /**
  4819. * Returns the Path3D array of successive Vector3 designing its curve.
  4820. * @returns the Path3D array of successive Vector3 designing its curve.
  4821. */
  4822. getCurve(): Vector3[];
  4823. /**
  4824. * Returns the Path3D array of successive Vector3 designing its curve.
  4825. * @returns the Path3D array of successive Vector3 designing its curve.
  4826. */
  4827. getPoints(): Vector3[];
  4828. /**
  4829. * @returns the computed length (float) of the path.
  4830. */
  4831. length(): number;
  4832. /**
  4833. * Returns an array populated with tangent vectors on each Path3D curve point.
  4834. * @returns an array populated with tangent vectors on each Path3D curve point.
  4835. */
  4836. getTangents(): Vector3[];
  4837. /**
  4838. * Returns an array populated with normal vectors on each Path3D curve point.
  4839. * @returns an array populated with normal vectors on each Path3D curve point.
  4840. */
  4841. getNormals(): Vector3[];
  4842. /**
  4843. * Returns an array populated with binormal vectors on each Path3D curve point.
  4844. * @returns an array populated with binormal vectors on each Path3D curve point.
  4845. */
  4846. getBinormals(): Vector3[];
  4847. /**
  4848. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. */
  4851. getDistances(): number[];
  4852. /**
  4853. * Returns an interpolated point along this path
  4854. * @param position the position of the point along this path, from 0.0 to 1.0
  4855. * @returns a new Vector3 as the point
  4856. */
  4857. getPointAt(position: number): Vector3;
  4858. /**
  4859. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4862. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4863. */
  4864. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4865. /**
  4866. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4867. * @param position the position of the point along this path, from 0.0 to 1.0
  4868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4869. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4870. */
  4871. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4872. /**
  4873. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4874. * @param position the position of the point along this path, from 0.0 to 1.0
  4875. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4876. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4877. */
  4878. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4879. /**
  4880. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4883. */
  4884. getDistanceAt(position: number): number;
  4885. /**
  4886. * Returns the array index of the previous point of an interpolated point along this path
  4887. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4888. * @returns the array index
  4889. */
  4890. getPreviousPointIndexAt(position: number): number;
  4891. /**
  4892. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the sub position
  4895. */
  4896. getSubPositionAt(position: number): number;
  4897. /**
  4898. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4899. * @param target the vector of which to get the closest position to
  4900. * @returns the position of the closest virtual point on this path to the target vector
  4901. */
  4902. getClosestPositionTo(target: Vector3): number;
  4903. /**
  4904. * Returns a sub path (slice) of this path
  4905. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4906. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @returns a sub path (slice) of this path
  4908. */
  4909. slice(start?: number, end?: number): Path3D;
  4910. /**
  4911. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4912. * @param path path which all values are copied into the curves points
  4913. * @param firstNormal which should be projected onto the curve
  4914. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4915. * @returns the same object updated.
  4916. */
  4917. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4918. private _compute;
  4919. private _getFirstNonNullVector;
  4920. private _getLastNonNullVector;
  4921. private _normalVector;
  4922. /**
  4923. * Updates the point at data for an interpolated point along this curve
  4924. * @param position the position of the point along this curve, from 0.0 to 1.0
  4925. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4926. * @returns the (updated) point at data
  4927. */
  4928. private _updatePointAtData;
  4929. /**
  4930. * Updates the point at data from the specified parameters
  4931. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4932. * @param point the interpolated point
  4933. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4934. */
  4935. private _setPointAtData;
  4936. /**
  4937. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4938. */
  4939. private _updateInterpolationMatrix;
  4940. }
  4941. /**
  4942. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4943. * A Curve3 is designed from a series of successive Vector3.
  4944. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4945. */
  4946. export class Curve3 {
  4947. private _points;
  4948. private _length;
  4949. /**
  4950. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4951. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4952. * @param v1 (Vector3) the control point
  4953. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4954. * @param nbPoints (integer) the wanted number of points in the curve
  4955. * @returns the created Curve3
  4956. */
  4957. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4958. /**
  4959. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4960. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4961. * @param v1 (Vector3) the first control point
  4962. * @param v2 (Vector3) the second control point
  4963. * @param v3 (Vector3) the end point of the Cubic Bezier
  4964. * @param nbPoints (integer) the wanted number of points in the curve
  4965. * @returns the created Curve3
  4966. */
  4967. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4968. /**
  4969. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4970. * @param p1 (Vector3) the origin point of the Hermite Spline
  4971. * @param t1 (Vector3) the tangent vector at the origin point
  4972. * @param p2 (Vector3) the end point of the Hermite Spline
  4973. * @param t2 (Vector3) the tangent vector at the end point
  4974. * @param nbPoints (integer) the wanted number of points in the curve
  4975. * @returns the created Curve3
  4976. */
  4977. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4978. /**
  4979. * Returns a Curve3 object along a CatmullRom Spline curve :
  4980. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4981. * @param nbPoints (integer) the wanted number of points between each curve control points
  4982. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4986. /**
  4987. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4988. * A Curve3 is designed from a series of successive Vector3.
  4989. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4990. * @param points points which make up the curve
  4991. */
  4992. constructor(points: Vector3[]);
  4993. /**
  4994. * @returns the Curve3 stored array of successive Vector3
  4995. */
  4996. getPoints(): Vector3[];
  4997. /**
  4998. * @returns the computed length (float) of the curve.
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5003. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5004. * curveA and curveB keep unchanged.
  5005. * @param curve the curve to continue from this curve
  5006. * @returns the newly constructed curve
  5007. */
  5008. continue(curve: DeepImmutable<Curve3>): Curve3;
  5009. private _computeLength;
  5010. }
  5011. }
  5012. declare module BABYLON {
  5013. /**
  5014. * This represents the main contract an easing function should follow.
  5015. * Easing functions are used throughout the animation system.
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export interface IEasingFunction {
  5019. /**
  5020. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5021. * of the easing function.
  5022. * The link below provides some of the most common examples of easing functions.
  5023. * @see https://easings.net/
  5024. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5025. * @returns the corresponding value on the curve defined by the easing function
  5026. */
  5027. ease(gradient: number): number;
  5028. }
  5029. /**
  5030. * Base class used for every default easing function.
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class EasingFunction implements IEasingFunction {
  5034. /**
  5035. * Interpolation follows the mathematical formula associated with the easing function.
  5036. */
  5037. static readonly EASINGMODE_EASEIN: number;
  5038. /**
  5039. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5040. */
  5041. static readonly EASINGMODE_EASEOUT: number;
  5042. /**
  5043. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5044. */
  5045. static readonly EASINGMODE_EASEINOUT: number;
  5046. private _easingMode;
  5047. /**
  5048. * Sets the easing mode of the current function.
  5049. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5050. */
  5051. setEasingMode(easingMode: number): void;
  5052. /**
  5053. * Gets the current easing mode.
  5054. * @returns the easing mode
  5055. */
  5056. getEasingMode(): number;
  5057. /**
  5058. * @hidden
  5059. */
  5060. easeInCore(gradient: number): number;
  5061. /**
  5062. * Given an input gradient between 0 and 1, this returns the corresponding value
  5063. * of the easing function.
  5064. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5065. * @returns the corresponding value on the curve defined by the easing function
  5066. */
  5067. ease(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a circle shape (see link below).
  5071. * @see https://easings.net/#easeInCirc
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class CircleEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a ease back shape (see link below).
  5080. * @see https://easings.net/#easeInBack
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BackEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the amplitude of the function */
  5085. amplitude: number;
  5086. /**
  5087. * Instantiates a back ease easing
  5088. * @see https://easings.net/#easeInBack
  5089. * @param amplitude Defines the amplitude of the function
  5090. */
  5091. constructor(
  5092. /** Defines the amplitude of the function */
  5093. amplitude?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a bouncing shape (see link below).
  5099. * @see https://easings.net/#easeInBounce
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class BounceEase extends EasingFunction implements IEasingFunction {
  5103. /** Defines the number of bounces */
  5104. bounces: number;
  5105. /** Defines the amplitude of the bounce */
  5106. bounciness: number;
  5107. /**
  5108. * Instantiates a bounce easing
  5109. * @see https://easings.net/#easeInBounce
  5110. * @param bounces Defines the number of bounces
  5111. * @param bounciness Defines the amplitude of the bounce
  5112. */
  5113. constructor(
  5114. /** Defines the number of bounces */
  5115. bounces?: number,
  5116. /** Defines the amplitude of the bounce */
  5117. bounciness?: number);
  5118. /** @hidden */
  5119. easeInCore(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a power of 3 shape (see link below).
  5123. * @see https://easings.net/#easeInCubic
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CubicEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an elastic shape (see link below).
  5132. * @see https://easings.net/#easeInElastic
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the number of oscillations*/
  5137. oscillations: number;
  5138. /** Defines the amplitude of the oscillations*/
  5139. springiness: number;
  5140. /**
  5141. * Instantiates an elastic easing function
  5142. * @see https://easings.net/#easeInElastic
  5143. * @param oscillations Defines the number of oscillations
  5144. * @param springiness Defines the amplitude of the oscillations
  5145. */
  5146. constructor(
  5147. /** Defines the number of oscillations*/
  5148. oscillations?: number,
  5149. /** Defines the amplitude of the oscillations*/
  5150. springiness?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with an exponential shape (see link below).
  5156. * @see https://easings.net/#easeInExpo
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the exponent of the function */
  5161. exponent: number;
  5162. /**
  5163. * Instantiates an exponential easing function
  5164. * @see https://easings.net/#easeInExpo
  5165. * @param exponent Defines the exponent of the function
  5166. */
  5167. constructor(
  5168. /** Defines the exponent of the function */
  5169. exponent?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class PowerEase extends EasingFunction implements IEasingFunction {
  5179. /** Defines the power of the function */
  5180. power: number;
  5181. /**
  5182. * Instantiates an power base easing function
  5183. * @see https://easings.net/#easeInQuad
  5184. * @param power Defines the power of the function
  5185. */
  5186. constructor(
  5187. /** Defines the power of the function */
  5188. power?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with a power of 2 shape (see link below).
  5194. * @see https://easings.net/#easeInQuad
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power of 4 shape (see link below).
  5203. * @see https://easings.net/#easeInQuart
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with a power of 5 shape (see link below).
  5212. * @see https://easings.net/#easeInQuint
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5216. /** @hidden */
  5217. easeInCore(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a sin shape (see link below).
  5221. * @see https://easings.net/#easeInSine
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class SineEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a bezier shape (see link below).
  5230. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the x component of the start tangent in the bezier curve */
  5235. x1: number;
  5236. /** Defines the y component of the start tangent in the bezier curve */
  5237. y1: number;
  5238. /** Defines the x component of the end tangent in the bezier curve */
  5239. x2: number;
  5240. /** Defines the y component of the end tangent in the bezier curve */
  5241. y2: number;
  5242. /**
  5243. * Instantiates a bezier function
  5244. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5245. * @param x1 Defines the x component of the start tangent in the bezier curve
  5246. * @param y1 Defines the y component of the start tangent in the bezier curve
  5247. * @param x2 Defines the x component of the end tangent in the bezier curve
  5248. * @param y2 Defines the y component of the end tangent in the bezier curve
  5249. */
  5250. constructor(
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1?: number,
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1?: number,
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2?: number,
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2?: number);
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. }
  5263. declare module BABYLON {
  5264. /**
  5265. * Class used to hold a RBG color
  5266. */
  5267. export class Color3 {
  5268. /**
  5269. * Defines the red component (between 0 and 1, default is 0)
  5270. */
  5271. r: number;
  5272. /**
  5273. * Defines the green component (between 0 and 1, default is 0)
  5274. */
  5275. g: number;
  5276. /**
  5277. * Defines the blue component (between 0 and 1, default is 0)
  5278. */
  5279. b: number;
  5280. /**
  5281. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5282. * @param r defines the red component (between 0 and 1, default is 0)
  5283. * @param g defines the green component (between 0 and 1, default is 0)
  5284. * @param b defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. constructor(
  5287. /**
  5288. * Defines the red component (between 0 and 1, default is 0)
  5289. */
  5290. r?: number,
  5291. /**
  5292. * Defines the green component (between 0 and 1, default is 0)
  5293. */
  5294. g?: number,
  5295. /**
  5296. * Defines the blue component (between 0 and 1, default is 0)
  5297. */
  5298. b?: number);
  5299. /**
  5300. * Creates a string with the Color3 current values
  5301. * @returns the string representation of the Color3 object
  5302. */
  5303. toString(): string;
  5304. /**
  5305. * Returns the string "Color3"
  5306. * @returns "Color3"
  5307. */
  5308. getClassName(): string;
  5309. /**
  5310. * Compute the Color3 hash code
  5311. * @returns an unique number that can be used to hash Color3 objects
  5312. */
  5313. getHashCode(): number;
  5314. /**
  5315. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5316. * @param array defines the array where to store the r,g,b components
  5317. * @param index defines an optional index in the target array to define where to start storing values
  5318. * @returns the current Color3 object
  5319. */
  5320. toArray(array: FloatArray, index?: number): Color3;
  5321. /**
  5322. * Returns a new Color4 object from the current Color3 and the given alpha
  5323. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5324. * @returns a new Color4 object
  5325. */
  5326. toColor4(alpha?: number): Color4;
  5327. /**
  5328. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5329. * @returns the new array
  5330. */
  5331. asArray(): number[];
  5332. /**
  5333. * Returns the luminance value
  5334. * @returns a float value
  5335. */
  5336. toLuminance(): number;
  5337. /**
  5338. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5339. * @param otherColor defines the second operand
  5340. * @returns the new Color3 object
  5341. */
  5342. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5343. /**
  5344. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5345. * @param otherColor defines the second operand
  5346. * @param result defines the Color3 object where to store the result
  5347. * @returns the current Color3
  5348. */
  5349. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5350. /**
  5351. * Determines equality between Color3 objects
  5352. * @param otherColor defines the second operand
  5353. * @returns true if the rgb values are equal to the given ones
  5354. */
  5355. equals(otherColor: DeepImmutable<Color3>): boolean;
  5356. /**
  5357. * Determines equality between the current Color3 object and a set of r,b,g values
  5358. * @param r defines the red component to check
  5359. * @param g defines the green component to check
  5360. * @param b defines the blue component to check
  5361. * @returns true if the rgb values are equal to the given ones
  5362. */
  5363. equalsFloats(r: number, g: number, b: number): boolean;
  5364. /**
  5365. * Multiplies in place each rgb value by scale
  5366. * @param scale defines the scaling factor
  5367. * @returns the updated Color3
  5368. */
  5369. scale(scale: number): Color3;
  5370. /**
  5371. * Multiplies the rgb values by scale and stores the result into "result"
  5372. * @param scale defines the scaling factor
  5373. * @param result defines the Color3 object where to store the result
  5374. * @returns the unmodified current Color3
  5375. */
  5376. scaleToRef(scale: number, result: Color3): Color3;
  5377. /**
  5378. * Scale the current Color3 values by a factor and add the result to a given Color3
  5379. * @param scale defines the scale factor
  5380. * @param result defines color to store the result into
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Clamps the rgb values by the min and max values and stores the result into "result"
  5386. * @param min defines minimum clamping value (default is 0)
  5387. * @param max defines maximum clamping value (default is 1)
  5388. * @param result defines color to store the result into
  5389. * @returns the original Color3
  5390. */
  5391. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5392. /**
  5393. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5394. * @param otherColor defines the second operand
  5395. * @returns the new Color3
  5396. */
  5397. add(otherColor: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5400. * @param otherColor defines the second operand
  5401. * @param result defines Color3 object to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5405. /**
  5406. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5407. * @param otherColor defines the second operand
  5408. * @returns the new Color3
  5409. */
  5410. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5413. * @param otherColor defines the second operand
  5414. * @param result defines Color3 object to store the result into
  5415. * @returns the unmodified current Color3
  5416. */
  5417. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5418. /**
  5419. * Copy the current object
  5420. * @returns a new Color3 copied the current one
  5421. */
  5422. clone(): Color3;
  5423. /**
  5424. * Copies the rgb values from the source in the current Color3
  5425. * @param source defines the source Color3 object
  5426. * @returns the updated Color3 object
  5427. */
  5428. copyFrom(source: DeepImmutable<Color3>): Color3;
  5429. /**
  5430. * Updates the Color3 rgb values from the given floats
  5431. * @param r defines the red component to read from
  5432. * @param g defines the green component to read from
  5433. * @param b defines the blue component to read from
  5434. * @returns the current Color3 object
  5435. */
  5436. copyFromFloats(r: number, g: number, b: number): Color3;
  5437. /**
  5438. * Updates the Color3 rgb values from the given floats
  5439. * @param r defines the red component to read from
  5440. * @param g defines the green component to read from
  5441. * @param b defines the blue component to read from
  5442. * @returns the current Color3 object
  5443. */
  5444. set(r: number, g: number, b: number): Color3;
  5445. /**
  5446. * Compute the Color3 hexadecimal code as a string
  5447. * @returns a string containing the hexadecimal representation of the Color3 object
  5448. */
  5449. toHexString(): string;
  5450. /**
  5451. * Computes a new Color3 converted from the current one to linear space
  5452. * @returns a new Color3 object
  5453. */
  5454. toLinearSpace(): Color3;
  5455. /**
  5456. * Converts current color in rgb space to HSV values
  5457. * @returns a new color3 representing the HSV values
  5458. */
  5459. toHSV(): Color3;
  5460. /**
  5461. * Converts current color in rgb space to HSV values
  5462. * @param result defines the Color3 where to store the HSV values
  5463. */
  5464. toHSVToRef(result: Color3): void;
  5465. /**
  5466. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5467. * @param convertedColor defines the Color3 object where to store the linear space version
  5468. * @returns the unmodified Color3
  5469. */
  5470. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to gamma space
  5473. * @returns a new Color3 object
  5474. */
  5475. toGammaSpace(): Color3;
  5476. /**
  5477. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5478. * @param convertedColor defines the Color3 object where to store the gamma space version
  5479. * @returns the unmodified Color3
  5480. */
  5481. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5482. private static _BlackReadOnly;
  5483. /**
  5484. * Convert Hue, saturation and value to a Color3 (RGB)
  5485. * @param hue defines the hue
  5486. * @param saturation defines the saturation
  5487. * @param value defines the value
  5488. * @param result defines the Color3 where to store the RGB values
  5489. */
  5490. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5491. /**
  5492. * Creates a new Color3 from the string containing valid hexadecimal values
  5493. * @param hex defines a string containing valid hexadecimal values
  5494. * @returns a new Color3 object
  5495. */
  5496. static FromHexString(hex: string): Color3;
  5497. /**
  5498. * Creates a new Color3 from the starting index of the given array
  5499. * @param array defines the source array
  5500. * @param offset defines an offset in the source array
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5504. /**
  5505. * Creates a new Color3 from integer values (< 256)
  5506. * @param r defines the red component to read from (value between 0 and 255)
  5507. * @param g defines the green component to read from (value between 0 and 255)
  5508. * @param b defines the blue component to read from (value between 0 and 255)
  5509. * @returns a new Color3 object
  5510. */
  5511. static FromInts(r: number, g: number, b: number): Color3;
  5512. /**
  5513. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5514. * @param start defines the start Color3 value
  5515. * @param end defines the end Color3 value
  5516. * @param amount defines the gradient value between start and end
  5517. * @returns a new Color3 object
  5518. */
  5519. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5520. /**
  5521. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5522. * @param left defines the start value
  5523. * @param right defines the end value
  5524. * @param amount defines the gradient factor
  5525. * @param result defines the Color3 object where to store the result
  5526. */
  5527. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5528. /**
  5529. * Returns a Color3 value containing a red color
  5530. * @returns a new Color3 object
  5531. */
  5532. static Red(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a green color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Green(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a blue color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Blue(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a black color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Black(): Color3;
  5548. /**
  5549. * Gets a Color3 value containing a black color that must not be updated
  5550. */
  5551. static get BlackReadOnly(): DeepImmutable<Color3>;
  5552. /**
  5553. * Returns a Color3 value containing a white color
  5554. * @returns a new Color3 object
  5555. */
  5556. static White(): Color3;
  5557. /**
  5558. * Returns a Color3 value containing a purple color
  5559. * @returns a new Color3 object
  5560. */
  5561. static Purple(): Color3;
  5562. /**
  5563. * Returns a Color3 value containing a magenta color
  5564. * @returns a new Color3 object
  5565. */
  5566. static Magenta(): Color3;
  5567. /**
  5568. * Returns a Color3 value containing a yellow color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Yellow(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a gray color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Gray(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a teal color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Teal(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a random color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Random(): Color3;
  5587. }
  5588. /**
  5589. * Class used to hold a RBGA color
  5590. */
  5591. export class Color4 {
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r: number;
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g: number;
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b: number;
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a: number;
  5608. /**
  5609. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5610. * @param r defines the red component (between 0 and 1, default is 0)
  5611. * @param g defines the green component (between 0 and 1, default is 0)
  5612. * @param b defines the blue component (between 0 and 1, default is 0)
  5613. * @param a defines the alpha component (between 0 and 1, default is 1)
  5614. */
  5615. constructor(
  5616. /**
  5617. * Defines the red component (between 0 and 1, default is 0)
  5618. */
  5619. r?: number,
  5620. /**
  5621. * Defines the green component (between 0 and 1, default is 0)
  5622. */
  5623. g?: number,
  5624. /**
  5625. * Defines the blue component (between 0 and 1, default is 0)
  5626. */
  5627. b?: number,
  5628. /**
  5629. * Defines the alpha component (between 0 and 1, default is 1)
  5630. */
  5631. a?: number);
  5632. /**
  5633. * Adds in place the given Color4 values to the current Color4 object
  5634. * @param right defines the second operand
  5635. * @returns the current updated Color4 object
  5636. */
  5637. addInPlace(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5640. * @returns the new array
  5641. */
  5642. asArray(): number[];
  5643. /**
  5644. * Stores from the starting index in the given array the Color4 successive values
  5645. * @param array defines the array where to store the r,g,b components
  5646. * @param index defines an optional index in the target array to define where to start storing values
  5647. * @returns the current Color4 object
  5648. */
  5649. toArray(array: number[], index?: number): Color4;
  5650. /**
  5651. * Determines equality between Color4 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgba values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color4>): boolean;
  5656. /**
  5657. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5658. * @param right defines the second operand
  5659. * @returns a new Color4 object
  5660. */
  5661. add(right: DeepImmutable<Color4>): Color4;
  5662. /**
  5663. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5664. * @param right defines the second operand
  5665. * @returns a new Color4 object
  5666. */
  5667. subtract(right: DeepImmutable<Color4>): Color4;
  5668. /**
  5669. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5670. * @param right defines the second operand
  5671. * @param result defines the Color4 object where to store the result
  5672. * @returns the current Color4 object
  5673. */
  5674. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5675. /**
  5676. * Creates a new Color4 with the current Color4 values multiplied by scale
  5677. * @param scale defines the scaling factor to apply
  5678. * @returns a new Color4 object
  5679. */
  5680. scale(scale: number): Color4;
  5681. /**
  5682. * Multiplies the current Color4 values by scale and stores the result in "result"
  5683. * @param scale defines the scaling factor to apply
  5684. * @param result defines the Color4 object where to store the result
  5685. * @returns the current unmodified Color4
  5686. */
  5687. scaleToRef(scale: number, result: Color4): Color4;
  5688. /**
  5689. * Scale the current Color4 values by a factor and add the result to a given Color4
  5690. * @param scale defines the scale factor
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the unmodified current Color4
  5693. */
  5694. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Clamps the rgb values by the min and max values and stores the result into "result"
  5697. * @param min defines minimum clamping value (default is 0)
  5698. * @param max defines maximum clamping value (default is 1)
  5699. * @param result defines color to store the result into.
  5700. * @returns the cuurent Color4
  5701. */
  5702. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5703. /**
  5704. * Multipy an Color4 value by another and return a new Color4 object
  5705. * @param color defines the Color4 value to multiply by
  5706. * @returns a new Color4 object
  5707. */
  5708. multiply(color: Color4): Color4;
  5709. /**
  5710. * Multipy a Color4 value by another and push the result in a reference value
  5711. * @param color defines the Color4 value to multiply by
  5712. * @param result defines the Color4 to fill the result in
  5713. * @returns the result Color4
  5714. */
  5715. multiplyToRef(color: Color4, result: Color4): Color4;
  5716. /**
  5717. * Creates a string with the Color4 current values
  5718. * @returns the string representation of the Color4 object
  5719. */
  5720. toString(): string;
  5721. /**
  5722. * Returns the string "Color4"
  5723. * @returns "Color4"
  5724. */
  5725. getClassName(): string;
  5726. /**
  5727. * Compute the Color4 hash code
  5728. * @returns an unique number that can be used to hash Color4 objects
  5729. */
  5730. getHashCode(): number;
  5731. /**
  5732. * Creates a new Color4 copied from the current one
  5733. * @returns a new Color4 object
  5734. */
  5735. clone(): Color4;
  5736. /**
  5737. * Copies the given Color4 values into the current one
  5738. * @param source defines the source Color4 object
  5739. * @returns the current updated Color4 object
  5740. */
  5741. copyFrom(source: Color4): Color4;
  5742. /**
  5743. * Copies the given float values into the current one
  5744. * @param r defines the red component to read from
  5745. * @param g defines the green component to read from
  5746. * @param b defines the blue component to read from
  5747. * @param a defines the alpha component to read from
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. set(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Compute the Color4 hexadecimal code as a string
  5762. * @returns a string containing the hexadecimal representation of the Color4 object
  5763. */
  5764. toHexString(): string;
  5765. /**
  5766. * Computes a new Color4 converted from the current one to linear space
  5767. * @returns a new Color4 object
  5768. */
  5769. toLinearSpace(): Color4;
  5770. /**
  5771. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5772. * @param convertedColor defines the Color4 object where to store the linear space version
  5773. * @returns the unmodified Color4
  5774. */
  5775. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5776. /**
  5777. * Computes a new Color4 converted from the current one to gamma space
  5778. * @returns a new Color4 object
  5779. */
  5780. toGammaSpace(): Color4;
  5781. /**
  5782. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5783. * @param convertedColor defines the Color4 object where to store the gamma space version
  5784. * @returns the unmodified Color4
  5785. */
  5786. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5787. /**
  5788. * Creates a new Color4 from the string containing valid hexadecimal values
  5789. * @param hex defines a string containing valid hexadecimal values
  5790. * @returns a new Color4 object
  5791. */
  5792. static FromHexString(hex: string): Color4;
  5793. /**
  5794. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5795. * @param left defines the start value
  5796. * @param right defines the end value
  5797. * @param amount defines the gradient factor
  5798. * @returns a new Color4 object
  5799. */
  5800. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5801. /**
  5802. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5803. * @param left defines the start value
  5804. * @param right defines the end value
  5805. * @param amount defines the gradient factor
  5806. * @param result defines the Color4 object where to store data
  5807. */
  5808. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5809. /**
  5810. * Creates a new Color4 from a Color3 and an alpha value
  5811. * @param color3 defines the source Color3 to read from
  5812. * @param alpha defines the alpha component (1.0 by default)
  5813. * @returns a new Color4 object
  5814. */
  5815. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5816. /**
  5817. * Creates a new Color4 from the starting index element of the given array
  5818. * @param array defines the source array to read from
  5819. * @param offset defines the offset in the source array
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5823. /**
  5824. * Creates a new Color3 from integer values (< 256)
  5825. * @param r defines the red component to read from (value between 0 and 255)
  5826. * @param g defines the green component to read from (value between 0 and 255)
  5827. * @param b defines the blue component to read from (value between 0 and 255)
  5828. * @param a defines the alpha component to read from (value between 0 and 255)
  5829. * @returns a new Color3 object
  5830. */
  5831. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5832. /**
  5833. * Check the content of a given array and convert it to an array containing RGBA data
  5834. * If the original array was already containing count * 4 values then it is returned directly
  5835. * @param colors defines the array to check
  5836. * @param count defines the number of RGBA data to expect
  5837. * @returns an array containing count * 4 values (RGBA)
  5838. */
  5839. static CheckColors4(colors: number[], count: number): number[];
  5840. }
  5841. /**
  5842. * @hidden
  5843. */
  5844. export class TmpColors {
  5845. static Color3: Color3[];
  5846. static Color4: Color4[];
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Defines an interface which represents an animation key frame
  5852. */
  5853. export interface IAnimationKey {
  5854. /**
  5855. * Frame of the key frame
  5856. */
  5857. frame: number;
  5858. /**
  5859. * Value at the specifies key frame
  5860. */
  5861. value: any;
  5862. /**
  5863. * The input tangent for the cubic hermite spline
  5864. */
  5865. inTangent?: any;
  5866. /**
  5867. * The output tangent for the cubic hermite spline
  5868. */
  5869. outTangent?: any;
  5870. /**
  5871. * The animation interpolation type
  5872. */
  5873. interpolation?: AnimationKeyInterpolation;
  5874. }
  5875. /**
  5876. * Enum for the animation key frame interpolation type
  5877. */
  5878. export enum AnimationKeyInterpolation {
  5879. /**
  5880. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5881. */
  5882. STEP = 1
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Represents the range of an animation
  5888. */
  5889. export class AnimationRange {
  5890. /**The name of the animation range**/
  5891. name: string;
  5892. /**The starting frame of the animation */
  5893. from: number;
  5894. /**The ending frame of the animation*/
  5895. to: number;
  5896. /**
  5897. * Initializes the range of an animation
  5898. * @param name The name of the animation range
  5899. * @param from The starting frame of the animation
  5900. * @param to The ending frame of the animation
  5901. */
  5902. constructor(
  5903. /**The name of the animation range**/
  5904. name: string,
  5905. /**The starting frame of the animation */
  5906. from: number,
  5907. /**The ending frame of the animation*/
  5908. to: number);
  5909. /**
  5910. * Makes a copy of the animation range
  5911. * @returns A copy of the animation range
  5912. */
  5913. clone(): AnimationRange;
  5914. }
  5915. }
  5916. declare module BABYLON {
  5917. /**
  5918. * Composed of a frame, and an action function
  5919. */
  5920. export class AnimationEvent {
  5921. /** The frame for which the event is triggered **/
  5922. frame: number;
  5923. /** The event to perform when triggered **/
  5924. action: (currentFrame: number) => void;
  5925. /** Specifies if the event should be triggered only once**/
  5926. onlyOnce?: boolean | undefined;
  5927. /**
  5928. * Specifies if the animation event is done
  5929. */
  5930. isDone: boolean;
  5931. /**
  5932. * Initializes the animation event
  5933. * @param frame The frame for which the event is triggered
  5934. * @param action The event to perform when triggered
  5935. * @param onlyOnce Specifies if the event should be triggered only once
  5936. */
  5937. constructor(
  5938. /** The frame for which the event is triggered **/
  5939. frame: number,
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void,
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined);
  5944. /** @hidden */
  5945. _clone(): AnimationEvent;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Interface used to define a behavior
  5951. */
  5952. export interface Behavior<T> {
  5953. /** gets or sets behavior's name */
  5954. name: string;
  5955. /**
  5956. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5957. */
  5958. init(): void;
  5959. /**
  5960. * Called when the behavior is attached to a target
  5961. * @param target defines the target where the behavior is attached to
  5962. */
  5963. attach(target: T): void;
  5964. /**
  5965. * Called when the behavior is detached from its target
  5966. */
  5967. detach(): void;
  5968. }
  5969. /**
  5970. * Interface implemented by classes supporting behaviors
  5971. */
  5972. export interface IBehaviorAware<T> {
  5973. /**
  5974. * Attach a behavior
  5975. * @param behavior defines the behavior to attach
  5976. * @returns the current host
  5977. */
  5978. addBehavior(behavior: Behavior<T>): T;
  5979. /**
  5980. * Remove a behavior from the current object
  5981. * @param behavior defines the behavior to detach
  5982. * @returns the current host
  5983. */
  5984. removeBehavior(behavior: Behavior<T>): T;
  5985. /**
  5986. * Gets a behavior using its name to search
  5987. * @param name defines the name to search
  5988. * @returns the behavior or null if not found
  5989. */
  5990. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5991. }
  5992. }
  5993. declare module BABYLON {
  5994. /**
  5995. * Defines an array and its length.
  5996. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5997. */
  5998. export interface ISmartArrayLike<T> {
  5999. /**
  6000. * The data of the array.
  6001. */
  6002. data: Array<T>;
  6003. /**
  6004. * The active length of the array.
  6005. */
  6006. length: number;
  6007. }
  6008. /**
  6009. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6010. */
  6011. export class SmartArray<T> implements ISmartArrayLike<T> {
  6012. /**
  6013. * The full set of data from the array.
  6014. */
  6015. data: Array<T>;
  6016. /**
  6017. * The active length of the array.
  6018. */
  6019. length: number;
  6020. protected _id: number;
  6021. /**
  6022. * Instantiates a Smart Array.
  6023. * @param capacity defines the default capacity of the array.
  6024. */
  6025. constructor(capacity: number);
  6026. /**
  6027. * Pushes a value at the end of the active data.
  6028. * @param value defines the object to push in the array.
  6029. */
  6030. push(value: T): void;
  6031. /**
  6032. * Iterates over the active data and apply the lambda to them.
  6033. * @param func defines the action to apply on each value.
  6034. */
  6035. forEach(func: (content: T) => void): void;
  6036. /**
  6037. * Sorts the full sets of data.
  6038. * @param compareFn defines the comparison function to apply.
  6039. */
  6040. sort(compareFn: (a: T, b: T) => number): void;
  6041. /**
  6042. * Resets the active data to an empty array.
  6043. */
  6044. reset(): void;
  6045. /**
  6046. * Releases all the data from the array as well as the array.
  6047. */
  6048. dispose(): void;
  6049. /**
  6050. * Concats the active data with a given array.
  6051. * @param array defines the data to concatenate with.
  6052. */
  6053. concat(array: any): void;
  6054. /**
  6055. * Returns the position of a value in the active data.
  6056. * @param value defines the value to find the index for
  6057. * @returns the index if found in the active data otherwise -1
  6058. */
  6059. indexOf(value: T): number;
  6060. /**
  6061. * Returns whether an element is part of the active data.
  6062. * @param value defines the value to look for
  6063. * @returns true if found in the active data otherwise false
  6064. */
  6065. contains(value: T): boolean;
  6066. private static _GlobalId;
  6067. }
  6068. /**
  6069. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6070. * The data in this array can only be present once
  6071. */
  6072. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6073. private _duplicateId;
  6074. /**
  6075. * Pushes a value at the end of the active data.
  6076. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6077. * @param value defines the object to push in the array.
  6078. */
  6079. push(value: T): void;
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * If the data is already present, it won t be added again
  6083. * @param value defines the object to push in the array.
  6084. * @returns true if added false if it was already present
  6085. */
  6086. pushNoDuplicate(value: T): boolean;
  6087. /**
  6088. * Resets the active data to an empty array.
  6089. */
  6090. reset(): void;
  6091. /**
  6092. * Concats the active data with a given array.
  6093. * This ensures no dupplicate will be present in the result.
  6094. * @param array defines the data to concatenate with.
  6095. */
  6096. concatWithNoDuplicate(array: any): void;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * @ignore
  6102. * This is a list of all the different input types that are available in the application.
  6103. * Fo instance: ArcRotateCameraGamepadInput...
  6104. */
  6105. export var CameraInputTypes: {};
  6106. /**
  6107. * This is the contract to implement in order to create a new input class.
  6108. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6109. */
  6110. export interface ICameraInput<TCamera extends Camera> {
  6111. /**
  6112. * Defines the camera the input is attached to.
  6113. */
  6114. camera: Nullable<TCamera>;
  6115. /**
  6116. * Gets the class name of the current intput.
  6117. * @returns the class name
  6118. */
  6119. getClassName(): string;
  6120. /**
  6121. * Get the friendly name associated with the input class.
  6122. * @returns the input friendly name
  6123. */
  6124. getSimpleName(): string;
  6125. /**
  6126. * Attach the input controls to a specific dom element to get the input from.
  6127. * @param element Defines the element the controls should be listened from
  6128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6129. */
  6130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6131. /**
  6132. * Detach the current controls from the specified dom element.
  6133. * @param element Defines the element to stop listening the inputs from
  6134. */
  6135. detachControl(element: Nullable<HTMLElement>): void;
  6136. /**
  6137. * Update the current camera state depending on the inputs that have been used this frame.
  6138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6139. */
  6140. checkInputs?: () => void;
  6141. }
  6142. /**
  6143. * Represents a map of input types to input instance or input index to input instance.
  6144. */
  6145. export interface CameraInputsMap<TCamera extends Camera> {
  6146. /**
  6147. * Accessor to the input by input type.
  6148. */
  6149. [name: string]: ICameraInput<TCamera>;
  6150. /**
  6151. * Accessor to the input by input index.
  6152. */
  6153. [idx: number]: ICameraInput<TCamera>;
  6154. }
  6155. /**
  6156. * This represents the input manager used within a camera.
  6157. * It helps dealing with all the different kind of input attached to a camera.
  6158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6159. */
  6160. export class CameraInputsManager<TCamera extends Camera> {
  6161. /**
  6162. * Defines the list of inputs attahed to the camera.
  6163. */
  6164. attached: CameraInputsMap<TCamera>;
  6165. /**
  6166. * Defines the dom element the camera is collecting inputs from.
  6167. * This is null if the controls have not been attached.
  6168. */
  6169. attachedElement: Nullable<HTMLElement>;
  6170. /**
  6171. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6172. */
  6173. noPreventDefault: boolean;
  6174. /**
  6175. * Defined the camera the input manager belongs to.
  6176. */
  6177. camera: TCamera;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs: () => void;
  6183. /**
  6184. * Instantiate a new Camera Input Manager.
  6185. * @param camera Defines the camera the input manager blongs to
  6186. */
  6187. constructor(camera: TCamera);
  6188. /**
  6189. * Add an input method to a camera
  6190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6191. * @param input camera input method
  6192. */
  6193. add(input: ICameraInput<TCamera>): void;
  6194. /**
  6195. * Remove a specific input method from a camera
  6196. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6197. * @param inputToRemove camera input method
  6198. */
  6199. remove(inputToRemove: ICameraInput<TCamera>): void;
  6200. /**
  6201. * Remove a specific input type from a camera
  6202. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6203. * @param inputType the type of the input to remove
  6204. */
  6205. removeByType(inputType: string): void;
  6206. private _addCheckInputs;
  6207. /**
  6208. * Attach the input controls to the currently attached dom element to listen the events from.
  6209. * @param input Defines the input to attach
  6210. */
  6211. attachInput(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6214. * @param element Defines the dom element to collect the events from
  6215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6216. */
  6217. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6218. /**
  6219. * Detach the current manager inputs controls from a specific dom element.
  6220. * @param element Defines the dom element to collect the events from
  6221. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6222. */
  6223. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6224. /**
  6225. * Rebuild the dynamic inputCheck function from the current list of
  6226. * defined inputs in the manager.
  6227. */
  6228. rebuildInputCheck(): void;
  6229. /**
  6230. * Remove all attached input methods from a camera
  6231. */
  6232. clear(): void;
  6233. /**
  6234. * Serialize the current input manager attached to a camera.
  6235. * This ensures than once parsed,
  6236. * the input associated to the camera will be identical to the current ones
  6237. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6238. */
  6239. serialize(serializedCamera: any): void;
  6240. /**
  6241. * Parses an input manager serialized JSON to restore the previous list of inputs
  6242. * and states associated to a camera.
  6243. * @param parsedCamera Defines the JSON to parse
  6244. */
  6245. parse(parsedCamera: any): void;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. /**
  6250. * Class used to store data that will be store in GPU memory
  6251. */
  6252. export class Buffer {
  6253. private _engine;
  6254. private _buffer;
  6255. /** @hidden */
  6256. _data: Nullable<DataArray>;
  6257. private _updatable;
  6258. private _instanced;
  6259. private _divisor;
  6260. /**
  6261. * Gets the byte stride.
  6262. */
  6263. readonly byteStride: number;
  6264. /**
  6265. * Constructor
  6266. * @param engine the engine
  6267. * @param data the data to use for this buffer
  6268. * @param updatable whether the data is updatable
  6269. * @param stride the stride (optional)
  6270. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6271. * @param instanced whether the buffer is instanced (optional)
  6272. * @param useBytes set to true if the stride in in bytes (optional)
  6273. * @param divisor sets an optional divisor for instances (1 by default)
  6274. */
  6275. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6276. /**
  6277. * Create a new VertexBuffer based on the current buffer
  6278. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6279. * @param offset defines offset in the buffer (0 by default)
  6280. * @param size defines the size in floats of attributes (position is 3 for instance)
  6281. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6282. * @param instanced defines if the vertex buffer contains indexed data
  6283. * @param useBytes defines if the offset and stride are in bytes *
  6284. * @param divisor sets an optional divisor for instances (1 by default)
  6285. * @returns the new vertex buffer
  6286. */
  6287. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6288. /**
  6289. * Gets a boolean indicating if the Buffer is updatable?
  6290. * @returns true if the buffer is updatable
  6291. */
  6292. isUpdatable(): boolean;
  6293. /**
  6294. * Gets current buffer's data
  6295. * @returns a DataArray or null
  6296. */
  6297. getData(): Nullable<DataArray>;
  6298. /**
  6299. * Gets underlying native buffer
  6300. * @returns underlying native buffer
  6301. */
  6302. getBuffer(): Nullable<DataBuffer>;
  6303. /**
  6304. * Gets the stride in float32 units (i.e. byte stride / 4).
  6305. * May not be an integer if the byte stride is not divisible by 4.
  6306. * @returns the stride in float32 units
  6307. * @deprecated Please use byteStride instead.
  6308. */
  6309. getStrideSize(): number;
  6310. /**
  6311. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6312. * @param data defines the data to store
  6313. */
  6314. create(data?: Nullable<DataArray>): void;
  6315. /** @hidden */
  6316. _rebuild(): void;
  6317. /**
  6318. * Update current buffer data
  6319. * @param data defines the data to store
  6320. */
  6321. update(data: DataArray): void;
  6322. /**
  6323. * Updates the data directly.
  6324. * @param data the new data
  6325. * @param offset the new offset
  6326. * @param vertexCount the vertex count (optional)
  6327. * @param useBytes set to true if the offset is in bytes
  6328. */
  6329. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6330. /**
  6331. * Release all resources
  6332. */
  6333. dispose(): void;
  6334. }
  6335. /**
  6336. * Specialized buffer used to store vertex data
  6337. */
  6338. export class VertexBuffer {
  6339. /** @hidden */
  6340. _buffer: Buffer;
  6341. private _kind;
  6342. private _size;
  6343. private _ownsBuffer;
  6344. private _instanced;
  6345. private _instanceDivisor;
  6346. /**
  6347. * The byte type.
  6348. */
  6349. static readonly BYTE: number;
  6350. /**
  6351. * The unsigned byte type.
  6352. */
  6353. static readonly UNSIGNED_BYTE: number;
  6354. /**
  6355. * The short type.
  6356. */
  6357. static readonly SHORT: number;
  6358. /**
  6359. * The unsigned short type.
  6360. */
  6361. static readonly UNSIGNED_SHORT: number;
  6362. /**
  6363. * The integer type.
  6364. */
  6365. static readonly INT: number;
  6366. /**
  6367. * The unsigned integer type.
  6368. */
  6369. static readonly UNSIGNED_INT: number;
  6370. /**
  6371. * The float type.
  6372. */
  6373. static readonly FLOAT: number;
  6374. /**
  6375. * Gets or sets the instance divisor when in instanced mode
  6376. */
  6377. get instanceDivisor(): number;
  6378. set instanceDivisor(value: number);
  6379. /**
  6380. * Gets the byte stride.
  6381. */
  6382. readonly byteStride: number;
  6383. /**
  6384. * Gets the byte offset.
  6385. */
  6386. readonly byteOffset: number;
  6387. /**
  6388. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6389. */
  6390. readonly normalized: boolean;
  6391. /**
  6392. * Gets the data type of each component in the array.
  6393. */
  6394. readonly type: number;
  6395. /**
  6396. * Constructor
  6397. * @param engine the engine
  6398. * @param data the data to use for this vertex buffer
  6399. * @param kind the vertex buffer kind
  6400. * @param updatable whether the data is updatable
  6401. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6402. * @param stride the stride (optional)
  6403. * @param instanced whether the buffer is instanced (optional)
  6404. * @param offset the offset of the data (optional)
  6405. * @param size the number of components (optional)
  6406. * @param type the type of the component (optional)
  6407. * @param normalized whether the data contains normalized data (optional)
  6408. * @param useBytes set to true if stride and offset are in bytes (optional)
  6409. * @param divisor defines the instance divisor to use (1 by default)
  6410. */
  6411. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6412. /** @hidden */
  6413. _rebuild(): void;
  6414. /**
  6415. * Returns the kind of the VertexBuffer (string)
  6416. * @returns a string
  6417. */
  6418. getKind(): string;
  6419. /**
  6420. * Gets a boolean indicating if the VertexBuffer is updatable?
  6421. * @returns true if the buffer is updatable
  6422. */
  6423. isUpdatable(): boolean;
  6424. /**
  6425. * Gets current buffer's data
  6426. * @returns a DataArray or null
  6427. */
  6428. getData(): Nullable<DataArray>;
  6429. /**
  6430. * Gets underlying native buffer
  6431. * @returns underlying native buffer
  6432. */
  6433. getBuffer(): Nullable<DataBuffer>;
  6434. /**
  6435. * Gets the stride in float32 units (i.e. byte stride / 4).
  6436. * May not be an integer if the byte stride is not divisible by 4.
  6437. * @returns the stride in float32 units
  6438. * @deprecated Please use byteStride instead.
  6439. */
  6440. getStrideSize(): number;
  6441. /**
  6442. * Returns the offset as a multiple of the type byte length.
  6443. * @returns the offset in bytes
  6444. * @deprecated Please use byteOffset instead.
  6445. */
  6446. getOffset(): number;
  6447. /**
  6448. * Returns the number of components per vertex attribute (integer)
  6449. * @returns the size in float
  6450. */
  6451. getSize(): number;
  6452. /**
  6453. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6454. * @returns true if this buffer is instanced
  6455. */
  6456. getIsInstanced(): boolean;
  6457. /**
  6458. * Returns the instancing divisor, zero for non-instanced (integer).
  6459. * @returns a number
  6460. */
  6461. getInstanceDivisor(): number;
  6462. /**
  6463. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6464. * @param data defines the data to store
  6465. */
  6466. create(data?: DataArray): void;
  6467. /**
  6468. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6469. * This function will create a new buffer if the current one is not updatable
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6475. * Returns the directly updated WebGLBuffer.
  6476. * @param data the new data
  6477. * @param offset the new offset
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6481. /**
  6482. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6483. */
  6484. dispose(): void;
  6485. /**
  6486. * Enumerates each value of this vertex buffer as numbers.
  6487. * @param count the number of values to enumerate
  6488. * @param callback the callback function called for each value
  6489. */
  6490. forEach(count: number, callback: (value: number, index: number) => void): void;
  6491. /**
  6492. * Positions
  6493. */
  6494. static readonly PositionKind: string;
  6495. /**
  6496. * Normals
  6497. */
  6498. static readonly NormalKind: string;
  6499. /**
  6500. * Tangents
  6501. */
  6502. static readonly TangentKind: string;
  6503. /**
  6504. * Texture coordinates
  6505. */
  6506. static readonly UVKind: string;
  6507. /**
  6508. * Texture coordinates 2
  6509. */
  6510. static readonly UV2Kind: string;
  6511. /**
  6512. * Texture coordinates 3
  6513. */
  6514. static readonly UV3Kind: string;
  6515. /**
  6516. * Texture coordinates 4
  6517. */
  6518. static readonly UV4Kind: string;
  6519. /**
  6520. * Texture coordinates 5
  6521. */
  6522. static readonly UV5Kind: string;
  6523. /**
  6524. * Texture coordinates 6
  6525. */
  6526. static readonly UV6Kind: string;
  6527. /**
  6528. * Colors
  6529. */
  6530. static readonly ColorKind: string;
  6531. /**
  6532. * Matrix indices (for bones)
  6533. */
  6534. static readonly MatricesIndicesKind: string;
  6535. /**
  6536. * Matrix weights (for bones)
  6537. */
  6538. static readonly MatricesWeightsKind: string;
  6539. /**
  6540. * Additional matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesExtraKind: string;
  6543. /**
  6544. * Additional matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsExtraKind: string;
  6547. /**
  6548. * Deduces the stride given a kind.
  6549. * @param kind The kind string to deduce
  6550. * @returns The deduced stride
  6551. */
  6552. static DeduceStride(kind: string): number;
  6553. /**
  6554. * Gets the byte length of the given type.
  6555. * @param type the type
  6556. * @returns the number of bytes
  6557. */
  6558. static GetTypeByteLength(type: number): number;
  6559. /**
  6560. * Enumerates each value of the given parameters as numbers.
  6561. * @param data the data to enumerate
  6562. * @param byteOffset the byte offset of the data
  6563. * @param byteStride the byte stride of the data
  6564. * @param componentCount the number of components per element
  6565. * @param componentType the type of the component
  6566. * @param count the number of values to enumerate
  6567. * @param normalized whether the data is normalized
  6568. * @param callback the callback function called for each value
  6569. */
  6570. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6571. private static _GetFloatValue;
  6572. }
  6573. }
  6574. declare module BABYLON {
  6575. /**
  6576. * @hidden
  6577. */
  6578. export class IntersectionInfo {
  6579. bu: Nullable<number>;
  6580. bv: Nullable<number>;
  6581. distance: number;
  6582. faceId: number;
  6583. subMeshId: number;
  6584. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Represens a plane by the equation ax + by + cz + d = 0
  6590. */
  6591. export class Plane {
  6592. private static _TmpMatrix;
  6593. /**
  6594. * Normal of the plane (a,b,c)
  6595. */
  6596. normal: Vector3;
  6597. /**
  6598. * d component of the plane
  6599. */
  6600. d: number;
  6601. /**
  6602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6603. * @param a a component of the plane
  6604. * @param b b component of the plane
  6605. * @param c c component of the plane
  6606. * @param d d component of the plane
  6607. */
  6608. constructor(a: number, b: number, c: number, d: number);
  6609. /**
  6610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6611. */
  6612. asArray(): number[];
  6613. /**
  6614. * @returns a new plane copied from the current Plane.
  6615. */
  6616. clone(): Plane;
  6617. /**
  6618. * @returns the string "Plane".
  6619. */
  6620. getClassName(): string;
  6621. /**
  6622. * @returns the Plane hash code.
  6623. */
  6624. getHashCode(): number;
  6625. /**
  6626. * Normalize the current Plane in place.
  6627. * @returns the updated Plane.
  6628. */
  6629. normalize(): Plane;
  6630. /**
  6631. * Applies a transformation the plane and returns the result
  6632. * @param transformation the transformation matrix to be applied to the plane
  6633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6634. */
  6635. transform(transformation: DeepImmutable<Matrix>): Plane;
  6636. /**
  6637. * Calcualtte the dot product between the point and the plane normal
  6638. * @param point point to calculate the dot product with
  6639. * @returns the dot product (float) of the point coordinates and the plane normal.
  6640. */
  6641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6642. /**
  6643. * Updates the current Plane from the plane defined by the three given points.
  6644. * @param point1 one of the points used to contruct the plane
  6645. * @param point2 one of the points used to contruct the plane
  6646. * @param point3 one of the points used to contruct the plane
  6647. * @returns the updated Plane.
  6648. */
  6649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Checks if the plane is facing a given direction
  6652. * @param direction the direction to check if the plane is facing
  6653. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6654. * @returns True is the vector "direction" is the same side than the plane normal.
  6655. */
  6656. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6657. /**
  6658. * Calculates the distance to a point
  6659. * @param point point to calculate distance to
  6660. * @returns the signed distance (float) from the given point to the Plane.
  6661. */
  6662. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6663. /**
  6664. * Creates a plane from an array
  6665. * @param array the array to create a plane from
  6666. * @returns a new Plane from the given array.
  6667. */
  6668. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6669. /**
  6670. * Creates a plane from three points
  6671. * @param point1 point used to create the plane
  6672. * @param point2 point used to create the plane
  6673. * @param point3 point used to create the plane
  6674. * @returns a new Plane defined by the three given points.
  6675. */
  6676. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Creates a plane from an origin point and a normal
  6679. * @param origin origin of the plane to be constructed
  6680. * @param normal normal of the plane to be constructed
  6681. * @returns a new Plane the normal vector to this plane at the given origin point.
  6682. * Note : the vector "normal" is updated because normalized.
  6683. */
  6684. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6685. /**
  6686. * Calculates the distance from a plane and a point
  6687. * @param origin origin of the plane to be constructed
  6688. * @param normal normal of the plane to be constructed
  6689. * @param point point to calculate distance to
  6690. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6691. */
  6692. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Class used to store bounding sphere information
  6698. */
  6699. export class BoundingSphere {
  6700. /**
  6701. * Gets the center of the bounding sphere in local space
  6702. */
  6703. readonly center: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in local space
  6706. */
  6707. radius: number;
  6708. /**
  6709. * Gets the center of the bounding sphere in world space
  6710. */
  6711. readonly centerWorld: Vector3;
  6712. /**
  6713. * Radius of the bounding sphere in world space
  6714. */
  6715. radiusWorld: number;
  6716. /**
  6717. * Gets the minimum vector in local space
  6718. */
  6719. readonly minimum: Vector3;
  6720. /**
  6721. * Gets the maximum vector in local space
  6722. */
  6723. readonly maximum: Vector3;
  6724. private _worldMatrix;
  6725. private static readonly TmpVector3;
  6726. /**
  6727. * Creates a new bounding sphere
  6728. * @param min defines the minimum vector (in local space)
  6729. * @param max defines the maximum vector (in local space)
  6730. * @param worldMatrix defines the new world matrix
  6731. */
  6732. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6733. /**
  6734. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6735. * @param min defines the new minimum vector (in local space)
  6736. * @param max defines the new maximum vector (in local space)
  6737. * @param worldMatrix defines the new world matrix
  6738. */
  6739. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6740. /**
  6741. * Scale the current bounding sphere by applying a scale factor
  6742. * @param factor defines the scale factor to apply
  6743. * @returns the current bounding box
  6744. */
  6745. scale(factor: number): BoundingSphere;
  6746. /**
  6747. * Gets the world matrix of the bounding box
  6748. * @returns a matrix
  6749. */
  6750. getWorldMatrix(): DeepImmutable<Matrix>;
  6751. /** @hidden */
  6752. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6753. /**
  6754. * Tests if the bounding sphere is intersecting the frustum planes
  6755. * @param frustumPlanes defines the frustum planes to test
  6756. * @returns true if there is an intersection
  6757. */
  6758. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6759. /**
  6760. * Tests if the bounding sphere center is in between the frustum planes.
  6761. * Used for optimistic fast inclusion.
  6762. * @param frustumPlanes defines the frustum planes to test
  6763. * @returns true if the sphere center is in between the frustum planes
  6764. */
  6765. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6766. /**
  6767. * Tests if a point is inside the bounding sphere
  6768. * @param point defines the point to test
  6769. * @returns true if the point is inside the bounding sphere
  6770. */
  6771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6772. /**
  6773. * Checks if two sphere intersct
  6774. * @param sphere0 sphere 0
  6775. * @param sphere1 sphere 1
  6776. * @returns true if the speres intersect
  6777. */
  6778. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding box information
  6784. */
  6785. export class BoundingBox implements ICullable {
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in local space
  6788. */
  6789. readonly vectors: Vector3[];
  6790. /**
  6791. * Gets the center of the bounding box in local space
  6792. */
  6793. readonly center: Vector3;
  6794. /**
  6795. * Gets the center of the bounding box in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Gets the extend size in local space
  6800. */
  6801. readonly extendSize: Vector3;
  6802. /**
  6803. * Gets the extend size in world space
  6804. */
  6805. readonly extendSizeWorld: Vector3;
  6806. /**
  6807. * Gets the OBB (object bounding box) directions
  6808. */
  6809. readonly directions: Vector3[];
  6810. /**
  6811. * Gets the 8 vectors representing the bounding box in world space
  6812. */
  6813. readonly vectorsWorld: Vector3[];
  6814. /**
  6815. * Gets the minimum vector in world space
  6816. */
  6817. readonly minimumWorld: Vector3;
  6818. /**
  6819. * Gets the maximum vector in world space
  6820. */
  6821. readonly maximumWorld: Vector3;
  6822. /**
  6823. * Gets the minimum vector in local space
  6824. */
  6825. readonly minimum: Vector3;
  6826. /**
  6827. * Gets the maximum vector in local space
  6828. */
  6829. readonly maximum: Vector3;
  6830. private _worldMatrix;
  6831. private static readonly TmpVector3;
  6832. /**
  6833. * @hidden
  6834. */
  6835. _tag: number;
  6836. /**
  6837. * Creates a new bounding box
  6838. * @param min defines the minimum vector (in local space)
  6839. * @param max defines the maximum vector (in local space)
  6840. * @param worldMatrix defines the new world matrix
  6841. */
  6842. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6843. /**
  6844. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6845. * @param min defines the new minimum vector (in local space)
  6846. * @param max defines the new maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Scale the current bounding box by applying a scale factor
  6852. * @param factor defines the scale factor to apply
  6853. * @returns the current bounding box
  6854. */
  6855. scale(factor: number): BoundingBox;
  6856. /**
  6857. * Gets the world matrix of the bounding box
  6858. * @returns a matrix
  6859. */
  6860. getWorldMatrix(): DeepImmutable<Matrix>;
  6861. /** @hidden */
  6862. _update(world: DeepImmutable<Matrix>): void;
  6863. /**
  6864. * Tests if the bounding box is intersecting the frustum planes
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if the bounding box is entirely inside the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an inclusion
  6873. */
  6874. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if a point is inside the bounding box
  6877. * @param point defines the point to test
  6878. * @returns true if the point is inside the bounding box
  6879. */
  6880. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6881. /**
  6882. * Tests if the bounding box intersects with a bounding sphere
  6883. * @param sphere defines the sphere to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6887. /**
  6888. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6889. * @param min defines the min vector to use
  6890. * @param max defines the max vector to use
  6891. * @returns true if there is an intersection
  6892. */
  6893. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6894. /**
  6895. * Tests if two bounding boxes are intersections
  6896. * @param box0 defines the first box to test
  6897. * @param box1 defines the second box to test
  6898. * @returns true if there is an intersection
  6899. */
  6900. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6901. /**
  6902. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6903. * @param minPoint defines the minimum vector of the bounding box
  6904. * @param maxPoint defines the maximum vector of the bounding box
  6905. * @param sphereCenter defines the sphere center
  6906. * @param sphereRadius defines the sphere radius
  6907. * @returns true if there is an intersection
  6908. */
  6909. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6910. /**
  6911. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6912. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6913. * @param frustumPlanes defines the frustum planes to test
  6914. * @return true if there is an inclusion
  6915. */
  6916. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6917. /**
  6918. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6919. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @return true if there is an intersection
  6922. */
  6923. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. }
  6925. }
  6926. declare module BABYLON {
  6927. /** @hidden */
  6928. export class Collider {
  6929. /** Define if a collision was found */
  6930. collisionFound: boolean;
  6931. /**
  6932. * Define last intersection point in local space
  6933. */
  6934. intersectionPoint: Vector3;
  6935. /**
  6936. * Define last collided mesh
  6937. */
  6938. collidedMesh: Nullable<AbstractMesh>;
  6939. private _collisionPoint;
  6940. private _planeIntersectionPoint;
  6941. private _tempVector;
  6942. private _tempVector2;
  6943. private _tempVector3;
  6944. private _tempVector4;
  6945. private _edge;
  6946. private _baseToVertex;
  6947. private _destinationPoint;
  6948. private _slidePlaneNormal;
  6949. private _displacementVector;
  6950. /** @hidden */
  6951. _radius: Vector3;
  6952. /** @hidden */
  6953. _retry: number;
  6954. private _velocity;
  6955. private _basePoint;
  6956. private _epsilon;
  6957. /** @hidden */
  6958. _velocityWorldLength: number;
  6959. /** @hidden */
  6960. _basePointWorld: Vector3;
  6961. private _velocityWorld;
  6962. private _normalizedVelocity;
  6963. /** @hidden */
  6964. _initialVelocity: Vector3;
  6965. /** @hidden */
  6966. _initialPosition: Vector3;
  6967. private _nearestDistance;
  6968. private _collisionMask;
  6969. get collisionMask(): number;
  6970. set collisionMask(mask: number);
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. get slidePlaneNormal(): Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Interface for cullable objects
  6992. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6993. */
  6994. export interface ICullable {
  6995. /**
  6996. * Checks if the object or part of the object is in the frustum
  6997. * @param frustumPlanes Camera near/planes
  6998. * @returns true if the object is in frustum otherwise false
  6999. */
  7000. isInFrustum(frustumPlanes: Plane[]): boolean;
  7001. /**
  7002. * Checks if a cullable object (mesh...) is in the camera frustum
  7003. * Unlike isInFrustum this cheks the full bounding box
  7004. * @param frustumPlanes Camera near/planes
  7005. * @returns true if the object is in frustum otherwise false
  7006. */
  7007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7008. }
  7009. /**
  7010. * Info for a bounding data of a mesh
  7011. */
  7012. export class BoundingInfo implements ICullable {
  7013. /**
  7014. * Bounding box for the mesh
  7015. */
  7016. readonly boundingBox: BoundingBox;
  7017. /**
  7018. * Bounding sphere for the mesh
  7019. */
  7020. readonly boundingSphere: BoundingSphere;
  7021. private _isLocked;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * Constructs bounding info
  7025. * @param minimum min vector of the bounding box/sphere
  7026. * @param maximum max vector of the bounding box/sphere
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7030. /**
  7031. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7032. * @param min defines the new minimum vector (in local space)
  7033. * @param max defines the new maximum vector (in local space)
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7037. /**
  7038. * min vector of the bounding box/sphere
  7039. */
  7040. get minimum(): Vector3;
  7041. /**
  7042. * max vector of the bounding box/sphere
  7043. */
  7044. get maximum(): Vector3;
  7045. /**
  7046. * If the info is locked and won't be updated to avoid perf overhead
  7047. */
  7048. get isLocked(): boolean;
  7049. set isLocked(value: boolean);
  7050. /**
  7051. * Updates the bounding sphere and box
  7052. * @param world world matrix to be used to update
  7053. */
  7054. update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7057. * @param center New center of the bounding info
  7058. * @param extend New extend of the bounding info
  7059. * @returns the current bounding info
  7060. */
  7061. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7062. /**
  7063. * Scale the current bounding info by applying a scale factor
  7064. * @param factor defines the scale factor to apply
  7065. * @returns the current bounding info
  7066. */
  7067. scale(factor: number): BoundingInfo;
  7068. /**
  7069. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7070. * @param frustumPlanes defines the frustum to test
  7071. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7072. * @returns true if the bounding info is in the frustum planes
  7073. */
  7074. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7075. /**
  7076. * Gets the world distance between the min and max points of the bounding box
  7077. */
  7078. get diagonalLength(): number;
  7079. /**
  7080. * Checks if a cullable object (mesh...) is in the camera frustum
  7081. * Unlike isInFrustum this cheks the full bounding box
  7082. * @param frustumPlanes Camera near/planes
  7083. * @returns true if the object is in frustum otherwise false
  7084. */
  7085. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7086. /** @hidden */
  7087. _checkCollision(collider: Collider): boolean;
  7088. /**
  7089. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7090. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7091. * @param point the point to check intersection with
  7092. * @returns if the point intersects
  7093. */
  7094. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7095. /**
  7096. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param boundingInfo the bounding info to check intersection with
  7099. * @param precise if the intersection should be done using OBB
  7100. * @returns if the bounding info intersects
  7101. */
  7102. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. /**
  7107. * Extracts minimum and maximum values from a list of indexed positions
  7108. * @param positions defines the positions to use
  7109. * @param indices defines the indices to the positions
  7110. * @param indexStart defines the start index
  7111. * @param indexCount defines the end index
  7112. * @param bias defines bias value to add to the result
  7113. * @return minimum and maximum values
  7114. */
  7115. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7116. minimum: Vector3;
  7117. maximum: Vector3;
  7118. };
  7119. /**
  7120. * Extracts minimum and maximum values from a list of positions
  7121. * @param positions defines the positions to use
  7122. * @param start defines the start index in the positions array
  7123. * @param count defines the number of positions to handle
  7124. * @param bias defines bias value to add to the result
  7125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7126. * @return minimum and maximum values
  7127. */
  7128. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7129. minimum: Vector3;
  7130. maximum: Vector3;
  7131. };
  7132. }
  7133. declare module BABYLON {
  7134. /** @hidden */
  7135. export class WebGLDataBuffer extends DataBuffer {
  7136. private _buffer;
  7137. constructor(resource: WebGLBuffer);
  7138. get underlyingResource(): any;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class WebGLPipelineContext implements IPipelineContext {
  7144. engine: ThinEngine;
  7145. program: Nullable<WebGLProgram>;
  7146. context?: WebGLRenderingContext;
  7147. vertexShader?: WebGLShader;
  7148. fragmentShader?: WebGLShader;
  7149. isParallelCompiled: boolean;
  7150. onCompiled?: () => void;
  7151. transformFeedback?: WebGLTransformFeedback | null;
  7152. vertexCompilationError: Nullable<string>;
  7153. fragmentCompilationError: Nullable<string>;
  7154. programLinkError: Nullable<string>;
  7155. programValidationError: Nullable<string>;
  7156. get isAsync(): boolean;
  7157. get isReady(): boolean;
  7158. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7159. }
  7160. }
  7161. declare module BABYLON {
  7162. interface ThinEngine {
  7163. /**
  7164. * Create an uniform buffer
  7165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7166. * @param elements defines the content of the uniform buffer
  7167. * @returns the webGL uniform buffer
  7168. */
  7169. createUniformBuffer(elements: FloatArray): DataBuffer;
  7170. /**
  7171. * Create a dynamic uniform buffer
  7172. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7173. * @param elements defines the content of the uniform buffer
  7174. * @returns the webGL uniform buffer
  7175. */
  7176. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7177. /**
  7178. * Update an existing uniform buffer
  7179. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7180. * @param uniformBuffer defines the target uniform buffer
  7181. * @param elements defines the content to update
  7182. * @param offset defines the offset in the uniform buffer where update should start
  7183. * @param count defines the size of the data to update
  7184. */
  7185. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7186. /**
  7187. * Bind an uniform buffer to the current webGL context
  7188. * @param buffer defines the buffer to bind
  7189. */
  7190. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7191. /**
  7192. * Bind a buffer to the current webGL context at a given location
  7193. * @param buffer defines the buffer to bind
  7194. * @param location defines the index where to bind the buffer
  7195. */
  7196. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7197. /**
  7198. * Bind a specific block at a given index in a specific shader program
  7199. * @param pipelineContext defines the pipeline context to use
  7200. * @param blockName defines the block name
  7201. * @param index defines the index where to bind the block
  7202. */
  7203. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. /**
  7208. * Uniform buffer objects.
  7209. *
  7210. * Handles blocks of uniform on the GPU.
  7211. *
  7212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7213. *
  7214. * For more information, please refer to :
  7215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7216. */
  7217. export class UniformBuffer {
  7218. private _engine;
  7219. private _buffer;
  7220. private _data;
  7221. private _bufferData;
  7222. private _dynamic?;
  7223. private _uniformLocations;
  7224. private _uniformSizes;
  7225. private _uniformLocationPointer;
  7226. private _needSync;
  7227. private _noUBO;
  7228. private _currentEffect;
  7229. /** @hidden */
  7230. _alreadyBound: boolean;
  7231. private static _MAX_UNIFORM_SIZE;
  7232. private static _tempBuffer;
  7233. /**
  7234. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7239. /**
  7240. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7245. /**
  7246. * Lambda to Update a single float in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateFloat: (name: string, x: number) => void;
  7251. /**
  7252. * Lambda to Update a vec2 of float in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7257. /**
  7258. * Lambda to Update a vec3 of float in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7263. /**
  7264. * Lambda to Update a vec4 of float in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateMatrix: (name: string, mat: Matrix) => void;
  7275. /**
  7276. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateVector3: (name: string, vector: Vector3) => void;
  7281. /**
  7282. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateVector4: (name: string, vector: Vector4) => void;
  7287. /**
  7288. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7299. /**
  7300. * Instantiates a new Uniform buffer objects.
  7301. *
  7302. * Handles blocks of uniform on the GPU.
  7303. *
  7304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7305. *
  7306. * For more information, please refer to :
  7307. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7308. * @param engine Define the engine the buffer is associated with
  7309. * @param data Define the data contained in the buffer
  7310. * @param dynamic Define if the buffer is updatable
  7311. */
  7312. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7313. /**
  7314. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7315. * or just falling back on setUniformXXX calls.
  7316. */
  7317. get useUbo(): boolean;
  7318. /**
  7319. * Indicates if the WebGL underlying uniform buffer is in sync
  7320. * with the javascript cache data.
  7321. */
  7322. get isSync(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7325. * Also, a dynamic UniformBuffer will disable cache verification and always
  7326. * update the underlying WebGL uniform buffer to the GPU.
  7327. * @returns if Dynamic, otherwise false
  7328. */
  7329. isDynamic(): boolean;
  7330. /**
  7331. * The data cache on JS side.
  7332. * @returns the underlying data as a float array
  7333. */
  7334. getData(): Float32Array;
  7335. /**
  7336. * The underlying WebGL Uniform buffer.
  7337. * @returns the webgl buffer
  7338. */
  7339. getBuffer(): Nullable<DataBuffer>;
  7340. /**
  7341. * std140 layout specifies how to align data within an UBO structure.
  7342. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7343. * for specs.
  7344. */
  7345. private _fillAlignment;
  7346. /**
  7347. * Adds an uniform in the buffer.
  7348. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7349. * for the layout to be correct !
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param size Data size, or data directly.
  7352. */
  7353. addUniform(name: string, size: number | number[]): void;
  7354. /**
  7355. * Adds a Matrix 4x4 to the uniform buffer.
  7356. * @param name Name of the uniform, as used in the uniform block in the shader.
  7357. * @param mat A 4x4 matrix.
  7358. */
  7359. addMatrix(name: string, mat: Matrix): void;
  7360. /**
  7361. * Adds a vec2 to the uniform buffer.
  7362. * @param name Name of the uniform, as used in the uniform block in the shader.
  7363. * @param x Define the x component value of the vec2
  7364. * @param y Define the y component value of the vec2
  7365. */
  7366. addFloat2(name: string, x: number, y: number): void;
  7367. /**
  7368. * Adds a vec3 to the uniform buffer.
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param x Define the x component value of the vec3
  7371. * @param y Define the y component value of the vec3
  7372. * @param z Define the z component value of the vec3
  7373. */
  7374. addFloat3(name: string, x: number, y: number, z: number): void;
  7375. /**
  7376. * Adds a vec3 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. * @param color Define the vec3 from a Color
  7379. */
  7380. addColor3(name: string, color: Color3): void;
  7381. /**
  7382. * Adds a vec4 to the uniform buffer.
  7383. * @param name Name of the uniform, as used in the uniform block in the shader.
  7384. * @param color Define the rgb components from a Color
  7385. * @param alpha Define the a component of the vec4
  7386. */
  7387. addColor4(name: string, color: Color3, alpha: number): void;
  7388. /**
  7389. * Adds a vec3 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param vector Define the vec3 components from a Vector
  7392. */
  7393. addVector3(name: string, vector: Vector3): void;
  7394. /**
  7395. * Adds a Matrix 3x3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. */
  7398. addMatrix3x3(name: string): void;
  7399. /**
  7400. * Adds a Matrix 2x2 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix2x2(name: string): void;
  7404. /**
  7405. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7406. */
  7407. create(): void;
  7408. /** @hidden */
  7409. _rebuild(): void;
  7410. /**
  7411. * Updates the WebGL Uniform Buffer on the GPU.
  7412. * If the `dynamic` flag is set to true, no cache comparison is done.
  7413. * Otherwise, the buffer will be updated only if the cache differs.
  7414. */
  7415. update(): void;
  7416. /**
  7417. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7418. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7419. * @param data Define the flattened data
  7420. * @param size Define the size of the data.
  7421. */
  7422. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7423. private _valueCache;
  7424. private _cacheMatrix;
  7425. private _updateMatrix3x3ForUniform;
  7426. private _updateMatrix3x3ForEffect;
  7427. private _updateMatrix2x2ForEffect;
  7428. private _updateMatrix2x2ForUniform;
  7429. private _updateFloatForEffect;
  7430. private _updateFloatForUniform;
  7431. private _updateFloat2ForEffect;
  7432. private _updateFloat2ForUniform;
  7433. private _updateFloat3ForEffect;
  7434. private _updateFloat3ForUniform;
  7435. private _updateFloat4ForEffect;
  7436. private _updateFloat4ForUniform;
  7437. private _updateMatrixForEffect;
  7438. private _updateMatrixForUniform;
  7439. private _updateVector3ForEffect;
  7440. private _updateVector3ForUniform;
  7441. private _updateVector4ForEffect;
  7442. private _updateVector4ForUniform;
  7443. private _updateColor3ForEffect;
  7444. private _updateColor3ForUniform;
  7445. private _updateColor4ForEffect;
  7446. private _updateColor4ForUniform;
  7447. /**
  7448. * Sets a sampler uniform on the effect.
  7449. * @param name Define the name of the sampler.
  7450. * @param texture Define the texture to set in the sampler
  7451. */
  7452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7453. /**
  7454. * Directly updates the value of the uniform in the cache AND on the GPU.
  7455. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7456. * @param data Define the flattened data
  7457. */
  7458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7459. /**
  7460. * Binds this uniform buffer to an effect.
  7461. * @param effect Define the effect to bind the buffer to
  7462. * @param name Name of the uniform block in the shader.
  7463. */
  7464. bindToEffect(effect: Effect, name: string): void;
  7465. /**
  7466. * Disposes the uniform buffer.
  7467. */
  7468. dispose(): void;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Enum that determines the text-wrapping mode to use.
  7474. */
  7475. export enum InspectableType {
  7476. /**
  7477. * Checkbox for booleans
  7478. */
  7479. Checkbox = 0,
  7480. /**
  7481. * Sliders for numbers
  7482. */
  7483. Slider = 1,
  7484. /**
  7485. * Vector3
  7486. */
  7487. Vector3 = 2,
  7488. /**
  7489. * Quaternions
  7490. */
  7491. Quaternion = 3,
  7492. /**
  7493. * Color3
  7494. */
  7495. Color3 = 4,
  7496. /**
  7497. * String
  7498. */
  7499. String = 5
  7500. }
  7501. /**
  7502. * Interface used to define custom inspectable properties.
  7503. * This interface is used by the inspector to display custom property grids
  7504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7505. */
  7506. export interface IInspectable {
  7507. /**
  7508. * Gets the label to display
  7509. */
  7510. label: string;
  7511. /**
  7512. * Gets the name of the property to edit
  7513. */
  7514. propertyName: string;
  7515. /**
  7516. * Gets the type of the editor to use
  7517. */
  7518. type: InspectableType;
  7519. /**
  7520. * Gets the minimum value of the property when using in "slider" mode
  7521. */
  7522. min?: number;
  7523. /**
  7524. * Gets the maximum value of the property when using in "slider" mode
  7525. */
  7526. max?: number;
  7527. /**
  7528. * Gets the setp to use when using in "slider" mode
  7529. */
  7530. step?: number;
  7531. }
  7532. }
  7533. declare module BABYLON {
  7534. /**
  7535. * Class used to provide helper for timing
  7536. */
  7537. export class TimingTools {
  7538. /**
  7539. * Polyfill for setImmediate
  7540. * @param action defines the action to execute after the current execution block
  7541. */
  7542. static SetImmediate(action: () => void): void;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * Class used to enable instatition of objects by class name
  7548. */
  7549. export class InstantiationTools {
  7550. /**
  7551. * Use this object to register external classes like custom textures or material
  7552. * to allow the laoders to instantiate them
  7553. */
  7554. static RegisteredExternalClasses: {
  7555. [key: string]: Object;
  7556. };
  7557. /**
  7558. * Tries to instantiate a new object from a given class name
  7559. * @param className defines the class name to instantiate
  7560. * @returns the new object or null if the system was not able to do the instantiation
  7561. */
  7562. static Instantiate(className: string): any;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Define options used to create a depth texture
  7568. */
  7569. export class DepthTextureCreationOptions {
  7570. /** Specifies whether or not a stencil should be allocated in the texture */
  7571. generateStencil?: boolean;
  7572. /** Specifies whether or not bilinear filtering is enable on the texture */
  7573. bilinearFiltering?: boolean;
  7574. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7575. comparisonFunction?: number;
  7576. /** Specifies if the created texture is a cube texture */
  7577. isCube?: boolean;
  7578. }
  7579. }
  7580. declare module BABYLON {
  7581. interface ThinEngine {
  7582. /**
  7583. * Creates a depth stencil cube texture.
  7584. * This is only available in WebGL 2.
  7585. * @param size The size of face edge in the cube texture.
  7586. * @param options The options defining the cube texture.
  7587. * @returns The cube texture
  7588. */
  7589. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7590. /**
  7591. * Creates a cube texture
  7592. * @param rootUrl defines the url where the files to load is located
  7593. * @param scene defines the current scene
  7594. * @param files defines the list of files to load (1 per face)
  7595. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7596. * @param onLoad defines an optional callback raised when the texture is loaded
  7597. * @param onError defines an optional callback raised if there is an issue to load the texture
  7598. * @param format defines the format of the data
  7599. * @param forcedExtension defines the extension to use to pick the right loader
  7600. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7601. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7602. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7603. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7604. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7605. * @returns the cube texture as an InternalTexture
  7606. */
  7607. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7608. /**
  7609. * Creates a cube texture
  7610. * @param rootUrl defines the url where the files to load is located
  7611. * @param scene defines the current scene
  7612. * @param files defines the list of files to load (1 per face)
  7613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7614. * @param onLoad defines an optional callback raised when the texture is loaded
  7615. * @param onError defines an optional callback raised if there is an issue to load the texture
  7616. * @param format defines the format of the data
  7617. * @param forcedExtension defines the extension to use to pick the right loader
  7618. * @returns the cube texture as an InternalTexture
  7619. */
  7620. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @returns the cube texture as an InternalTexture
  7635. */
  7636. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7637. /** @hidden */
  7638. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7641. /** @hidden */
  7642. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /** @hidden */
  7644. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7645. /**
  7646. * @hidden
  7647. */
  7648. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7649. }
  7650. }
  7651. declare module BABYLON {
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. set boundingBoxSize(value: Vector3);
  7675. /**
  7676. * Returns the bounding box size
  7677. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7678. */
  7679. get boundingBoxSize(): Vector3;
  7680. protected _rotationY: number;
  7681. /**
  7682. * Sets texture matrix rotation angle around Y axis in radians.
  7683. */
  7684. set rotationY(value: number);
  7685. /**
  7686. * Gets texture matrix rotation angle around Y axis radians.
  7687. */
  7688. get rotationY(): number;
  7689. /**
  7690. * Are mip maps generated for this texture or not.
  7691. */
  7692. get noMipmap(): boolean;
  7693. private _noMipmap;
  7694. private _files;
  7695. protected _forcedExtension: Nullable<string>;
  7696. private _extensions;
  7697. private _textureMatrix;
  7698. private _format;
  7699. private _createPolynomials;
  7700. /** @hidden */
  7701. _prefiltered: boolean;
  7702. /**
  7703. * Creates a cube texture from an array of image urls
  7704. * @param files defines an array of image urls
  7705. * @param scene defines the hosting scene
  7706. * @param noMipmap specifies if mip maps are not used
  7707. * @returns a cube texture
  7708. */
  7709. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7710. /**
  7711. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7712. * @param url defines the url of the prefiltered texture
  7713. * @param scene defines the scene the texture is attached to
  7714. * @param forcedExtension defines the extension of the file if different from the url
  7715. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7716. * @return the prefiltered texture
  7717. */
  7718. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7719. /**
  7720. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7721. * as prefiltered data.
  7722. * @param rootUrl defines the url of the texture or the root name of the six images
  7723. * @param scene defines the scene the texture is attached to
  7724. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7725. * @param noMipmap defines if mipmaps should be created or not
  7726. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7727. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7728. * @param onError defines a callback triggered in case of error during load
  7729. * @param format defines the internal format to use for the texture once loaded
  7730. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7731. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @return the cube texture
  7736. */
  7737. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7738. /**
  7739. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7740. */
  7741. get isPrefiltered(): boolean;
  7742. /**
  7743. * Get the current class name of the texture useful for serialization or dynamic coding.
  7744. * @returns "CubeTexture"
  7745. */
  7746. getClassName(): string;
  7747. /**
  7748. * Update the url (and optional buffer) of this texture if url was null during construction.
  7749. * @param url the url of the texture
  7750. * @param forcedExtension defines the extension to use
  7751. * @param onLoad callback called when the texture is loaded (defaults to null)
  7752. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7753. */
  7754. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7755. /**
  7756. * Delays loading of the cube texture
  7757. * @param forcedExtension defines the extension to use
  7758. */
  7759. delayLoad(forcedExtension?: string): void;
  7760. /**
  7761. * Returns the reflection texture matrix
  7762. * @returns the reflection texture matrix
  7763. */
  7764. getReflectionTextureMatrix(): Matrix;
  7765. /**
  7766. * Sets the reflection texture matrix
  7767. * @param value Reflection texture matrix
  7768. */
  7769. setReflectionTextureMatrix(value: Matrix): void;
  7770. /**
  7771. * Parses text to create a cube texture
  7772. * @param parsedTexture define the serialized text to read from
  7773. * @param scene defines the hosting scene
  7774. * @param rootUrl defines the root url of the cube texture
  7775. * @returns a cube texture
  7776. */
  7777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7778. /**
  7779. * Makes a clone, or deep copy, of the cube texture
  7780. * @returns a new cube texture
  7781. */
  7782. clone(): CubeTexture;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. /**
  7787. * Manages the defines for the Material
  7788. */
  7789. export class MaterialDefines {
  7790. /** @hidden */
  7791. protected _keys: string[];
  7792. private _isDirty;
  7793. /** @hidden */
  7794. _renderId: number;
  7795. /** @hidden */
  7796. _areLightsDirty: boolean;
  7797. /** @hidden */
  7798. _areLightsDisposed: boolean;
  7799. /** @hidden */
  7800. _areAttributesDirty: boolean;
  7801. /** @hidden */
  7802. _areTexturesDirty: boolean;
  7803. /** @hidden */
  7804. _areFresnelDirty: boolean;
  7805. /** @hidden */
  7806. _areMiscDirty: boolean;
  7807. /** @hidden */
  7808. _areImageProcessingDirty: boolean;
  7809. /** @hidden */
  7810. _normals: boolean;
  7811. /** @hidden */
  7812. _uvs: boolean;
  7813. /** @hidden */
  7814. _needNormals: boolean;
  7815. /** @hidden */
  7816. _needUVs: boolean;
  7817. [id: string]: any;
  7818. /**
  7819. * Specifies if the material needs to be re-calculated
  7820. */
  7821. get isDirty(): boolean;
  7822. /**
  7823. * Marks the material to indicate that it has been re-calculated
  7824. */
  7825. markAsProcessed(): void;
  7826. /**
  7827. * Marks the material to indicate that it needs to be re-calculated
  7828. */
  7829. markAsUnprocessed(): void;
  7830. /**
  7831. * Marks the material to indicate all of its defines need to be re-calculated
  7832. */
  7833. markAllAsDirty(): void;
  7834. /**
  7835. * Marks the material to indicate that image processing needs to be re-calculated
  7836. */
  7837. markAsImageProcessingDirty(): void;
  7838. /**
  7839. * Marks the material to indicate the lights need to be re-calculated
  7840. * @param disposed Defines whether the light is dirty due to dispose or not
  7841. */
  7842. markAsLightDirty(disposed?: boolean): void;
  7843. /**
  7844. * Marks the attribute state as changed
  7845. */
  7846. markAsAttributesDirty(): void;
  7847. /**
  7848. * Marks the texture state as changed
  7849. */
  7850. markAsTexturesDirty(): void;
  7851. /**
  7852. * Marks the fresnel state as changed
  7853. */
  7854. markAsFresnelDirty(): void;
  7855. /**
  7856. * Marks the misc state as changed
  7857. */
  7858. markAsMiscDirty(): void;
  7859. /**
  7860. * Rebuilds the material defines
  7861. */
  7862. rebuild(): void;
  7863. /**
  7864. * Specifies if two material defines are equal
  7865. * @param other - A material define instance to compare to
  7866. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7867. */
  7868. isEqual(other: MaterialDefines): boolean;
  7869. /**
  7870. * Clones this instance's defines to another instance
  7871. * @param other - material defines to clone values to
  7872. */
  7873. cloneTo(other: MaterialDefines): void;
  7874. /**
  7875. * Resets the material define values
  7876. */
  7877. reset(): void;
  7878. /**
  7879. * Converts the material define values to a string
  7880. * @returns - String of material define information
  7881. */
  7882. toString(): string;
  7883. }
  7884. }
  7885. declare module BABYLON {
  7886. /**
  7887. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7888. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7889. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7890. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7891. */
  7892. export class ColorCurves {
  7893. private _dirty;
  7894. private _tempColor;
  7895. private _globalCurve;
  7896. private _highlightsCurve;
  7897. private _midtonesCurve;
  7898. private _shadowsCurve;
  7899. private _positiveCurve;
  7900. private _negativeCurve;
  7901. private _globalHue;
  7902. private _globalDensity;
  7903. private _globalSaturation;
  7904. private _globalExposure;
  7905. /**
  7906. * Gets the global Hue value.
  7907. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7908. */
  7909. get globalHue(): number;
  7910. /**
  7911. * Sets the global Hue value.
  7912. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7913. */
  7914. set globalHue(value: number);
  7915. /**
  7916. * Gets the global Density value.
  7917. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. get globalDensity(): number;
  7921. /**
  7922. * Sets the global Density value.
  7923. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7924. * Values less than zero provide a filter of opposite hue.
  7925. */
  7926. set globalDensity(value: number);
  7927. /**
  7928. * Gets the global Saturation value.
  7929. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7930. */
  7931. get globalSaturation(): number;
  7932. /**
  7933. * Sets the global Saturation value.
  7934. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7935. */
  7936. set globalSaturation(value: number);
  7937. /**
  7938. * Gets the global Exposure value.
  7939. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7940. */
  7941. get globalExposure(): number;
  7942. /**
  7943. * Sets the global Exposure value.
  7944. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7945. */
  7946. set globalExposure(value: number);
  7947. private _highlightsHue;
  7948. private _highlightsDensity;
  7949. private _highlightsSaturation;
  7950. private _highlightsExposure;
  7951. /**
  7952. * Gets the highlights Hue value.
  7953. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7954. */
  7955. get highlightsHue(): number;
  7956. /**
  7957. * Sets the highlights Hue value.
  7958. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7959. */
  7960. set highlightsHue(value: number);
  7961. /**
  7962. * Gets the highlights Density value.
  7963. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7964. * Values less than zero provide a filter of opposite hue.
  7965. */
  7966. get highlightsDensity(): number;
  7967. /**
  7968. * Sets the highlights Density value.
  7969. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. set highlightsDensity(value: number);
  7973. /**
  7974. * Gets the highlights Saturation value.
  7975. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7976. */
  7977. get highlightsSaturation(): number;
  7978. /**
  7979. * Sets the highlights Saturation value.
  7980. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7981. */
  7982. set highlightsSaturation(value: number);
  7983. /**
  7984. * Gets the highlights Exposure value.
  7985. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7986. */
  7987. get highlightsExposure(): number;
  7988. /**
  7989. * Sets the highlights Exposure value.
  7990. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7991. */
  7992. set highlightsExposure(value: number);
  7993. private _midtonesHue;
  7994. private _midtonesDensity;
  7995. private _midtonesSaturation;
  7996. private _midtonesExposure;
  7997. /**
  7998. * Gets the midtones Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. get midtonesHue(): number;
  8002. /**
  8003. * Sets the midtones Hue value.
  8004. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8005. */
  8006. set midtonesHue(value: number);
  8007. /**
  8008. * Gets the midtones Density value.
  8009. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. get midtonesDensity(): number;
  8013. /**
  8014. * Sets the midtones Density value.
  8015. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8016. * Values less than zero provide a filter of opposite hue.
  8017. */
  8018. set midtonesDensity(value: number);
  8019. /**
  8020. * Gets the midtones Saturation value.
  8021. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8022. */
  8023. get midtonesSaturation(): number;
  8024. /**
  8025. * Sets the midtones Saturation value.
  8026. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8027. */
  8028. set midtonesSaturation(value: number);
  8029. /**
  8030. * Gets the midtones Exposure value.
  8031. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8032. */
  8033. get midtonesExposure(): number;
  8034. /**
  8035. * Sets the midtones Exposure value.
  8036. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8037. */
  8038. set midtonesExposure(value: number);
  8039. private _shadowsHue;
  8040. private _shadowsDensity;
  8041. private _shadowsSaturation;
  8042. private _shadowsExposure;
  8043. /**
  8044. * Gets the shadows Hue value.
  8045. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8046. */
  8047. get shadowsHue(): number;
  8048. /**
  8049. * Sets the shadows Hue value.
  8050. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8051. */
  8052. set shadowsHue(value: number);
  8053. /**
  8054. * Gets the shadows Density value.
  8055. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. get shadowsDensity(): number;
  8059. /**
  8060. * Sets the shadows Density value.
  8061. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. set shadowsDensity(value: number);
  8065. /**
  8066. * Gets the shadows Saturation value.
  8067. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8068. */
  8069. get shadowsSaturation(): number;
  8070. /**
  8071. * Sets the shadows Saturation value.
  8072. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8073. */
  8074. set shadowsSaturation(value: number);
  8075. /**
  8076. * Gets the shadows Exposure value.
  8077. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8078. */
  8079. get shadowsExposure(): number;
  8080. /**
  8081. * Sets the shadows Exposure value.
  8082. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8083. */
  8084. set shadowsExposure(value: number);
  8085. /**
  8086. * Returns the class name
  8087. * @returns The class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Binds the color curves to the shader.
  8092. * @param colorCurves The color curve to bind
  8093. * @param effect The effect to bind to
  8094. * @param positiveUniform The positive uniform shader parameter
  8095. * @param neutralUniform The neutral uniform shader parameter
  8096. * @param negativeUniform The negative uniform shader parameter
  8097. */
  8098. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8099. /**
  8100. * Prepare the list of uniforms associated with the ColorCurves effects.
  8101. * @param uniformsList The list of uniforms used in the effect
  8102. */
  8103. static PrepareUniforms(uniformsList: string[]): void;
  8104. /**
  8105. * Returns color grading data based on a hue, density, saturation and exposure value.
  8106. * @param filterHue The hue of the color filter.
  8107. * @param filterDensity The density of the color filter.
  8108. * @param saturation The saturation.
  8109. * @param exposure The exposure.
  8110. * @param result The result data container.
  8111. */
  8112. private getColorGradingDataToRef;
  8113. /**
  8114. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8115. * @param value The input slider value in range [-100,100].
  8116. * @returns Adjusted value.
  8117. */
  8118. private static applyColorGradingSliderNonlinear;
  8119. /**
  8120. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8121. * @param hue The hue (H) input.
  8122. * @param saturation The saturation (S) input.
  8123. * @param brightness The brightness (B) input.
  8124. * @result An RGBA color represented as Vector4.
  8125. */
  8126. private static fromHSBToRef;
  8127. /**
  8128. * Returns a value clamped between min and max
  8129. * @param value The value to clamp
  8130. * @param min The minimum of value
  8131. * @param max The maximum of value
  8132. * @returns The clamped value.
  8133. */
  8134. private static clamp;
  8135. /**
  8136. * Clones the current color curve instance.
  8137. * @return The cloned curves
  8138. */
  8139. clone(): ColorCurves;
  8140. /**
  8141. * Serializes the current color curve instance to a json representation.
  8142. * @return a JSON representation
  8143. */
  8144. serialize(): any;
  8145. /**
  8146. * Parses the color curve from a json representation.
  8147. * @param source the JSON source to parse
  8148. * @return The parsed curves
  8149. */
  8150. static Parse(source: any): ColorCurves;
  8151. }
  8152. }
  8153. declare module BABYLON {
  8154. /**
  8155. * Interface to follow in your material defines to integrate easily the
  8156. * Image proccessing functions.
  8157. * @hidden
  8158. */
  8159. export interface IImageProcessingConfigurationDefines {
  8160. IMAGEPROCESSING: boolean;
  8161. VIGNETTE: boolean;
  8162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8163. VIGNETTEBLENDMODEOPAQUE: boolean;
  8164. TONEMAPPING: boolean;
  8165. TONEMAPPING_ACES: boolean;
  8166. CONTRAST: boolean;
  8167. EXPOSURE: boolean;
  8168. COLORCURVES: boolean;
  8169. COLORGRADING: boolean;
  8170. COLORGRADING3D: boolean;
  8171. SAMPLER3DGREENDEPTH: boolean;
  8172. SAMPLER3DBGRMAP: boolean;
  8173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8174. }
  8175. /**
  8176. * @hidden
  8177. */
  8178. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8179. IMAGEPROCESSING: boolean;
  8180. VIGNETTE: boolean;
  8181. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8182. VIGNETTEBLENDMODEOPAQUE: boolean;
  8183. TONEMAPPING: boolean;
  8184. TONEMAPPING_ACES: boolean;
  8185. CONTRAST: boolean;
  8186. COLORCURVES: boolean;
  8187. COLORGRADING: boolean;
  8188. COLORGRADING3D: boolean;
  8189. SAMPLER3DGREENDEPTH: boolean;
  8190. SAMPLER3DBGRMAP: boolean;
  8191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8192. EXPOSURE: boolean;
  8193. constructor();
  8194. }
  8195. /**
  8196. * This groups together the common properties used for image processing either in direct forward pass
  8197. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8198. * or not.
  8199. */
  8200. export class ImageProcessingConfiguration {
  8201. /**
  8202. * Default tone mapping applied in BabylonJS.
  8203. */
  8204. static readonly TONEMAPPING_STANDARD: number;
  8205. /**
  8206. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8207. * to other engines rendering to increase portability.
  8208. */
  8209. static readonly TONEMAPPING_ACES: number;
  8210. /**
  8211. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8212. */
  8213. colorCurves: Nullable<ColorCurves>;
  8214. private _colorCurvesEnabled;
  8215. /**
  8216. * Gets wether the color curves effect is enabled.
  8217. */
  8218. get colorCurvesEnabled(): boolean;
  8219. /**
  8220. * Sets wether the color curves effect is enabled.
  8221. */
  8222. set colorCurvesEnabled(value: boolean);
  8223. private _colorGradingTexture;
  8224. /**
  8225. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8226. */
  8227. get colorGradingTexture(): Nullable<BaseTexture>;
  8228. /**
  8229. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8230. */
  8231. set colorGradingTexture(value: Nullable<BaseTexture>);
  8232. private _colorGradingEnabled;
  8233. /**
  8234. * Gets wether the color grading effect is enabled.
  8235. */
  8236. get colorGradingEnabled(): boolean;
  8237. /**
  8238. * Sets wether the color grading effect is enabled.
  8239. */
  8240. set colorGradingEnabled(value: boolean);
  8241. private _colorGradingWithGreenDepth;
  8242. /**
  8243. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8244. */
  8245. get colorGradingWithGreenDepth(): boolean;
  8246. /**
  8247. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8248. */
  8249. set colorGradingWithGreenDepth(value: boolean);
  8250. private _colorGradingBGR;
  8251. /**
  8252. * Gets wether the color grading texture contains BGR values.
  8253. */
  8254. get colorGradingBGR(): boolean;
  8255. /**
  8256. * Sets wether the color grading texture contains BGR values.
  8257. */
  8258. set colorGradingBGR(value: boolean);
  8259. /** @hidden */
  8260. _exposure: number;
  8261. /**
  8262. * Gets the Exposure used in the effect.
  8263. */
  8264. get exposure(): number;
  8265. /**
  8266. * Sets the Exposure used in the effect.
  8267. */
  8268. set exposure(value: number);
  8269. private _toneMappingEnabled;
  8270. /**
  8271. * Gets wether the tone mapping effect is enabled.
  8272. */
  8273. get toneMappingEnabled(): boolean;
  8274. /**
  8275. * Sets wether the tone mapping effect is enabled.
  8276. */
  8277. set toneMappingEnabled(value: boolean);
  8278. private _toneMappingType;
  8279. /**
  8280. * Gets the type of tone mapping effect.
  8281. */
  8282. get toneMappingType(): number;
  8283. /**
  8284. * Sets the type of tone mapping effect used in BabylonJS.
  8285. */
  8286. set toneMappingType(value: number);
  8287. protected _contrast: number;
  8288. /**
  8289. * Gets the contrast used in the effect.
  8290. */
  8291. get contrast(): number;
  8292. /**
  8293. * Sets the contrast used in the effect.
  8294. */
  8295. set contrast(value: number);
  8296. /**
  8297. * Vignette stretch size.
  8298. */
  8299. vignetteStretch: number;
  8300. /**
  8301. * Vignette centre X Offset.
  8302. */
  8303. vignetteCentreX: number;
  8304. /**
  8305. * Vignette centre Y Offset.
  8306. */
  8307. vignetteCentreY: number;
  8308. /**
  8309. * Vignette weight or intensity of the vignette effect.
  8310. */
  8311. vignetteWeight: number;
  8312. /**
  8313. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8314. * if vignetteEnabled is set to true.
  8315. */
  8316. vignetteColor: Color4;
  8317. /**
  8318. * Camera field of view used by the Vignette effect.
  8319. */
  8320. vignetteCameraFov: number;
  8321. private _vignetteBlendMode;
  8322. /**
  8323. * Gets the vignette blend mode allowing different kind of effect.
  8324. */
  8325. get vignetteBlendMode(): number;
  8326. /**
  8327. * Sets the vignette blend mode allowing different kind of effect.
  8328. */
  8329. set vignetteBlendMode(value: number);
  8330. private _vignetteEnabled;
  8331. /**
  8332. * Gets wether the vignette effect is enabled.
  8333. */
  8334. get vignetteEnabled(): boolean;
  8335. /**
  8336. * Sets wether the vignette effect is enabled.
  8337. */
  8338. set vignetteEnabled(value: boolean);
  8339. private _applyByPostProcess;
  8340. /**
  8341. * Gets wether the image processing is applied through a post process or not.
  8342. */
  8343. get applyByPostProcess(): boolean;
  8344. /**
  8345. * Sets wether the image processing is applied through a post process or not.
  8346. */
  8347. set applyByPostProcess(value: boolean);
  8348. private _isEnabled;
  8349. /**
  8350. * Gets wether the image processing is enabled or not.
  8351. */
  8352. get isEnabled(): boolean;
  8353. /**
  8354. * Sets wether the image processing is enabled or not.
  8355. */
  8356. set isEnabled(value: boolean);
  8357. /**
  8358. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8359. */
  8360. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8361. /**
  8362. * Method called each time the image processing information changes requires to recompile the effect.
  8363. */
  8364. protected _updateParameters(): void;
  8365. /**
  8366. * Gets the current class name.
  8367. * @return "ImageProcessingConfiguration"
  8368. */
  8369. getClassName(): string;
  8370. /**
  8371. * Prepare the list of uniforms associated with the Image Processing effects.
  8372. * @param uniforms The list of uniforms used in the effect
  8373. * @param defines the list of defines currently in use
  8374. */
  8375. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8376. /**
  8377. * Prepare the list of samplers associated with the Image Processing effects.
  8378. * @param samplersList The list of uniforms used in the effect
  8379. * @param defines the list of defines currently in use
  8380. */
  8381. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8382. /**
  8383. * Prepare the list of defines associated to the shader.
  8384. * @param defines the list of defines to complete
  8385. * @param forPostProcess Define if we are currently in post process mode or not
  8386. */
  8387. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8388. /**
  8389. * Returns true if all the image processing information are ready.
  8390. * @returns True if ready, otherwise, false
  8391. */
  8392. isReady(): boolean;
  8393. /**
  8394. * Binds the image processing to the shader.
  8395. * @param effect The effect to bind to
  8396. * @param overrideAspectRatio Override the aspect ratio of the effect
  8397. */
  8398. bind(effect: Effect, overrideAspectRatio?: number): void;
  8399. /**
  8400. * Clones the current image processing instance.
  8401. * @return The cloned image processing
  8402. */
  8403. clone(): ImageProcessingConfiguration;
  8404. /**
  8405. * Serializes the current image processing instance to a json representation.
  8406. * @return a JSON representation
  8407. */
  8408. serialize(): any;
  8409. /**
  8410. * Parses the image processing from a json representation.
  8411. * @param source the JSON source to parse
  8412. * @return The parsed image processing
  8413. */
  8414. static Parse(source: any): ImageProcessingConfiguration;
  8415. private static _VIGNETTEMODE_MULTIPLY;
  8416. private static _VIGNETTEMODE_OPAQUE;
  8417. /**
  8418. * Used to apply the vignette as a mix with the pixel color.
  8419. */
  8420. static get VIGNETTEMODE_MULTIPLY(): number;
  8421. /**
  8422. * Used to apply the vignette as a replacement of the pixel color.
  8423. */
  8424. static get VIGNETTEMODE_OPAQUE(): number;
  8425. }
  8426. }
  8427. declare module BABYLON {
  8428. /** @hidden */
  8429. export var postprocessVertexShader: {
  8430. name: string;
  8431. shader: string;
  8432. };
  8433. }
  8434. declare module BABYLON {
  8435. interface ThinEngine {
  8436. /**
  8437. * Creates a new render target texture
  8438. * @param size defines the size of the texture
  8439. * @param options defines the options used to create the texture
  8440. * @returns a new render target texture stored in an InternalTexture
  8441. */
  8442. createRenderTargetTexture(size: number | {
  8443. width: number;
  8444. height: number;
  8445. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8446. /**
  8447. * Creates a depth stencil texture.
  8448. * This is only available in WebGL 2 or with the depth texture extension available.
  8449. * @param size The size of face edge in the texture.
  8450. * @param options The options defining the texture.
  8451. * @returns The texture
  8452. */
  8453. createDepthStencilTexture(size: number | {
  8454. width: number;
  8455. height: number;
  8456. }, options: DepthTextureCreationOptions): InternalTexture;
  8457. /** @hidden */
  8458. _createDepthStencilTexture(size: number | {
  8459. width: number;
  8460. height: number;
  8461. }, options: DepthTextureCreationOptions): InternalTexture;
  8462. }
  8463. }
  8464. declare module BABYLON {
  8465. /** Defines supported spaces */
  8466. export enum Space {
  8467. /** Local (object) space */
  8468. LOCAL = 0,
  8469. /** World space */
  8470. WORLD = 1,
  8471. /** Bone space */
  8472. BONE = 2
  8473. }
  8474. /** Defines the 3 main axes */
  8475. export class Axis {
  8476. /** X axis */
  8477. static X: Vector3;
  8478. /** Y axis */
  8479. static Y: Vector3;
  8480. /** Z axis */
  8481. static Z: Vector3;
  8482. }
  8483. }
  8484. declare module BABYLON {
  8485. /**
  8486. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8487. * This is the base of the follow, arc rotate cameras and Free camera
  8488. * @see http://doc.babylonjs.com/features/cameras
  8489. */
  8490. export class TargetCamera extends Camera {
  8491. private static _RigCamTransformMatrix;
  8492. private static _TargetTransformMatrix;
  8493. private static _TargetFocalPoint;
  8494. /**
  8495. * Define the current direction the camera is moving to
  8496. */
  8497. cameraDirection: Vector3;
  8498. /**
  8499. * Define the current rotation the camera is rotating to
  8500. */
  8501. cameraRotation: Vector2;
  8502. /**
  8503. * When set, the up vector of the camera will be updated by the rotation of the camera
  8504. */
  8505. updateUpVectorFromRotation: boolean;
  8506. private _tmpQuaternion;
  8507. /**
  8508. * Define the current rotation of the camera
  8509. */
  8510. rotation: Vector3;
  8511. /**
  8512. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8513. */
  8514. rotationQuaternion: Quaternion;
  8515. /**
  8516. * Define the current speed of the camera
  8517. */
  8518. speed: number;
  8519. /**
  8520. * Add constraint to the camera to prevent it to move freely in all directions and
  8521. * around all axis.
  8522. */
  8523. noRotationConstraint: boolean;
  8524. /**
  8525. * Define the current target of the camera as an object or a position.
  8526. */
  8527. lockedTarget: any;
  8528. /** @hidden */
  8529. _currentTarget: Vector3;
  8530. /** @hidden */
  8531. _initialFocalDistance: number;
  8532. /** @hidden */
  8533. _viewMatrix: Matrix;
  8534. /** @hidden */
  8535. _camMatrix: Matrix;
  8536. /** @hidden */
  8537. _cameraTransformMatrix: Matrix;
  8538. /** @hidden */
  8539. _cameraRotationMatrix: Matrix;
  8540. /** @hidden */
  8541. _referencePoint: Vector3;
  8542. /** @hidden */
  8543. _transformedReferencePoint: Vector3;
  8544. protected _globalCurrentTarget: Vector3;
  8545. protected _globalCurrentUpVector: Vector3;
  8546. /** @hidden */
  8547. _reset: () => void;
  8548. private _defaultUp;
  8549. /**
  8550. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8551. * This is the base of the follow, arc rotate cameras and Free camera
  8552. * @see http://doc.babylonjs.com/features/cameras
  8553. * @param name Defines the name of the camera in the scene
  8554. * @param position Defines the start position of the camera in the scene
  8555. * @param scene Defines the scene the camera belongs to
  8556. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8557. */
  8558. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8559. /**
  8560. * Gets the position in front of the camera at a given distance.
  8561. * @param distance The distance from the camera we want the position to be
  8562. * @returns the position
  8563. */
  8564. getFrontPosition(distance: number): Vector3;
  8565. /** @hidden */
  8566. _getLockedTargetPosition(): Nullable<Vector3>;
  8567. private _storedPosition;
  8568. private _storedRotation;
  8569. private _storedRotationQuaternion;
  8570. /**
  8571. * Store current camera state of the camera (fov, position, rotation, etc..)
  8572. * @returns the camera
  8573. */
  8574. storeState(): Camera;
  8575. /**
  8576. * Restored camera state. You must call storeState() first
  8577. * @returns whether it was successful or not
  8578. * @hidden
  8579. */
  8580. _restoreStateValues(): boolean;
  8581. /** @hidden */
  8582. _initCache(): void;
  8583. /** @hidden */
  8584. _updateCache(ignoreParentClass?: boolean): void;
  8585. /** @hidden */
  8586. _isSynchronizedViewMatrix(): boolean;
  8587. /** @hidden */
  8588. _computeLocalCameraSpeed(): number;
  8589. /**
  8590. * Defines the target the camera should look at.
  8591. * @param target Defines the new target as a Vector or a mesh
  8592. */
  8593. setTarget(target: Vector3): void;
  8594. /**
  8595. * Return the current target position of the camera. This value is expressed in local space.
  8596. * @returns the target position
  8597. */
  8598. getTarget(): Vector3;
  8599. /** @hidden */
  8600. _decideIfNeedsToMove(): boolean;
  8601. /** @hidden */
  8602. _updatePosition(): void;
  8603. /** @hidden */
  8604. _checkInputs(): void;
  8605. protected _updateCameraRotationMatrix(): void;
  8606. /**
  8607. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8608. * @returns the current camera
  8609. */
  8610. private _rotateUpVectorWithCameraRotationMatrix;
  8611. private _cachedRotationZ;
  8612. private _cachedQuaternionRotationZ;
  8613. /** @hidden */
  8614. _getViewMatrix(): Matrix;
  8615. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8616. /**
  8617. * @hidden
  8618. */
  8619. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8620. /**
  8621. * @hidden
  8622. */
  8623. _updateRigCameras(): void;
  8624. private _getRigCamPositionAndTarget;
  8625. /**
  8626. * Gets the current object class name.
  8627. * @return the class name
  8628. */
  8629. getClassName(): string;
  8630. }
  8631. }
  8632. declare module BABYLON {
  8633. /**
  8634. * Gather the list of keyboard event types as constants.
  8635. */
  8636. export class KeyboardEventTypes {
  8637. /**
  8638. * The keydown event is fired when a key becomes active (pressed).
  8639. */
  8640. static readonly KEYDOWN: number;
  8641. /**
  8642. * The keyup event is fired when a key has been released.
  8643. */
  8644. static readonly KEYUP: number;
  8645. }
  8646. /**
  8647. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8648. */
  8649. export class KeyboardInfo {
  8650. /**
  8651. * Defines the type of event (KeyboardEventTypes)
  8652. */
  8653. type: number;
  8654. /**
  8655. * Defines the related dom event
  8656. */
  8657. event: KeyboardEvent;
  8658. /**
  8659. * Instantiates a new keyboard info.
  8660. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8661. * @param type Defines the type of event (KeyboardEventTypes)
  8662. * @param event Defines the related dom event
  8663. */
  8664. constructor(
  8665. /**
  8666. * Defines the type of event (KeyboardEventTypes)
  8667. */
  8668. type: number,
  8669. /**
  8670. * Defines the related dom event
  8671. */
  8672. event: KeyboardEvent);
  8673. }
  8674. /**
  8675. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8676. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8677. */
  8678. export class KeyboardInfoPre extends KeyboardInfo {
  8679. /**
  8680. * Defines the type of event (KeyboardEventTypes)
  8681. */
  8682. type: number;
  8683. /**
  8684. * Defines the related dom event
  8685. */
  8686. event: KeyboardEvent;
  8687. /**
  8688. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8689. */
  8690. skipOnPointerObservable: boolean;
  8691. /**
  8692. * Instantiates a new keyboard pre info.
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * @param type Defines the type of event (KeyboardEventTypes)
  8695. * @param event Defines the related dom event
  8696. */
  8697. constructor(
  8698. /**
  8699. * Defines the type of event (KeyboardEventTypes)
  8700. */
  8701. type: number,
  8702. /**
  8703. * Defines the related dom event
  8704. */
  8705. event: KeyboardEvent);
  8706. }
  8707. }
  8708. declare module BABYLON {
  8709. /**
  8710. * Manage the keyboard inputs to control the movement of a free camera.
  8711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8712. */
  8713. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8714. /**
  8715. * Defines the camera the input is attached to.
  8716. */
  8717. camera: FreeCamera;
  8718. /**
  8719. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8720. */
  8721. keysUp: number[];
  8722. /**
  8723. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8724. */
  8725. keysDown: number[];
  8726. /**
  8727. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8728. */
  8729. keysLeft: number[];
  8730. /**
  8731. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8732. */
  8733. keysRight: number[];
  8734. private _keys;
  8735. private _onCanvasBlurObserver;
  8736. private _onKeyboardObserver;
  8737. private _engine;
  8738. private _scene;
  8739. /**
  8740. * Attach the input controls to a specific dom element to get the input from.
  8741. * @param element Defines the element the controls should be listened from
  8742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8743. */
  8744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8745. /**
  8746. * Detach the current controls from the specified dom element.
  8747. * @param element Defines the element to stop listening the inputs from
  8748. */
  8749. detachControl(element: Nullable<HTMLElement>): void;
  8750. /**
  8751. * Update the current camera state depending on the inputs that have been used this frame.
  8752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8753. */
  8754. checkInputs(): void;
  8755. /**
  8756. * Gets the class name of the current intput.
  8757. * @returns the class name
  8758. */
  8759. getClassName(): string;
  8760. /** @hidden */
  8761. _onLostFocus(): void;
  8762. /**
  8763. * Get the friendly name associated with the input class.
  8764. * @returns the input friendly name
  8765. */
  8766. getSimpleName(): string;
  8767. }
  8768. }
  8769. declare module BABYLON {
  8770. /**
  8771. * Interface describing all the common properties and methods a shadow light needs to implement.
  8772. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8773. * as well as binding the different shadow properties to the effects.
  8774. */
  8775. export interface IShadowLight extends Light {
  8776. /**
  8777. * The light id in the scene (used in scene.findLighById for instance)
  8778. */
  8779. id: string;
  8780. /**
  8781. * The position the shdow will be casted from.
  8782. */
  8783. position: Vector3;
  8784. /**
  8785. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8786. */
  8787. direction: Vector3;
  8788. /**
  8789. * The transformed position. Position of the light in world space taking parenting in account.
  8790. */
  8791. transformedPosition: Vector3;
  8792. /**
  8793. * The transformed direction. Direction of the light in world space taking parenting in account.
  8794. */
  8795. transformedDirection: Vector3;
  8796. /**
  8797. * The friendly name of the light in the scene.
  8798. */
  8799. name: string;
  8800. /**
  8801. * Defines the shadow projection clipping minimum z value.
  8802. */
  8803. shadowMinZ: number;
  8804. /**
  8805. * Defines the shadow projection clipping maximum z value.
  8806. */
  8807. shadowMaxZ: number;
  8808. /**
  8809. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8810. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8811. */
  8812. computeTransformedInformation(): boolean;
  8813. /**
  8814. * Gets the scene the light belongs to.
  8815. * @returns The scene
  8816. */
  8817. getScene(): Scene;
  8818. /**
  8819. * Callback defining a custom Projection Matrix Builder.
  8820. * This can be used to override the default projection matrix computation.
  8821. */
  8822. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8823. /**
  8824. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8825. * @param matrix The materix to updated with the projection information
  8826. * @param viewMatrix The transform matrix of the light
  8827. * @param renderList The list of mesh to render in the map
  8828. * @returns The current light
  8829. */
  8830. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8831. /**
  8832. * Gets the current depth scale used in ESM.
  8833. * @returns The scale
  8834. */
  8835. getDepthScale(): number;
  8836. /**
  8837. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8838. * @returns true if a cube texture needs to be use
  8839. */
  8840. needCube(): boolean;
  8841. /**
  8842. * Detects if the projection matrix requires to be recomputed this frame.
  8843. * @returns true if it requires to be recomputed otherwise, false.
  8844. */
  8845. needProjectionMatrixCompute(): boolean;
  8846. /**
  8847. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8848. */
  8849. forceProjectionMatrixCompute(): void;
  8850. /**
  8851. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8852. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8853. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8854. */
  8855. getShadowDirection(faceIndex?: number): Vector3;
  8856. /**
  8857. * Gets the minZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the min for
  8859. * @returns the depth min z
  8860. */
  8861. getDepthMinZ(activeCamera: Camera): number;
  8862. /**
  8863. * Gets the maxZ used for shadow according to both the scene and the light.
  8864. * @param activeCamera The camera we are returning the max for
  8865. * @returns the depth max z
  8866. */
  8867. getDepthMaxZ(activeCamera: Camera): number;
  8868. }
  8869. /**
  8870. * Base implementation IShadowLight
  8871. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8872. */
  8873. export abstract class ShadowLight extends Light implements IShadowLight {
  8874. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8875. protected _position: Vector3;
  8876. protected _setPosition(value: Vector3): void;
  8877. /**
  8878. * Sets the position the shadow will be casted from. Also use as the light position for both
  8879. * point and spot lights.
  8880. */
  8881. get position(): Vector3;
  8882. /**
  8883. * Sets the position the shadow will be casted from. Also use as the light position for both
  8884. * point and spot lights.
  8885. */
  8886. set position(value: Vector3);
  8887. protected _direction: Vector3;
  8888. protected _setDirection(value: Vector3): void;
  8889. /**
  8890. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8891. * Also use as the light direction on spot and directional lights.
  8892. */
  8893. get direction(): Vector3;
  8894. /**
  8895. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8896. * Also use as the light direction on spot and directional lights.
  8897. */
  8898. set direction(value: Vector3);
  8899. protected _shadowMinZ: number;
  8900. /**
  8901. * Gets the shadow projection clipping minimum z value.
  8902. */
  8903. get shadowMinZ(): number;
  8904. /**
  8905. * Sets the shadow projection clipping minimum z value.
  8906. */
  8907. set shadowMinZ(value: number);
  8908. protected _shadowMaxZ: number;
  8909. /**
  8910. * Sets the shadow projection clipping maximum z value.
  8911. */
  8912. get shadowMaxZ(): number;
  8913. /**
  8914. * Gets the shadow projection clipping maximum z value.
  8915. */
  8916. set shadowMaxZ(value: number);
  8917. /**
  8918. * Callback defining a custom Projection Matrix Builder.
  8919. * This can be used to override the default projection matrix computation.
  8920. */
  8921. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8922. /**
  8923. * The transformed position. Position of the light in world space taking parenting in account.
  8924. */
  8925. transformedPosition: Vector3;
  8926. /**
  8927. * The transformed direction. Direction of the light in world space taking parenting in account.
  8928. */
  8929. transformedDirection: Vector3;
  8930. private _needProjectionMatrixCompute;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Return the depth scale used for the shadow map.
  8938. * @returns the depth scale.
  8939. */
  8940. getDepthScale(): number;
  8941. /**
  8942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8945. */
  8946. getShadowDirection(faceIndex?: number): Vector3;
  8947. /**
  8948. * Returns the ShadowLight absolute position in the World.
  8949. * @returns the position vector in world space
  8950. */
  8951. getAbsolutePosition(): Vector3;
  8952. /**
  8953. * Sets the ShadowLight direction toward the passed target.
  8954. * @param target The point to target in local space
  8955. * @returns the updated ShadowLight direction
  8956. */
  8957. setDirectionToTarget(target: Vector3): Vector3;
  8958. /**
  8959. * Returns the light rotation in euler definition.
  8960. * @returns the x y z rotation in local space.
  8961. */
  8962. getRotation(): Vector3;
  8963. /**
  8964. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8965. * @returns true if a cube texture needs to be use
  8966. */
  8967. needCube(): boolean;
  8968. /**
  8969. * Detects if the projection matrix requires to be recomputed this frame.
  8970. * @returns true if it requires to be recomputed otherwise, false.
  8971. */
  8972. needProjectionMatrixCompute(): boolean;
  8973. /**
  8974. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8975. */
  8976. forceProjectionMatrixCompute(): void;
  8977. /** @hidden */
  8978. _initCache(): void;
  8979. /** @hidden */
  8980. _isSynchronized(): boolean;
  8981. /**
  8982. * Computes the world matrix of the node
  8983. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8984. * @returns the world matrix
  8985. */
  8986. computeWorldMatrix(force?: boolean): Matrix;
  8987. /**
  8988. * Gets the minZ used for shadow according to both the scene and the light.
  8989. * @param activeCamera The camera we are returning the min for
  8990. * @returns the depth min z
  8991. */
  8992. getDepthMinZ(activeCamera: Camera): number;
  8993. /**
  8994. * Gets the maxZ used for shadow according to both the scene and the light.
  8995. * @param activeCamera The camera we are returning the max for
  8996. * @returns the depth max z
  8997. */
  8998. getDepthMaxZ(activeCamera: Camera): number;
  8999. /**
  9000. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9001. * @param matrix The materix to updated with the projection information
  9002. * @param viewMatrix The transform matrix of the light
  9003. * @param renderList The list of mesh to render in the map
  9004. * @returns The current light
  9005. */
  9006. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /**
  9011. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9012. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9013. */
  9014. export class EffectFallbacks implements IEffectFallbacks {
  9015. private _defines;
  9016. private _currentRank;
  9017. private _maxRank;
  9018. private _mesh;
  9019. /**
  9020. * Removes the fallback from the bound mesh.
  9021. */
  9022. unBindMesh(): void;
  9023. /**
  9024. * Adds a fallback on the specified property.
  9025. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9026. * @param define The name of the define in the shader
  9027. */
  9028. addFallback(rank: number, define: string): void;
  9029. /**
  9030. * Sets the mesh to use CPU skinning when needing to fallback.
  9031. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9032. * @param mesh The mesh to use the fallbacks.
  9033. */
  9034. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9035. /**
  9036. * Checks to see if more fallbacks are still availible.
  9037. */
  9038. get hasMoreFallbacks(): boolean;
  9039. /**
  9040. * Removes the defines that should be removed when falling back.
  9041. * @param currentDefines defines the current define statements for the shader.
  9042. * @param effect defines the current effect we try to compile
  9043. * @returns The resulting defines with defines of the current rank removed.
  9044. */
  9045. reduce(currentDefines: string, effect: Effect): string;
  9046. }
  9047. }
  9048. declare module BABYLON {
  9049. /**
  9050. * "Static Class" containing the most commonly used helper while dealing with material for
  9051. * rendering purpose.
  9052. *
  9053. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9054. *
  9055. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9056. */
  9057. export class MaterialHelper {
  9058. /**
  9059. * Bind the current view position to an effect.
  9060. * @param effect The effect to be bound
  9061. * @param scene The scene the eyes position is used from
  9062. */
  9063. static BindEyePosition(effect: Effect, scene: Scene): void;
  9064. /**
  9065. * Helps preparing the defines values about the UVs in used in the effect.
  9066. * UVs are shared as much as we can accross channels in the shaders.
  9067. * @param texture The texture we are preparing the UVs for
  9068. * @param defines The defines to update
  9069. * @param key The channel key "diffuse", "specular"... used in the shader
  9070. */
  9071. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9072. /**
  9073. * Binds a texture matrix value to its corrsponding uniform
  9074. * @param texture The texture to bind the matrix for
  9075. * @param uniformBuffer The uniform buffer receivin the data
  9076. * @param key The channel key "diffuse", "specular"... used in the shader
  9077. */
  9078. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9079. /**
  9080. * Gets the current status of the fog (should it be enabled?)
  9081. * @param mesh defines the mesh to evaluate for fog support
  9082. * @param scene defines the hosting scene
  9083. * @returns true if fog must be enabled
  9084. */
  9085. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9086. /**
  9087. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9088. * @param mesh defines the current mesh
  9089. * @param scene defines the current scene
  9090. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9091. * @param pointsCloud defines if point cloud rendering has to be turned on
  9092. * @param fogEnabled defines if fog has to be turned on
  9093. * @param alphaTest defines if alpha testing has to be turned on
  9094. * @param defines defines the current list of defines
  9095. */
  9096. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9097. /**
  9098. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9099. * @param scene defines the current scene
  9100. * @param engine defines the current engine
  9101. * @param defines specifies the list of active defines
  9102. * @param useInstances defines if instances have to be turned on
  9103. * @param useClipPlane defines if clip plane have to be turned on
  9104. */
  9105. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9106. /**
  9107. * Prepares the defines for bones
  9108. * @param mesh The mesh containing the geometry data we will draw
  9109. * @param defines The defines to update
  9110. */
  9111. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9112. /**
  9113. * Prepares the defines for morph targets
  9114. * @param mesh The mesh containing the geometry data we will draw
  9115. * @param defines The defines to update
  9116. */
  9117. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9118. /**
  9119. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9120. * @param mesh The mesh containing the geometry data we will draw
  9121. * @param defines The defines to update
  9122. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9123. * @param useBones Precise whether bones should be used or not (override mesh info)
  9124. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9125. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9126. * @returns false if defines are considered not dirty and have not been checked
  9127. */
  9128. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9129. /**
  9130. * Prepares the defines related to multiview
  9131. * @param scene The scene we are intending to draw
  9132. * @param defines The defines to update
  9133. */
  9134. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9135. /**
  9136. * Prepares the defines related to the light information passed in parameter
  9137. * @param scene The scene we are intending to draw
  9138. * @param mesh The mesh the effect is compiling for
  9139. * @param light The light the effect is compiling for
  9140. * @param lightIndex The index of the light
  9141. * @param defines The defines to update
  9142. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9143. * @param state Defines the current state regarding what is needed (normals, etc...)
  9144. */
  9145. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9146. needNormals: boolean;
  9147. needRebuild: boolean;
  9148. shadowEnabled: boolean;
  9149. specularEnabled: boolean;
  9150. lightmapMode: boolean;
  9151. }): void;
  9152. /**
  9153. * Prepares the defines related to the light information passed in parameter
  9154. * @param scene The scene we are intending to draw
  9155. * @param mesh The mesh the effect is compiling for
  9156. * @param defines The defines to update
  9157. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9158. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9159. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9160. * @returns true if normals will be required for the rest of the effect
  9161. */
  9162. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9163. /**
  9164. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9165. * @param lightIndex defines the light index
  9166. * @param uniformsList The uniform list
  9167. * @param samplersList The sampler list
  9168. * @param projectedLightTexture defines if projected texture must be used
  9169. * @param uniformBuffersList defines an optional list of uniform buffers
  9170. */
  9171. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9172. /**
  9173. * Prepares the uniforms and samplers list to be used in the effect
  9174. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9175. * @param samplersList The sampler list
  9176. * @param defines The defines helping in the list generation
  9177. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9178. */
  9179. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9180. /**
  9181. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9182. * @param defines The defines to update while falling back
  9183. * @param fallbacks The authorized effect fallbacks
  9184. * @param maxSimultaneousLights The maximum number of lights allowed
  9185. * @param rank the current rank of the Effect
  9186. * @returns The newly affected rank
  9187. */
  9188. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9189. private static _TmpMorphInfluencers;
  9190. /**
  9191. * Prepares the list of attributes required for morph targets according to the effect defines.
  9192. * @param attribs The current list of supported attribs
  9193. * @param mesh The mesh to prepare the morph targets attributes for
  9194. * @param influencers The number of influencers
  9195. */
  9196. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9197. /**
  9198. * Prepares the list of attributes required for morph targets according to the effect defines.
  9199. * @param attribs The current list of supported attribs
  9200. * @param mesh The mesh to prepare the morph targets attributes for
  9201. * @param defines The current Defines of the effect
  9202. */
  9203. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9204. /**
  9205. * Prepares the list of attributes required for bones according to the effect defines.
  9206. * @param attribs The current list of supported attribs
  9207. * @param mesh The mesh to prepare the bones attributes for
  9208. * @param defines The current Defines of the effect
  9209. * @param fallbacks The current efffect fallback strategy
  9210. */
  9211. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9212. /**
  9213. * Check and prepare the list of attributes required for instances according to the effect defines.
  9214. * @param attribs The current list of supported attribs
  9215. * @param defines The current MaterialDefines of the effect
  9216. */
  9217. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9218. /**
  9219. * Add the list of attributes required for instances to the attribs array.
  9220. * @param attribs The current list of supported attribs
  9221. */
  9222. static PushAttributesForInstances(attribs: string[]): void;
  9223. /**
  9224. * Binds the light information to the effect.
  9225. * @param light The light containing the generator
  9226. * @param effect The effect we are binding the data to
  9227. * @param lightIndex The light index in the effect used to render
  9228. */
  9229. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9230. /**
  9231. * Binds the lights information from the scene to the effect for the given mesh.
  9232. * @param light Light to bind
  9233. * @param lightIndex Light index
  9234. * @param scene The scene where the light belongs to
  9235. * @param effect The effect we are binding the data to
  9236. * @param useSpecular Defines if specular is supported
  9237. * @param 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. * Utility function to detect if the current user agent is Safari
  34260. * @returns whether or not the current user agent is safari
  34261. */
  34262. static IsSafari(): boolean;
  34263. }
  34264. /**
  34265. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34266. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34267. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34268. * @param name The name of the class, case should be preserved
  34269. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34270. */
  34271. export function className(name: string, module?: string): (target: Object) => void;
  34272. /**
  34273. * An implementation of a loop for asynchronous functions.
  34274. */
  34275. export class AsyncLoop {
  34276. /**
  34277. * Defines the number of iterations for the loop
  34278. */
  34279. iterations: number;
  34280. /**
  34281. * Defines the current index of the loop.
  34282. */
  34283. index: number;
  34284. private _done;
  34285. private _fn;
  34286. private _successCallback;
  34287. /**
  34288. * Constructor.
  34289. * @param iterations the number of iterations.
  34290. * @param func the function to run each iteration
  34291. * @param successCallback the callback that will be called upon succesful execution
  34292. * @param offset starting offset.
  34293. */
  34294. constructor(
  34295. /**
  34296. * Defines the number of iterations for the loop
  34297. */
  34298. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34299. /**
  34300. * Execute the next iteration. Must be called after the last iteration was finished.
  34301. */
  34302. executeNext(): void;
  34303. /**
  34304. * Break the loop and run the success callback.
  34305. */
  34306. breakLoop(): void;
  34307. /**
  34308. * Create and run an async loop.
  34309. * @param iterations the number of iterations.
  34310. * @param fn the function to run each iteration
  34311. * @param successCallback the callback that will be called upon succesful execution
  34312. * @param offset starting offset.
  34313. * @returns the created async loop object
  34314. */
  34315. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34316. /**
  34317. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34318. * @param iterations total number of iterations
  34319. * @param syncedIterations number of synchronous iterations in each async iteration.
  34320. * @param fn the function to call each iteration.
  34321. * @param callback a success call back that will be called when iterating stops.
  34322. * @param breakFunction a break condition (optional)
  34323. * @param timeout timeout settings for the setTimeout function. default - 0.
  34324. * @returns the created async loop object
  34325. */
  34326. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34327. }
  34328. }
  34329. declare module BABYLON {
  34330. /**
  34331. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34332. * The underlying implementation relies on an associative array to ensure the best performances.
  34333. * The value can be anything including 'null' but except 'undefined'
  34334. */
  34335. export class StringDictionary<T> {
  34336. /**
  34337. * This will clear this dictionary and copy the content from the 'source' one.
  34338. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34339. * @param source the dictionary to take the content from and copy to this dictionary
  34340. */
  34341. copyFrom(source: StringDictionary<T>): void;
  34342. /**
  34343. * Get a value based from its key
  34344. * @param key the given key to get the matching value from
  34345. * @return the value if found, otherwise undefined is returned
  34346. */
  34347. get(key: string): T | undefined;
  34348. /**
  34349. * Get a value from its key or add it if it doesn't exist.
  34350. * This method will ensure you that a given key/data will be present in the dictionary.
  34351. * @param key the given key to get the matching value from
  34352. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34353. * The factory will only be invoked if there's no data for the given key.
  34354. * @return the value corresponding to the key.
  34355. */
  34356. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34357. /**
  34358. * Get a value from its key if present in the dictionary otherwise add it
  34359. * @param key the key to get the value from
  34360. * @param val if there's no such key/value pair in the dictionary add it with this value
  34361. * @return the value corresponding to the key
  34362. */
  34363. getOrAdd(key: string, val: T): T;
  34364. /**
  34365. * Check if there's a given key in the dictionary
  34366. * @param key the key to check for
  34367. * @return true if the key is present, false otherwise
  34368. */
  34369. contains(key: string): boolean;
  34370. /**
  34371. * Add a new key and its corresponding value
  34372. * @param key the key to add
  34373. * @param value the value corresponding to the key
  34374. * @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
  34375. */
  34376. add(key: string, value: T): boolean;
  34377. /**
  34378. * Update a specific value associated to a key
  34379. * @param key defines the key to use
  34380. * @param value defines the value to store
  34381. * @returns true if the value was updated (or false if the key was not found)
  34382. */
  34383. set(key: string, value: T): boolean;
  34384. /**
  34385. * Get the element of the given key and remove it from the dictionary
  34386. * @param key defines the key to search
  34387. * @returns the value associated with the key or null if not found
  34388. */
  34389. getAndRemove(key: string): Nullable<T>;
  34390. /**
  34391. * Remove a key/value from the dictionary.
  34392. * @param key the key to remove
  34393. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34394. */
  34395. remove(key: string): boolean;
  34396. /**
  34397. * Clear the whole content of the dictionary
  34398. */
  34399. clear(): void;
  34400. /**
  34401. * Gets the current count
  34402. */
  34403. get count(): number;
  34404. /**
  34405. * Execute a callback on each key/val of the dictionary.
  34406. * Note that you can remove any element in this dictionary in the callback implementation
  34407. * @param callback the callback to execute on a given key/value pair
  34408. */
  34409. forEach(callback: (key: string, val: T) => void): void;
  34410. /**
  34411. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34412. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34413. * Note that you can remove any element in this dictionary in the callback implementation
  34414. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34415. * @returns the first item
  34416. */
  34417. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34418. private _count;
  34419. private _data;
  34420. }
  34421. }
  34422. declare module BABYLON {
  34423. /** @hidden */
  34424. export interface ICollisionCoordinator {
  34425. createCollider(): Collider;
  34426. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34427. init(scene: Scene): void;
  34428. }
  34429. /** @hidden */
  34430. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34431. private _scene;
  34432. private _scaledPosition;
  34433. private _scaledVelocity;
  34434. private _finalPosition;
  34435. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34436. createCollider(): Collider;
  34437. init(scene: Scene): void;
  34438. private _collideWithWorld;
  34439. }
  34440. }
  34441. declare module BABYLON {
  34442. /**
  34443. * Class used to manage all inputs for the scene.
  34444. */
  34445. export class InputManager {
  34446. /** The distance in pixel that you have to move to prevent some events */
  34447. static DragMovementThreshold: number;
  34448. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34449. static LongPressDelay: number;
  34450. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34451. static DoubleClickDelay: number;
  34452. /** If you need to check double click without raising a single click at first click, enable this flag */
  34453. static ExclusiveDoubleClickMode: boolean;
  34454. private _wheelEventName;
  34455. private _onPointerMove;
  34456. private _onPointerDown;
  34457. private _onPointerUp;
  34458. private _initClickEvent;
  34459. private _initActionManager;
  34460. private _delayedSimpleClick;
  34461. private _delayedSimpleClickTimeout;
  34462. private _previousDelayedSimpleClickTimeout;
  34463. private _meshPickProceed;
  34464. private _previousButtonPressed;
  34465. private _currentPickResult;
  34466. private _previousPickResult;
  34467. private _totalPointersPressed;
  34468. private _doubleClickOccured;
  34469. private _pointerOverMesh;
  34470. private _pickedDownMesh;
  34471. private _pickedUpMesh;
  34472. private _pointerX;
  34473. private _pointerY;
  34474. private _unTranslatedPointerX;
  34475. private _unTranslatedPointerY;
  34476. private _startingPointerPosition;
  34477. private _previousStartingPointerPosition;
  34478. private _startingPointerTime;
  34479. private _previousStartingPointerTime;
  34480. private _pointerCaptures;
  34481. private _onKeyDown;
  34482. private _onKeyUp;
  34483. private _onCanvasFocusObserver;
  34484. private _onCanvasBlurObserver;
  34485. private _scene;
  34486. /**
  34487. * Creates a new InputManager
  34488. * @param scene defines the hosting scene
  34489. */
  34490. constructor(scene: Scene);
  34491. /**
  34492. * Gets the mesh that is currently under the pointer
  34493. */
  34494. get meshUnderPointer(): Nullable<AbstractMesh>;
  34495. /**
  34496. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34497. */
  34498. get unTranslatedPointer(): Vector2;
  34499. /**
  34500. * Gets or sets the current on-screen X position of the pointer
  34501. */
  34502. get pointerX(): number;
  34503. set pointerX(value: number);
  34504. /**
  34505. * Gets or sets the current on-screen Y position of the pointer
  34506. */
  34507. get pointerY(): number;
  34508. set pointerY(value: number);
  34509. private _updatePointerPosition;
  34510. private _processPointerMove;
  34511. private _setRayOnPointerInfo;
  34512. private _checkPrePointerObservable;
  34513. /**
  34514. * Use this method to simulate a pointer move on a mesh
  34515. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34516. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34517. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34518. */
  34519. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34520. /**
  34521. * Use this method to simulate a pointer down on a mesh
  34522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34525. */
  34526. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34527. private _processPointerDown;
  34528. /** @hidden */
  34529. _isPointerSwiping(): boolean;
  34530. /**
  34531. * Use this method to simulate a pointer up on a mesh
  34532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34535. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34536. */
  34537. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34538. private _processPointerUp;
  34539. /**
  34540. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34541. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34542. * @returns true if the pointer was captured
  34543. */
  34544. isPointerCaptured(pointerId?: number): boolean;
  34545. /**
  34546. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34547. * @param attachUp defines if you want to attach events to pointerup
  34548. * @param attachDown defines if you want to attach events to pointerdown
  34549. * @param attachMove defines if you want to attach events to pointermove
  34550. */
  34551. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34552. /**
  34553. * Detaches all event handlers
  34554. */
  34555. detachControl(): void;
  34556. /**
  34557. * Force the value of meshUnderPointer
  34558. * @param mesh defines the mesh to use
  34559. */
  34560. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34561. /**
  34562. * Gets the mesh under the pointer
  34563. * @returns a Mesh or null if no mesh is under the pointer
  34564. */
  34565. getPointerOverMesh(): Nullable<AbstractMesh>;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * Helper class used to generate session unique ID
  34571. */
  34572. export class UniqueIdGenerator {
  34573. private static _UniqueIdCounter;
  34574. /**
  34575. * Gets an unique (relatively to the current scene) Id
  34576. */
  34577. static get UniqueId(): number;
  34578. }
  34579. }
  34580. declare module BABYLON {
  34581. /**
  34582. * This class defines the direct association between an animation and a target
  34583. */
  34584. export class TargetedAnimation {
  34585. /**
  34586. * Animation to perform
  34587. */
  34588. animation: Animation;
  34589. /**
  34590. * Target to animate
  34591. */
  34592. target: any;
  34593. /**
  34594. * Serialize the object
  34595. * @returns the JSON object representing the current entity
  34596. */
  34597. serialize(): any;
  34598. }
  34599. /**
  34600. * Use this class to create coordinated animations on multiple targets
  34601. */
  34602. export class AnimationGroup implements IDisposable {
  34603. /** The name of the animation group */
  34604. name: string;
  34605. private _scene;
  34606. private _targetedAnimations;
  34607. private _animatables;
  34608. private _from;
  34609. private _to;
  34610. private _isStarted;
  34611. private _isPaused;
  34612. private _speedRatio;
  34613. private _loopAnimation;
  34614. /**
  34615. * Gets or sets the unique id of the node
  34616. */
  34617. uniqueId: number;
  34618. /**
  34619. * This observable will notify when one animation have ended
  34620. */
  34621. onAnimationEndObservable: Observable<TargetedAnimation>;
  34622. /**
  34623. * Observer raised when one animation loops
  34624. */
  34625. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34626. /**
  34627. * Observer raised when all animations have looped
  34628. */
  34629. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34630. /**
  34631. * This observable will notify when all animations have ended.
  34632. */
  34633. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34634. /**
  34635. * This observable will notify when all animations have paused.
  34636. */
  34637. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34638. /**
  34639. * This observable will notify when all animations are playing.
  34640. */
  34641. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34642. /**
  34643. * Gets the first frame
  34644. */
  34645. get from(): number;
  34646. /**
  34647. * Gets the last frame
  34648. */
  34649. get to(): number;
  34650. /**
  34651. * Define if the animations are started
  34652. */
  34653. get isStarted(): boolean;
  34654. /**
  34655. * Gets a value indicating that the current group is playing
  34656. */
  34657. get isPlaying(): boolean;
  34658. /**
  34659. * Gets or sets the speed ratio to use for all animations
  34660. */
  34661. get speedRatio(): number;
  34662. /**
  34663. * Gets or sets the speed ratio to use for all animations
  34664. */
  34665. set speedRatio(value: number);
  34666. /**
  34667. * Gets or sets if all animations should loop or not
  34668. */
  34669. get loopAnimation(): boolean;
  34670. set loopAnimation(value: boolean);
  34671. /**
  34672. * Gets the targeted animations for this animation group
  34673. */
  34674. get targetedAnimations(): Array<TargetedAnimation>;
  34675. /**
  34676. * returning the list of animatables controlled by this animation group.
  34677. */
  34678. get animatables(): Array<Animatable>;
  34679. /**
  34680. * Instantiates a new Animation Group.
  34681. * This helps managing several animations at once.
  34682. * @see http://doc.babylonjs.com/how_to/group
  34683. * @param name Defines the name of the group
  34684. * @param scene Defines the scene the group belongs to
  34685. */
  34686. constructor(
  34687. /** The name of the animation group */
  34688. name: string, scene?: Nullable<Scene>);
  34689. /**
  34690. * Add an animation (with its target) in the group
  34691. * @param animation defines the animation we want to add
  34692. * @param target defines the target of the animation
  34693. * @returns the TargetedAnimation object
  34694. */
  34695. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34696. /**
  34697. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34698. * It can add constant keys at begin or end
  34699. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34700. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34701. * @returns the animation group
  34702. */
  34703. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34704. private _animationLoopCount;
  34705. private _animationLoopFlags;
  34706. private _processLoop;
  34707. /**
  34708. * Start all animations on given targets
  34709. * @param loop defines if animations must loop
  34710. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34711. * @param from defines the from key (optional)
  34712. * @param to defines the to key (optional)
  34713. * @returns the current animation group
  34714. */
  34715. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34716. /**
  34717. * Pause all animations
  34718. * @returns the animation group
  34719. */
  34720. pause(): AnimationGroup;
  34721. /**
  34722. * Play all animations to initial state
  34723. * This function will start() the animations if they were not started or will restart() them if they were paused
  34724. * @param loop defines if animations must loop
  34725. * @returns the animation group
  34726. */
  34727. play(loop?: boolean): AnimationGroup;
  34728. /**
  34729. * Reset all animations to initial state
  34730. * @returns the animation group
  34731. */
  34732. reset(): AnimationGroup;
  34733. /**
  34734. * Restart animations from key 0
  34735. * @returns the animation group
  34736. */
  34737. restart(): AnimationGroup;
  34738. /**
  34739. * Stop all animations
  34740. * @returns the animation group
  34741. */
  34742. stop(): AnimationGroup;
  34743. /**
  34744. * Set animation weight for all animatables
  34745. * @param weight defines the weight to use
  34746. * @return the animationGroup
  34747. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34748. */
  34749. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34750. /**
  34751. * Synchronize and normalize all animatables with a source animatable
  34752. * @param root defines the root animatable to synchronize with
  34753. * @return the animationGroup
  34754. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34755. */
  34756. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34757. /**
  34758. * Goes to a specific frame in this animation group
  34759. * @param frame the frame number to go to
  34760. * @return the animationGroup
  34761. */
  34762. goToFrame(frame: number): AnimationGroup;
  34763. /**
  34764. * Dispose all associated resources
  34765. */
  34766. dispose(): void;
  34767. private _checkAnimationGroupEnded;
  34768. /**
  34769. * Clone the current animation group and returns a copy
  34770. * @param newName defines the name of the new group
  34771. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34772. * @returns the new aniamtion group
  34773. */
  34774. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34775. /**
  34776. * Serializes the animationGroup to an object
  34777. * @returns Serialized object
  34778. */
  34779. serialize(): any;
  34780. /**
  34781. * Returns a new AnimationGroup object parsed from the source provided.
  34782. * @param parsedAnimationGroup defines the source
  34783. * @param scene defines the scene that will receive the animationGroup
  34784. * @returns a new AnimationGroup
  34785. */
  34786. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34787. /**
  34788. * Returns the string "AnimationGroup"
  34789. * @returns "AnimationGroup"
  34790. */
  34791. getClassName(): string;
  34792. /**
  34793. * Creates a detailled string about the object
  34794. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34795. * @returns a string representing the object
  34796. */
  34797. toString(fullDetails?: boolean): string;
  34798. }
  34799. }
  34800. declare module BABYLON {
  34801. /**
  34802. * Define an interface for all classes that will hold resources
  34803. */
  34804. export interface IDisposable {
  34805. /**
  34806. * Releases all held resources
  34807. */
  34808. dispose(): void;
  34809. }
  34810. /** Interface defining initialization parameters for Scene class */
  34811. export interface SceneOptions {
  34812. /**
  34813. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34814. * It will improve performance when the number of geometries becomes important.
  34815. */
  34816. useGeometryUniqueIdsMap?: boolean;
  34817. /**
  34818. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  34822. /**
  34823. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34824. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34825. */
  34826. useClonedMeshMap?: boolean;
  34827. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34828. virtual?: boolean;
  34829. }
  34830. /**
  34831. * Represents a scene to be rendered by the engine.
  34832. * @see http://doc.babylonjs.com/features/scene
  34833. */
  34834. export class Scene extends AbstractScene implements IAnimatable {
  34835. /** The fog is deactivated */
  34836. static readonly FOGMODE_NONE: number;
  34837. /** The fog density is following an exponential function */
  34838. static readonly FOGMODE_EXP: number;
  34839. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34840. static readonly FOGMODE_EXP2: number;
  34841. /** The fog density is following a linear function. */
  34842. static readonly FOGMODE_LINEAR: number;
  34843. /**
  34844. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34846. */
  34847. static MinDeltaTime: number;
  34848. /**
  34849. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34851. */
  34852. static MaxDeltaTime: number;
  34853. /**
  34854. * Factory used to create the default material.
  34855. * @param name The name of the material to create
  34856. * @param scene The scene to create the material for
  34857. * @returns The default material
  34858. */
  34859. static DefaultMaterialFactory(scene: Scene): Material;
  34860. /**
  34861. * Factory used to create the a collision coordinator.
  34862. * @returns The collision coordinator
  34863. */
  34864. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34865. /** @hidden */
  34866. _inputManager: InputManager;
  34867. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34868. cameraToUseForPointers: Nullable<Camera>;
  34869. /** @hidden */
  34870. readonly _isScene: boolean;
  34871. /**
  34872. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34873. */
  34874. autoClear: boolean;
  34875. /**
  34876. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34877. */
  34878. autoClearDepthAndStencil: boolean;
  34879. /**
  34880. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34881. */
  34882. clearColor: Color4;
  34883. /**
  34884. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34885. */
  34886. ambientColor: Color3;
  34887. /**
  34888. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34889. * It should only be one of the following (if not the default embedded one):
  34890. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34891. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34892. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34893. * The material properties need to be setup according to the type of texture in use.
  34894. */
  34895. environmentBRDFTexture: BaseTexture;
  34896. /** @hidden */
  34897. protected _environmentTexture: Nullable<BaseTexture>;
  34898. /**
  34899. * Texture used in all pbr material as the reflection texture.
  34900. * As in the majority of the scene they are the same (exception for multi room and so on),
  34901. * this is easier to reference from here than from all the materials.
  34902. */
  34903. get environmentTexture(): Nullable<BaseTexture>;
  34904. /**
  34905. * Texture used in all pbr material as the reflection texture.
  34906. * As in the majority of the scene they are the same (exception for multi room and so on),
  34907. * this is easier to set here than in all the materials.
  34908. */
  34909. set environmentTexture(value: Nullable<BaseTexture>);
  34910. /** @hidden */
  34911. protected _environmentIntensity: number;
  34912. /**
  34913. * Intensity of the environment in all pbr material.
  34914. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34915. * As in the majority of the scene they are the same (exception for multi room and so on),
  34916. * this is easier to reference from here than from all the materials.
  34917. */
  34918. get environmentIntensity(): number;
  34919. /**
  34920. * Intensity of the environment in all pbr material.
  34921. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34922. * As in the majority of the scene they are the same (exception for multi room and so on),
  34923. * this is easier to set here than in all the materials.
  34924. */
  34925. set environmentIntensity(value: number);
  34926. /** @hidden */
  34927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34928. /**
  34929. * Default image processing configuration used either in the rendering
  34930. * Forward main pass or through the imageProcessingPostProcess if present.
  34931. * As in the majority of the scene they are the same (exception for multi camera),
  34932. * this is easier to reference from here than from all the materials and post process.
  34933. *
  34934. * No setter as we it is a shared configuration, you can set the values instead.
  34935. */
  34936. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34937. private _forceWireframe;
  34938. /**
  34939. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34940. */
  34941. set forceWireframe(value: boolean);
  34942. get forceWireframe(): boolean;
  34943. private _skipFrustumClipping;
  34944. /**
  34945. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  34946. */
  34947. set skipFrustumClipping(value: boolean);
  34948. get skipFrustumClipping(): boolean;
  34949. private _forcePointsCloud;
  34950. /**
  34951. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34952. */
  34953. set forcePointsCloud(value: boolean);
  34954. get forcePointsCloud(): boolean;
  34955. /**
  34956. * Gets or sets the active clipplane 1
  34957. */
  34958. clipPlane: Nullable<Plane>;
  34959. /**
  34960. * Gets or sets the active clipplane 2
  34961. */
  34962. clipPlane2: Nullable<Plane>;
  34963. /**
  34964. * Gets or sets the active clipplane 3
  34965. */
  34966. clipPlane3: Nullable<Plane>;
  34967. /**
  34968. * Gets or sets the active clipplane 4
  34969. */
  34970. clipPlane4: Nullable<Plane>;
  34971. /**
  34972. * Gets or sets the active clipplane 5
  34973. */
  34974. clipPlane5: Nullable<Plane>;
  34975. /**
  34976. * Gets or sets the active clipplane 6
  34977. */
  34978. clipPlane6: Nullable<Plane>;
  34979. /**
  34980. * Gets or sets a boolean indicating if animations are enabled
  34981. */
  34982. animationsEnabled: boolean;
  34983. private _animationPropertiesOverride;
  34984. /**
  34985. * Gets or sets the animation properties override
  34986. */
  34987. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34988. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34989. /**
  34990. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34991. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34992. */
  34993. useConstantAnimationDeltaTime: boolean;
  34994. /**
  34995. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34996. * Please note that it requires to run a ray cast through the scene on every frame
  34997. */
  34998. constantlyUpdateMeshUnderPointer: boolean;
  34999. /**
  35000. * Defines the HTML cursor to use when hovering over interactive elements
  35001. */
  35002. hoverCursor: string;
  35003. /**
  35004. * Defines the HTML default cursor to use (empty by default)
  35005. */
  35006. defaultCursor: string;
  35007. /**
  35008. * Defines wether cursors are handled by the scene.
  35009. */
  35010. doNotHandleCursors: boolean;
  35011. /**
  35012. * This is used to call preventDefault() on pointer down
  35013. * in order to block unwanted artifacts like system double clicks
  35014. */
  35015. preventDefaultOnPointerDown: boolean;
  35016. /**
  35017. * This is used to call preventDefault() on pointer up
  35018. * in order to block unwanted artifacts like system double clicks
  35019. */
  35020. preventDefaultOnPointerUp: boolean;
  35021. /**
  35022. * Gets or sets user defined metadata
  35023. */
  35024. metadata: any;
  35025. /**
  35026. * For internal use only. Please do not use.
  35027. */
  35028. reservedDataStore: any;
  35029. /**
  35030. * Gets the name of the plugin used to load this scene (null by default)
  35031. */
  35032. loadingPluginName: string;
  35033. /**
  35034. * Use this array to add regular expressions used to disable offline support for specific urls
  35035. */
  35036. disableOfflineSupportExceptionRules: RegExp[];
  35037. /**
  35038. * An event triggered when the scene is disposed.
  35039. */
  35040. onDisposeObservable: Observable<Scene>;
  35041. private _onDisposeObserver;
  35042. /** Sets a function to be executed when this scene is disposed. */
  35043. set onDispose(callback: () => void);
  35044. /**
  35045. * An event triggered before rendering the scene (right after animations and physics)
  35046. */
  35047. onBeforeRenderObservable: Observable<Scene>;
  35048. private _onBeforeRenderObserver;
  35049. /** Sets a function to be executed before rendering this scene */
  35050. set beforeRender(callback: Nullable<() => void>);
  35051. /**
  35052. * An event triggered after rendering the scene
  35053. */
  35054. onAfterRenderObservable: Observable<Scene>;
  35055. /**
  35056. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35057. */
  35058. onAfterRenderCameraObservable: Observable<Camera>;
  35059. private _onAfterRenderObserver;
  35060. /** Sets a function to be executed after rendering this scene */
  35061. set afterRender(callback: Nullable<() => void>);
  35062. /**
  35063. * An event triggered before animating the scene
  35064. */
  35065. onBeforeAnimationsObservable: Observable<Scene>;
  35066. /**
  35067. * An event triggered after animations processing
  35068. */
  35069. onAfterAnimationsObservable: Observable<Scene>;
  35070. /**
  35071. * An event triggered before draw calls are ready to be sent
  35072. */
  35073. onBeforeDrawPhaseObservable: Observable<Scene>;
  35074. /**
  35075. * An event triggered after draw calls have been sent
  35076. */
  35077. onAfterDrawPhaseObservable: Observable<Scene>;
  35078. /**
  35079. * An event triggered when the scene is ready
  35080. */
  35081. onReadyObservable: Observable<Scene>;
  35082. /**
  35083. * An event triggered before rendering a camera
  35084. */
  35085. onBeforeCameraRenderObservable: Observable<Camera>;
  35086. private _onBeforeCameraRenderObserver;
  35087. /** Sets a function to be executed before rendering a camera*/
  35088. set beforeCameraRender(callback: () => void);
  35089. /**
  35090. * An event triggered after rendering a camera
  35091. */
  35092. onAfterCameraRenderObservable: Observable<Camera>;
  35093. private _onAfterCameraRenderObserver;
  35094. /** Sets a function to be executed after rendering a camera*/
  35095. set afterCameraRender(callback: () => void);
  35096. /**
  35097. * An event triggered when active meshes evaluation is about to start
  35098. */
  35099. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35100. /**
  35101. * An event triggered when active meshes evaluation is done
  35102. */
  35103. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35104. /**
  35105. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35109. /**
  35110. * An event triggered when particles rendering is done
  35111. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35112. */
  35113. onAfterParticlesRenderingObservable: Observable<Scene>;
  35114. /**
  35115. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35116. */
  35117. onDataLoadedObservable: Observable<Scene>;
  35118. /**
  35119. * An event triggered when a camera is created
  35120. */
  35121. onNewCameraAddedObservable: Observable<Camera>;
  35122. /**
  35123. * An event triggered when a camera is removed
  35124. */
  35125. onCameraRemovedObservable: Observable<Camera>;
  35126. /**
  35127. * An event triggered when a light is created
  35128. */
  35129. onNewLightAddedObservable: Observable<Light>;
  35130. /**
  35131. * An event triggered when a light is removed
  35132. */
  35133. onLightRemovedObservable: Observable<Light>;
  35134. /**
  35135. * An event triggered when a geometry is created
  35136. */
  35137. onNewGeometryAddedObservable: Observable<Geometry>;
  35138. /**
  35139. * An event triggered when a geometry is removed
  35140. */
  35141. onGeometryRemovedObservable: Observable<Geometry>;
  35142. /**
  35143. * An event triggered when a transform node is created
  35144. */
  35145. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35146. /**
  35147. * An event triggered when a transform node is removed
  35148. */
  35149. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35150. /**
  35151. * An event triggered when a mesh is created
  35152. */
  35153. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35154. /**
  35155. * An event triggered when a mesh is removed
  35156. */
  35157. onMeshRemovedObservable: Observable<AbstractMesh>;
  35158. /**
  35159. * An event triggered when a skeleton is created
  35160. */
  35161. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35162. /**
  35163. * An event triggered when a skeleton is removed
  35164. */
  35165. onSkeletonRemovedObservable: Observable<Skeleton>;
  35166. /**
  35167. * An event triggered when a material is created
  35168. */
  35169. onNewMaterialAddedObservable: Observable<Material>;
  35170. /**
  35171. * An event triggered when a material is removed
  35172. */
  35173. onMaterialRemovedObservable: Observable<Material>;
  35174. /**
  35175. * An event triggered when a texture is created
  35176. */
  35177. onNewTextureAddedObservable: Observable<BaseTexture>;
  35178. /**
  35179. * An event triggered when a texture is removed
  35180. */
  35181. onTextureRemovedObservable: Observable<BaseTexture>;
  35182. /**
  35183. * An event triggered when render targets are about to be rendered
  35184. * Can happen multiple times per frame.
  35185. */
  35186. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35187. /**
  35188. * An event triggered when render targets were rendered.
  35189. * Can happen multiple times per frame.
  35190. */
  35191. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35192. /**
  35193. * An event triggered before calculating deterministic simulation step
  35194. */
  35195. onBeforeStepObservable: Observable<Scene>;
  35196. /**
  35197. * An event triggered after calculating deterministic simulation step
  35198. */
  35199. onAfterStepObservable: Observable<Scene>;
  35200. /**
  35201. * An event triggered when the activeCamera property is updated
  35202. */
  35203. onActiveCameraChanged: Observable<Scene>;
  35204. /**
  35205. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35206. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35207. * 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)
  35208. */
  35209. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35210. /**
  35211. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35212. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35213. * 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)
  35214. */
  35215. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35216. /**
  35217. * This Observable will when a mesh has been imported into the scene.
  35218. */
  35219. onMeshImportedObservable: Observable<AbstractMesh>;
  35220. /**
  35221. * This Observable will when an animation file has been imported into the scene.
  35222. */
  35223. onAnimationFileImportedObservable: Observable<Scene>;
  35224. /**
  35225. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35226. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35227. */
  35228. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35229. /** @hidden */
  35230. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35231. /**
  35232. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35233. */
  35234. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35235. /**
  35236. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35237. */
  35238. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35239. /**
  35240. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35241. */
  35242. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35243. /** Callback called when a pointer move is detected */
  35244. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35245. /** Callback called when a pointer down is detected */
  35246. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35247. /** Callback called when a pointer up is detected */
  35248. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35249. /** Callback called when a pointer pick is detected */
  35250. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35251. /**
  35252. * 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).
  35253. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35254. */
  35255. onPrePointerObservable: Observable<PointerInfoPre>;
  35256. /**
  35257. * Observable event triggered each time an input event is received from the rendering canvas
  35258. */
  35259. onPointerObservable: Observable<PointerInfo>;
  35260. /**
  35261. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35262. */
  35263. get unTranslatedPointer(): Vector2;
  35264. /**
  35265. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35266. */
  35267. static get DragMovementThreshold(): number;
  35268. static set DragMovementThreshold(value: number);
  35269. /**
  35270. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35271. */
  35272. static get LongPressDelay(): number;
  35273. static set LongPressDelay(value: number);
  35274. /**
  35275. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35276. */
  35277. static get DoubleClickDelay(): number;
  35278. static set DoubleClickDelay(value: number);
  35279. /** If you need to check double click without raising a single click at first click, enable this flag */
  35280. static get ExclusiveDoubleClickMode(): boolean;
  35281. static set ExclusiveDoubleClickMode(value: boolean);
  35282. /** @hidden */
  35283. _mirroredCameraPosition: Nullable<Vector3>;
  35284. /**
  35285. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35286. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35287. */
  35288. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35289. /**
  35290. * Observable event triggered each time an keyboard event is received from the hosting window
  35291. */
  35292. onKeyboardObservable: Observable<KeyboardInfo>;
  35293. private _useRightHandedSystem;
  35294. /**
  35295. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35296. */
  35297. set useRightHandedSystem(value: boolean);
  35298. get useRightHandedSystem(): boolean;
  35299. private _timeAccumulator;
  35300. private _currentStepId;
  35301. private _currentInternalStep;
  35302. /**
  35303. * Sets the step Id used by deterministic lock step
  35304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35305. * @param newStepId defines the step Id
  35306. */
  35307. setStepId(newStepId: number): void;
  35308. /**
  35309. * Gets the step Id used by deterministic lock step
  35310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35311. * @returns the step Id
  35312. */
  35313. getStepId(): number;
  35314. /**
  35315. * Gets the internal step used by deterministic lock step
  35316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35317. * @returns the internal step
  35318. */
  35319. getInternalStep(): number;
  35320. private _fogEnabled;
  35321. /**
  35322. * Gets or sets a boolean indicating if fog is enabled on this scene
  35323. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35324. * (Default is true)
  35325. */
  35326. set fogEnabled(value: boolean);
  35327. get fogEnabled(): boolean;
  35328. private _fogMode;
  35329. /**
  35330. * Gets or sets the fog mode to use
  35331. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35332. * | mode | value |
  35333. * | --- | --- |
  35334. * | FOGMODE_NONE | 0 |
  35335. * | FOGMODE_EXP | 1 |
  35336. * | FOGMODE_EXP2 | 2 |
  35337. * | FOGMODE_LINEAR | 3 |
  35338. */
  35339. set fogMode(value: number);
  35340. get fogMode(): number;
  35341. /**
  35342. * Gets or sets the fog color to use
  35343. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35344. * (Default is Color3(0.2, 0.2, 0.3))
  35345. */
  35346. fogColor: Color3;
  35347. /**
  35348. * Gets or sets the fog density to use
  35349. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35350. * (Default is 0.1)
  35351. */
  35352. fogDensity: number;
  35353. /**
  35354. * Gets or sets the fog start distance to use
  35355. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35356. * (Default is 0)
  35357. */
  35358. fogStart: number;
  35359. /**
  35360. * Gets or sets the fog end distance to use
  35361. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35362. * (Default is 1000)
  35363. */
  35364. fogEnd: number;
  35365. private _shadowsEnabled;
  35366. /**
  35367. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35368. */
  35369. set shadowsEnabled(value: boolean);
  35370. get shadowsEnabled(): boolean;
  35371. private _lightsEnabled;
  35372. /**
  35373. * Gets or sets a boolean indicating if lights are enabled on this scene
  35374. */
  35375. set lightsEnabled(value: boolean);
  35376. get lightsEnabled(): boolean;
  35377. /** All of the active cameras added to this scene. */
  35378. activeCameras: Camera[];
  35379. /** @hidden */
  35380. _activeCamera: Nullable<Camera>;
  35381. /** Gets or sets the current active camera */
  35382. get activeCamera(): Nullable<Camera>;
  35383. set activeCamera(value: Nullable<Camera>);
  35384. private _defaultMaterial;
  35385. /** The default material used on meshes when no material is affected */
  35386. get defaultMaterial(): Material;
  35387. /** The default material used on meshes when no material is affected */
  35388. set defaultMaterial(value: Material);
  35389. private _texturesEnabled;
  35390. /**
  35391. * Gets or sets a boolean indicating if textures are enabled on this scene
  35392. */
  35393. set texturesEnabled(value: boolean);
  35394. get texturesEnabled(): boolean;
  35395. /**
  35396. * Gets or sets a boolean indicating if particles are enabled on this scene
  35397. */
  35398. particlesEnabled: boolean;
  35399. /**
  35400. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35401. */
  35402. spritesEnabled: boolean;
  35403. private _skeletonsEnabled;
  35404. /**
  35405. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35406. */
  35407. set skeletonsEnabled(value: boolean);
  35408. get skeletonsEnabled(): boolean;
  35409. /**
  35410. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35411. */
  35412. lensFlaresEnabled: boolean;
  35413. /**
  35414. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35416. */
  35417. collisionsEnabled: boolean;
  35418. private _collisionCoordinator;
  35419. /** @hidden */
  35420. get collisionCoordinator(): ICollisionCoordinator;
  35421. /**
  35422. * Defines the gravity applied to this scene (used only for collisions)
  35423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35424. */
  35425. gravity: Vector3;
  35426. /**
  35427. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35428. */
  35429. postProcessesEnabled: boolean;
  35430. /**
  35431. * The list of postprocesses added to the scene
  35432. */
  35433. postProcesses: PostProcess[];
  35434. /**
  35435. * Gets the current postprocess manager
  35436. */
  35437. postProcessManager: PostProcessManager;
  35438. /**
  35439. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35440. */
  35441. renderTargetsEnabled: boolean;
  35442. /**
  35443. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35444. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35445. */
  35446. dumpNextRenderTargets: boolean;
  35447. /**
  35448. * The list of user defined render targets added to the scene
  35449. */
  35450. customRenderTargets: RenderTargetTexture[];
  35451. /**
  35452. * Defines if texture loading must be delayed
  35453. * If true, textures will only be loaded when they need to be rendered
  35454. */
  35455. useDelayedTextureLoading: boolean;
  35456. /**
  35457. * Gets the list of meshes imported to the scene through SceneLoader
  35458. */
  35459. importedMeshesFiles: String[];
  35460. /**
  35461. * Gets or sets a boolean indicating if probes are enabled on this scene
  35462. */
  35463. probesEnabled: boolean;
  35464. /**
  35465. * Gets or sets the current offline provider to use to store scene data
  35466. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35467. */
  35468. offlineProvider: IOfflineProvider;
  35469. /**
  35470. * Gets or sets the action manager associated with the scene
  35471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35472. */
  35473. actionManager: AbstractActionManager;
  35474. private _meshesForIntersections;
  35475. /**
  35476. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35477. */
  35478. proceduralTexturesEnabled: boolean;
  35479. private _engine;
  35480. private _totalVertices;
  35481. /** @hidden */
  35482. _activeIndices: PerfCounter;
  35483. /** @hidden */
  35484. _activeParticles: PerfCounter;
  35485. /** @hidden */
  35486. _activeBones: PerfCounter;
  35487. private _animationRatio;
  35488. /** @hidden */
  35489. _animationTimeLast: number;
  35490. /** @hidden */
  35491. _animationTime: number;
  35492. /**
  35493. * Gets or sets a general scale for animation speed
  35494. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35495. */
  35496. animationTimeScale: number;
  35497. /** @hidden */
  35498. _cachedMaterial: Nullable<Material>;
  35499. /** @hidden */
  35500. _cachedEffect: Nullable<Effect>;
  35501. /** @hidden */
  35502. _cachedVisibility: Nullable<number>;
  35503. private _renderId;
  35504. private _frameId;
  35505. private _executeWhenReadyTimeoutId;
  35506. private _intermediateRendering;
  35507. private _viewUpdateFlag;
  35508. private _projectionUpdateFlag;
  35509. /** @hidden */
  35510. _toBeDisposed: Nullable<IDisposable>[];
  35511. private _activeRequests;
  35512. /** @hidden */
  35513. _pendingData: any[];
  35514. private _isDisposed;
  35515. /**
  35516. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35517. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35518. */
  35519. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35520. private _activeMeshes;
  35521. private _processedMaterials;
  35522. private _renderTargets;
  35523. /** @hidden */
  35524. _activeParticleSystems: SmartArray<IParticleSystem>;
  35525. private _activeSkeletons;
  35526. private _softwareSkinnedMeshes;
  35527. private _renderingManager;
  35528. /** @hidden */
  35529. _activeAnimatables: Animatable[];
  35530. private _transformMatrix;
  35531. private _sceneUbo;
  35532. /** @hidden */
  35533. _viewMatrix: Matrix;
  35534. private _projectionMatrix;
  35535. /** @hidden */
  35536. _forcedViewPosition: Nullable<Vector3>;
  35537. /** @hidden */
  35538. _frustumPlanes: Plane[];
  35539. /**
  35540. * Gets the list of frustum planes (built from the active camera)
  35541. */
  35542. get frustumPlanes(): Plane[];
  35543. /**
  35544. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35545. * This is useful if there are more lights that the maximum simulteanous authorized
  35546. */
  35547. requireLightSorting: boolean;
  35548. /** @hidden */
  35549. readonly useMaterialMeshMap: boolean;
  35550. /** @hidden */
  35551. readonly useClonedMeshMap: boolean;
  35552. private _externalData;
  35553. private _uid;
  35554. /**
  35555. * @hidden
  35556. * Backing store of defined scene components.
  35557. */
  35558. _components: ISceneComponent[];
  35559. /**
  35560. * @hidden
  35561. * Backing store of defined scene components.
  35562. */
  35563. _serializableComponents: ISceneSerializableComponent[];
  35564. /**
  35565. * List of components to register on the next registration step.
  35566. */
  35567. private _transientComponents;
  35568. /**
  35569. * Registers the transient components if needed.
  35570. */
  35571. private _registerTransientComponents;
  35572. /**
  35573. * @hidden
  35574. * Add a component to the scene.
  35575. * Note that the ccomponent could be registered on th next frame if this is called after
  35576. * the register component stage.
  35577. * @param component Defines the component to add to the scene
  35578. */
  35579. _addComponent(component: ISceneComponent): void;
  35580. /**
  35581. * @hidden
  35582. * Gets a component from the scene.
  35583. * @param name defines the name of the component to retrieve
  35584. * @returns the component or null if not present
  35585. */
  35586. _getComponent(name: string): Nullable<ISceneComponent>;
  35587. /**
  35588. * @hidden
  35589. * Defines the actions happening before camera updates.
  35590. */
  35591. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35592. /**
  35593. * @hidden
  35594. * Defines the actions happening before clear the canvas.
  35595. */
  35596. _beforeClearStage: Stage<SimpleStageAction>;
  35597. /**
  35598. * @hidden
  35599. * Defines the actions when collecting render targets for the frame.
  35600. */
  35601. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35602. /**
  35603. * @hidden
  35604. * Defines the actions happening for one camera in the frame.
  35605. */
  35606. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35607. /**
  35608. * @hidden
  35609. * Defines the actions happening during the per mesh ready checks.
  35610. */
  35611. _isReadyForMeshStage: Stage<MeshStageAction>;
  35612. /**
  35613. * @hidden
  35614. * Defines the actions happening before evaluate active mesh checks.
  35615. */
  35616. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35617. /**
  35618. * @hidden
  35619. * Defines the actions happening during the evaluate sub mesh checks.
  35620. */
  35621. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35622. /**
  35623. * @hidden
  35624. * Defines the actions happening during the active mesh stage.
  35625. */
  35626. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35627. /**
  35628. * @hidden
  35629. * Defines the actions happening during the per camera render target step.
  35630. */
  35631. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35632. /**
  35633. * @hidden
  35634. * Defines the actions happening just before the active camera is drawing.
  35635. */
  35636. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35637. /**
  35638. * @hidden
  35639. * Defines the actions happening just before a render target is drawing.
  35640. */
  35641. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35642. /**
  35643. * @hidden
  35644. * Defines the actions happening just before a rendering group is drawing.
  35645. */
  35646. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35647. /**
  35648. * @hidden
  35649. * Defines the actions happening just before a mesh is drawing.
  35650. */
  35651. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35652. /**
  35653. * @hidden
  35654. * Defines the actions happening just after a mesh has been drawn.
  35655. */
  35656. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35657. /**
  35658. * @hidden
  35659. * Defines the actions happening just after a rendering group has been drawn.
  35660. */
  35661. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35662. /**
  35663. * @hidden
  35664. * Defines the actions happening just after the active camera has been drawn.
  35665. */
  35666. _afterCameraDrawStage: Stage<CameraStageAction>;
  35667. /**
  35668. * @hidden
  35669. * Defines the actions happening just after a render target has been drawn.
  35670. */
  35671. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35672. /**
  35673. * @hidden
  35674. * Defines the actions happening just after rendering all cameras and computing intersections.
  35675. */
  35676. _afterRenderStage: Stage<SimpleStageAction>;
  35677. /**
  35678. * @hidden
  35679. * Defines the actions happening when a pointer move event happens.
  35680. */
  35681. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35682. /**
  35683. * @hidden
  35684. * Defines the actions happening when a pointer down event happens.
  35685. */
  35686. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35687. /**
  35688. * @hidden
  35689. * Defines the actions happening when a pointer up event happens.
  35690. */
  35691. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35692. /**
  35693. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35694. */
  35695. private geometriesByUniqueId;
  35696. /**
  35697. * Creates a new Scene
  35698. * @param engine defines the engine to use to render this scene
  35699. * @param options defines the scene options
  35700. */
  35701. constructor(engine: Engine, options?: SceneOptions);
  35702. /**
  35703. * Gets a string idenfifying the name of the class
  35704. * @returns "Scene" string
  35705. */
  35706. getClassName(): string;
  35707. private _defaultMeshCandidates;
  35708. /**
  35709. * @hidden
  35710. */
  35711. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35712. private _defaultSubMeshCandidates;
  35713. /**
  35714. * @hidden
  35715. */
  35716. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35717. /**
  35718. * Sets the default candidate providers for the scene.
  35719. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35720. * and getCollidingSubMeshCandidates to their default function
  35721. */
  35722. setDefaultCandidateProviders(): void;
  35723. /**
  35724. * Gets the mesh that is currently under the pointer
  35725. */
  35726. get meshUnderPointer(): Nullable<AbstractMesh>;
  35727. /**
  35728. * Gets or sets the current on-screen X position of the pointer
  35729. */
  35730. get pointerX(): number;
  35731. set pointerX(value: number);
  35732. /**
  35733. * Gets or sets the current on-screen Y position of the pointer
  35734. */
  35735. get pointerY(): number;
  35736. set pointerY(value: number);
  35737. /**
  35738. * Gets the cached material (ie. the latest rendered one)
  35739. * @returns the cached material
  35740. */
  35741. getCachedMaterial(): Nullable<Material>;
  35742. /**
  35743. * Gets the cached effect (ie. the latest rendered one)
  35744. * @returns the cached effect
  35745. */
  35746. getCachedEffect(): Nullable<Effect>;
  35747. /**
  35748. * Gets the cached visibility state (ie. the latest rendered one)
  35749. * @returns the cached visibility state
  35750. */
  35751. getCachedVisibility(): Nullable<number>;
  35752. /**
  35753. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35754. * @param material defines the current material
  35755. * @param effect defines the current effect
  35756. * @param visibility defines the current visibility state
  35757. * @returns true if one parameter is not cached
  35758. */
  35759. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35760. /**
  35761. * Gets the engine associated with the scene
  35762. * @returns an Engine
  35763. */
  35764. getEngine(): Engine;
  35765. /**
  35766. * Gets the total number of vertices rendered per frame
  35767. * @returns the total number of vertices rendered per frame
  35768. */
  35769. getTotalVertices(): number;
  35770. /**
  35771. * Gets the performance counter for total vertices
  35772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35773. */
  35774. get totalVerticesPerfCounter(): PerfCounter;
  35775. /**
  35776. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35777. * @returns the total number of active indices rendered per frame
  35778. */
  35779. getActiveIndices(): number;
  35780. /**
  35781. * Gets the performance counter for active indices
  35782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35783. */
  35784. get totalActiveIndicesPerfCounter(): PerfCounter;
  35785. /**
  35786. * Gets the total number of active particles rendered per frame
  35787. * @returns the total number of active particles rendered per frame
  35788. */
  35789. getActiveParticles(): number;
  35790. /**
  35791. * Gets the performance counter for active particles
  35792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35793. */
  35794. get activeParticlesPerfCounter(): PerfCounter;
  35795. /**
  35796. * Gets the total number of active bones rendered per frame
  35797. * @returns the total number of active bones rendered per frame
  35798. */
  35799. getActiveBones(): number;
  35800. /**
  35801. * Gets the performance counter for active bones
  35802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35803. */
  35804. get activeBonesPerfCounter(): PerfCounter;
  35805. /**
  35806. * Gets the array of active meshes
  35807. * @returns an array of AbstractMesh
  35808. */
  35809. getActiveMeshes(): SmartArray<AbstractMesh>;
  35810. /**
  35811. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35812. * @returns a number
  35813. */
  35814. getAnimationRatio(): number;
  35815. /**
  35816. * Gets an unique Id for the current render phase
  35817. * @returns a number
  35818. */
  35819. getRenderId(): number;
  35820. /**
  35821. * Gets an unique Id for the current frame
  35822. * @returns a number
  35823. */
  35824. getFrameId(): number;
  35825. /** Call this function if you want to manually increment the render Id*/
  35826. incrementRenderId(): void;
  35827. private _createUbo;
  35828. /**
  35829. * Use this method to simulate a pointer move on a mesh
  35830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35833. * @returns the current scene
  35834. */
  35835. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35836. /**
  35837. * Use this method to simulate a pointer down on a mesh
  35838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35841. * @returns the current scene
  35842. */
  35843. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35844. /**
  35845. * Use this method to simulate a pointer up on a mesh
  35846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35849. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35850. * @returns the current scene
  35851. */
  35852. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35853. /**
  35854. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35855. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35856. * @returns true if the pointer was captured
  35857. */
  35858. isPointerCaptured(pointerId?: number): boolean;
  35859. /**
  35860. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35861. * @param attachUp defines if you want to attach events to pointerup
  35862. * @param attachDown defines if you want to attach events to pointerdown
  35863. * @param attachMove defines if you want to attach events to pointermove
  35864. */
  35865. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35866. /** Detaches all event handlers*/
  35867. detachControl(): void;
  35868. /**
  35869. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35870. * Delay loaded resources are not taking in account
  35871. * @return true if all required resources are ready
  35872. */
  35873. isReady(): boolean;
  35874. /** Resets all cached information relative to material (including effect and visibility) */
  35875. resetCachedMaterial(): void;
  35876. /**
  35877. * Registers a function to be called before every frame render
  35878. * @param func defines the function to register
  35879. */
  35880. registerBeforeRender(func: () => void): void;
  35881. /**
  35882. * Unregisters a function called before every frame render
  35883. * @param func defines the function to unregister
  35884. */
  35885. unregisterBeforeRender(func: () => void): void;
  35886. /**
  35887. * Registers a function to be called after every frame render
  35888. * @param func defines the function to register
  35889. */
  35890. registerAfterRender(func: () => void): void;
  35891. /**
  35892. * Unregisters a function called after every frame render
  35893. * @param func defines the function to unregister
  35894. */
  35895. unregisterAfterRender(func: () => void): void;
  35896. private _executeOnceBeforeRender;
  35897. /**
  35898. * The provided function will run before render once and will be disposed afterwards.
  35899. * A timeout delay can be provided so that the function will be executed in N ms.
  35900. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35901. * @param func The function to be executed.
  35902. * @param timeout optional delay in ms
  35903. */
  35904. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35905. /** @hidden */
  35906. _addPendingData(data: any): void;
  35907. /** @hidden */
  35908. _removePendingData(data: any): void;
  35909. /**
  35910. * Returns the number of items waiting to be loaded
  35911. * @returns the number of items waiting to be loaded
  35912. */
  35913. getWaitingItemsCount(): number;
  35914. /**
  35915. * Returns a boolean indicating if the scene is still loading data
  35916. */
  35917. get isLoading(): boolean;
  35918. /**
  35919. * Registers a function to be executed when the scene is ready
  35920. * @param {Function} func - the function to be executed
  35921. */
  35922. executeWhenReady(func: () => void): void;
  35923. /**
  35924. * Returns a promise that resolves when the scene is ready
  35925. * @returns A promise that resolves when the scene is ready
  35926. */
  35927. whenReadyAsync(): Promise<void>;
  35928. /** @hidden */
  35929. _checkIsReady(): void;
  35930. /**
  35931. * Gets all animatable attached to the scene
  35932. */
  35933. get animatables(): Animatable[];
  35934. /**
  35935. * Resets the last animation time frame.
  35936. * Useful to override when animations start running when loading a scene for the first time.
  35937. */
  35938. resetLastAnimationTimeFrame(): void;
  35939. /**
  35940. * Gets the current view matrix
  35941. * @returns a Matrix
  35942. */
  35943. getViewMatrix(): Matrix;
  35944. /**
  35945. * Gets the current projection matrix
  35946. * @returns a Matrix
  35947. */
  35948. getProjectionMatrix(): Matrix;
  35949. /**
  35950. * Gets the current transform matrix
  35951. * @returns a Matrix made of View * Projection
  35952. */
  35953. getTransformMatrix(): Matrix;
  35954. /**
  35955. * Sets the current transform matrix
  35956. * @param viewL defines the View matrix to use
  35957. * @param projectionL defines the Projection matrix to use
  35958. * @param viewR defines the right View matrix to use (if provided)
  35959. * @param projectionR defines the right Projection matrix to use (if provided)
  35960. */
  35961. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35962. /**
  35963. * Gets the uniform buffer used to store scene data
  35964. * @returns a UniformBuffer
  35965. */
  35966. getSceneUniformBuffer(): UniformBuffer;
  35967. /**
  35968. * Gets an unique (relatively to the current scene) Id
  35969. * @returns an unique number for the scene
  35970. */
  35971. getUniqueId(): number;
  35972. /**
  35973. * Add a mesh to the list of scene's meshes
  35974. * @param newMesh defines the mesh to add
  35975. * @param recursive if all child meshes should also be added to the scene
  35976. */
  35977. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35978. /**
  35979. * Remove a mesh for the list of scene's meshes
  35980. * @param toRemove defines the mesh to remove
  35981. * @param recursive if all child meshes should also be removed from the scene
  35982. * @returns the index where the mesh was in the mesh list
  35983. */
  35984. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35985. /**
  35986. * Add a transform node to the list of scene's transform nodes
  35987. * @param newTransformNode defines the transform node to add
  35988. */
  35989. addTransformNode(newTransformNode: TransformNode): void;
  35990. /**
  35991. * Remove a transform node for the list of scene's transform nodes
  35992. * @param toRemove defines the transform node to remove
  35993. * @returns the index where the transform node was in the transform node list
  35994. */
  35995. removeTransformNode(toRemove: TransformNode): number;
  35996. /**
  35997. * Remove a skeleton for the list of scene's skeletons
  35998. * @param toRemove defines the skeleton to remove
  35999. * @returns the index where the skeleton was in the skeleton list
  36000. */
  36001. removeSkeleton(toRemove: Skeleton): number;
  36002. /**
  36003. * Remove a morph target for the list of scene's morph targets
  36004. * @param toRemove defines the morph target to remove
  36005. * @returns the index where the morph target was in the morph target list
  36006. */
  36007. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36008. /**
  36009. * Remove a light for the list of scene's lights
  36010. * @param toRemove defines the light to remove
  36011. * @returns the index where the light was in the light list
  36012. */
  36013. removeLight(toRemove: Light): number;
  36014. /**
  36015. * Remove a camera for the list of scene's cameras
  36016. * @param toRemove defines the camera to remove
  36017. * @returns the index where the camera was in the camera list
  36018. */
  36019. removeCamera(toRemove: Camera): number;
  36020. /**
  36021. * Remove a particle system for the list of scene's particle systems
  36022. * @param toRemove defines the particle system to remove
  36023. * @returns the index where the particle system was in the particle system list
  36024. */
  36025. removeParticleSystem(toRemove: IParticleSystem): number;
  36026. /**
  36027. * Remove a animation for the list of scene's animations
  36028. * @param toRemove defines the animation to remove
  36029. * @returns the index where the animation was in the animation list
  36030. */
  36031. removeAnimation(toRemove: Animation): number;
  36032. /**
  36033. * Will stop the animation of the given target
  36034. * @param target - the target
  36035. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36036. * @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)
  36037. */
  36038. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36039. /**
  36040. * Removes the given animation group from this scene.
  36041. * @param toRemove The animation group to remove
  36042. * @returns The index of the removed animation group
  36043. */
  36044. removeAnimationGroup(toRemove: AnimationGroup): number;
  36045. /**
  36046. * Removes the given multi-material from this scene.
  36047. * @param toRemove The multi-material to remove
  36048. * @returns The index of the removed multi-material
  36049. */
  36050. removeMultiMaterial(toRemove: MultiMaterial): number;
  36051. /**
  36052. * Removes the given material from this scene.
  36053. * @param toRemove The material to remove
  36054. * @returns The index of the removed material
  36055. */
  36056. removeMaterial(toRemove: Material): number;
  36057. /**
  36058. * Removes the given action manager from this scene.
  36059. * @param toRemove The action manager to remove
  36060. * @returns The index of the removed action manager
  36061. */
  36062. removeActionManager(toRemove: AbstractActionManager): number;
  36063. /**
  36064. * Removes the given texture from this scene.
  36065. * @param toRemove The texture to remove
  36066. * @returns The index of the removed texture
  36067. */
  36068. removeTexture(toRemove: BaseTexture): number;
  36069. /**
  36070. * Adds the given light to this scene
  36071. * @param newLight The light to add
  36072. */
  36073. addLight(newLight: Light): void;
  36074. /**
  36075. * Sorts the list list based on light priorities
  36076. */
  36077. sortLightsByPriority(): void;
  36078. /**
  36079. * Adds the given camera to this scene
  36080. * @param newCamera The camera to add
  36081. */
  36082. addCamera(newCamera: Camera): void;
  36083. /**
  36084. * Adds the given skeleton to this scene
  36085. * @param newSkeleton The skeleton to add
  36086. */
  36087. addSkeleton(newSkeleton: Skeleton): void;
  36088. /**
  36089. * Adds the given particle system to this scene
  36090. * @param newParticleSystem The particle system to add
  36091. */
  36092. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36093. /**
  36094. * Adds the given animation to this scene
  36095. * @param newAnimation The animation to add
  36096. */
  36097. addAnimation(newAnimation: Animation): void;
  36098. /**
  36099. * Adds the given animation group to this scene.
  36100. * @param newAnimationGroup The animation group to add
  36101. */
  36102. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36103. /**
  36104. * Adds the given multi-material to this scene
  36105. * @param newMultiMaterial The multi-material to add
  36106. */
  36107. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36108. /**
  36109. * Adds the given material to this scene
  36110. * @param newMaterial The material to add
  36111. */
  36112. addMaterial(newMaterial: Material): void;
  36113. /**
  36114. * Adds the given morph target to this scene
  36115. * @param newMorphTargetManager The morph target to add
  36116. */
  36117. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36118. /**
  36119. * Adds the given geometry to this scene
  36120. * @param newGeometry The geometry to add
  36121. */
  36122. addGeometry(newGeometry: Geometry): void;
  36123. /**
  36124. * Adds the given action manager to this scene
  36125. * @param newActionManager The action manager to add
  36126. */
  36127. addActionManager(newActionManager: AbstractActionManager): void;
  36128. /**
  36129. * Adds the given texture to this scene.
  36130. * @param newTexture The texture to add
  36131. */
  36132. addTexture(newTexture: BaseTexture): void;
  36133. /**
  36134. * Switch active camera
  36135. * @param newCamera defines the new active camera
  36136. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36137. */
  36138. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36139. /**
  36140. * sets the active camera of the scene using its ID
  36141. * @param id defines the camera's ID
  36142. * @return the new active camera or null if none found.
  36143. */
  36144. setActiveCameraByID(id: string): Nullable<Camera>;
  36145. /**
  36146. * sets the active camera of the scene using its name
  36147. * @param name defines the camera's name
  36148. * @returns the new active camera or null if none found.
  36149. */
  36150. setActiveCameraByName(name: string): Nullable<Camera>;
  36151. /**
  36152. * get an animation group using its name
  36153. * @param name defines the material's name
  36154. * @return the animation group or null if none found.
  36155. */
  36156. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36157. /**
  36158. * Get a material using its unique id
  36159. * @param uniqueId defines the material's unique id
  36160. * @return the material or null if none found.
  36161. */
  36162. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36163. /**
  36164. * get a material using its id
  36165. * @param id defines the material's ID
  36166. * @return the material or null if none found.
  36167. */
  36168. getMaterialByID(id: string): Nullable<Material>;
  36169. /**
  36170. * Gets a the last added material using a given id
  36171. * @param id defines the material's ID
  36172. * @return the last material with the given id or null if none found.
  36173. */
  36174. getLastMaterialByID(id: string): Nullable<Material>;
  36175. /**
  36176. * Gets a material using its name
  36177. * @param name defines the material's name
  36178. * @return the material or null if none found.
  36179. */
  36180. getMaterialByName(name: string): Nullable<Material>;
  36181. /**
  36182. * Get a texture using its unique id
  36183. * @param uniqueId defines the texture's unique id
  36184. * @return the texture or null if none found.
  36185. */
  36186. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36187. /**
  36188. * Gets a camera using its id
  36189. * @param id defines the id to look for
  36190. * @returns the camera or null if not found
  36191. */
  36192. getCameraByID(id: string): Nullable<Camera>;
  36193. /**
  36194. * Gets a camera using its unique id
  36195. * @param uniqueId defines the unique id to look for
  36196. * @returns the camera or null if not found
  36197. */
  36198. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36199. /**
  36200. * Gets a camera using its name
  36201. * @param name defines the camera's name
  36202. * @return the camera or null if none found.
  36203. */
  36204. getCameraByName(name: string): Nullable<Camera>;
  36205. /**
  36206. * Gets a bone using its id
  36207. * @param id defines the bone's id
  36208. * @return the bone or null if not found
  36209. */
  36210. getBoneByID(id: string): Nullable<Bone>;
  36211. /**
  36212. * Gets a bone using its id
  36213. * @param name defines the bone's name
  36214. * @return the bone or null if not found
  36215. */
  36216. getBoneByName(name: string): Nullable<Bone>;
  36217. /**
  36218. * Gets a light node using its name
  36219. * @param name defines the the light's name
  36220. * @return the light or null if none found.
  36221. */
  36222. getLightByName(name: string): Nullable<Light>;
  36223. /**
  36224. * Gets a light node using its id
  36225. * @param id defines the light's id
  36226. * @return the light or null if none found.
  36227. */
  36228. getLightByID(id: string): Nullable<Light>;
  36229. /**
  36230. * Gets a light node using its scene-generated unique ID
  36231. * @param uniqueId defines the light's unique id
  36232. * @return the light or null if none found.
  36233. */
  36234. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36235. /**
  36236. * Gets a particle system by id
  36237. * @param id defines the particle system id
  36238. * @return the corresponding system or null if none found
  36239. */
  36240. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36241. /**
  36242. * Gets a geometry using its ID
  36243. * @param id defines the geometry's id
  36244. * @return the geometry or null if none found.
  36245. */
  36246. getGeometryByID(id: string): Nullable<Geometry>;
  36247. private _getGeometryByUniqueID;
  36248. /**
  36249. * Add a new geometry to this scene
  36250. * @param geometry defines the geometry to be added to the scene.
  36251. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36252. * @return a boolean defining if the geometry was added or not
  36253. */
  36254. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36255. /**
  36256. * Removes an existing geometry
  36257. * @param geometry defines the geometry to be removed from the scene
  36258. * @return a boolean defining if the geometry was removed or not
  36259. */
  36260. removeGeometry(geometry: Geometry): boolean;
  36261. /**
  36262. * Gets the list of geometries attached to the scene
  36263. * @returns an array of Geometry
  36264. */
  36265. getGeometries(): Geometry[];
  36266. /**
  36267. * Gets the first added mesh found of a given ID
  36268. * @param id defines the id to search for
  36269. * @return the mesh found or null if not found at all
  36270. */
  36271. getMeshByID(id: string): Nullable<AbstractMesh>;
  36272. /**
  36273. * Gets a list of meshes using their id
  36274. * @param id defines the id to search for
  36275. * @returns a list of meshes
  36276. */
  36277. getMeshesByID(id: string): Array<AbstractMesh>;
  36278. /**
  36279. * Gets the first added transform node found of a given ID
  36280. * @param id defines the id to search for
  36281. * @return the found transform node or null if not found at all.
  36282. */
  36283. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36284. /**
  36285. * Gets a transform node with its auto-generated unique id
  36286. * @param uniqueId efines the unique id to search for
  36287. * @return the found transform node or null if not found at all.
  36288. */
  36289. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36290. /**
  36291. * Gets a list of transform nodes using their id
  36292. * @param id defines the id to search for
  36293. * @returns a list of transform nodes
  36294. */
  36295. getTransformNodesByID(id: string): Array<TransformNode>;
  36296. /**
  36297. * Gets a mesh with its auto-generated unique id
  36298. * @param uniqueId defines the unique id to search for
  36299. * @return the found mesh or null if not found at all.
  36300. */
  36301. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36302. /**
  36303. * Gets a the last added mesh using a given id
  36304. * @param id defines the id to search for
  36305. * @return the found mesh or null if not found at all.
  36306. */
  36307. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36308. /**
  36309. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36310. * @param id defines the id to search for
  36311. * @return the found node or null if not found at all
  36312. */
  36313. getLastEntryByID(id: string): Nullable<Node>;
  36314. /**
  36315. * Gets a node (Mesh, Camera, Light) using a given id
  36316. * @param id defines the id to search for
  36317. * @return the found node or null if not found at all
  36318. */
  36319. getNodeByID(id: string): Nullable<Node>;
  36320. /**
  36321. * Gets a node (Mesh, Camera, Light) using a given name
  36322. * @param name defines the name to search for
  36323. * @return the found node or null if not found at all.
  36324. */
  36325. getNodeByName(name: string): Nullable<Node>;
  36326. /**
  36327. * Gets a mesh using a given name
  36328. * @param name defines the name to search for
  36329. * @return the found mesh or null if not found at all.
  36330. */
  36331. getMeshByName(name: string): Nullable<AbstractMesh>;
  36332. /**
  36333. * Gets a transform node using a given name
  36334. * @param name defines the name to search for
  36335. * @return the found transform node or null if not found at all.
  36336. */
  36337. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36338. /**
  36339. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36340. * @param id defines the id to search for
  36341. * @return the found skeleton or null if not found at all.
  36342. */
  36343. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36344. /**
  36345. * Gets a skeleton using a given auto generated unique id
  36346. * @param uniqueId defines the unique id to search for
  36347. * @return the found skeleton or null if not found at all.
  36348. */
  36349. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36350. /**
  36351. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36352. * @param id defines the id to search for
  36353. * @return the found skeleton or null if not found at all.
  36354. */
  36355. getSkeletonById(id: string): Nullable<Skeleton>;
  36356. /**
  36357. * Gets a skeleton using a given name
  36358. * @param name defines the name to search for
  36359. * @return the found skeleton or null if not found at all.
  36360. */
  36361. getSkeletonByName(name: string): Nullable<Skeleton>;
  36362. /**
  36363. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36364. * @param id defines the id to search for
  36365. * @return the found morph target manager or null if not found at all.
  36366. */
  36367. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36368. /**
  36369. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36370. * @param id defines the id to search for
  36371. * @return the found morph target or null if not found at all.
  36372. */
  36373. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36374. /**
  36375. * Gets a boolean indicating if the given mesh is active
  36376. * @param mesh defines the mesh to look for
  36377. * @returns true if the mesh is in the active list
  36378. */
  36379. isActiveMesh(mesh: AbstractMesh): boolean;
  36380. /**
  36381. * Return a unique id as a string which can serve as an identifier for the scene
  36382. */
  36383. get uid(): string;
  36384. /**
  36385. * Add an externaly attached data from its key.
  36386. * This method call will fail and return false, if such key already exists.
  36387. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36388. * @param key the unique key that identifies the data
  36389. * @param data the data object to associate to the key for this Engine instance
  36390. * @return true if no such key were already present and the data was added successfully, false otherwise
  36391. */
  36392. addExternalData<T>(key: string, data: T): boolean;
  36393. /**
  36394. * Get an externaly attached data from its key
  36395. * @param key the unique key that identifies the data
  36396. * @return the associated data, if present (can be null), or undefined if not present
  36397. */
  36398. getExternalData<T>(key: string): Nullable<T>;
  36399. /**
  36400. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36401. * @param key the unique key that identifies the data
  36402. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36403. * @return the associated data, can be null if the factory returned null.
  36404. */
  36405. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36406. /**
  36407. * Remove an externaly attached data from the Engine instance
  36408. * @param key the unique key that identifies the data
  36409. * @return true if the data was successfully removed, false if it doesn't exist
  36410. */
  36411. removeExternalData(key: string): boolean;
  36412. private _evaluateSubMesh;
  36413. /**
  36414. * Clear the processed materials smart array preventing retention point in material dispose.
  36415. */
  36416. freeProcessedMaterials(): void;
  36417. private _preventFreeActiveMeshesAndRenderingGroups;
  36418. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36419. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36420. * when disposing several meshes in a row or a hierarchy of meshes.
  36421. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36422. */
  36423. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36424. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36425. /**
  36426. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36427. */
  36428. freeActiveMeshes(): void;
  36429. /**
  36430. * Clear the info related to rendering groups preventing retention points during dispose.
  36431. */
  36432. freeRenderingGroups(): void;
  36433. /** @hidden */
  36434. _isInIntermediateRendering(): boolean;
  36435. /**
  36436. * Lambda returning the list of potentially active meshes.
  36437. */
  36438. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36439. /**
  36440. * Lambda returning the list of potentially active sub meshes.
  36441. */
  36442. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36443. /**
  36444. * Lambda returning the list of potentially intersecting sub meshes.
  36445. */
  36446. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36447. /**
  36448. * Lambda returning the list of potentially colliding sub meshes.
  36449. */
  36450. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36451. private _activeMeshesFrozen;
  36452. private _skipEvaluateActiveMeshesCompletely;
  36453. /**
  36454. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36455. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36456. * @returns the current scene
  36457. */
  36458. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36459. /**
  36460. * Use this function to restart evaluating active meshes on every frame
  36461. * @returns the current scene
  36462. */
  36463. unfreezeActiveMeshes(): Scene;
  36464. private _evaluateActiveMeshes;
  36465. private _activeMesh;
  36466. /**
  36467. * Update the transform matrix to update from the current active camera
  36468. * @param force defines a boolean used to force the update even if cache is up to date
  36469. */
  36470. updateTransformMatrix(force?: boolean): void;
  36471. private _bindFrameBuffer;
  36472. /** @hidden */
  36473. _allowPostProcessClearColor: boolean;
  36474. /** @hidden */
  36475. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36476. private _processSubCameras;
  36477. private _checkIntersections;
  36478. /** @hidden */
  36479. _advancePhysicsEngineStep(step: number): void;
  36480. /**
  36481. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36482. */
  36483. getDeterministicFrameTime: () => number;
  36484. /** @hidden */
  36485. _animate(): void;
  36486. /** Execute all animations (for a frame) */
  36487. animate(): void;
  36488. /**
  36489. * Render the scene
  36490. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36491. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36492. */
  36493. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36494. /**
  36495. * Freeze all materials
  36496. * A frozen material will not be updatable but should be faster to render
  36497. */
  36498. freezeMaterials(): void;
  36499. /**
  36500. * Unfreeze all materials
  36501. * A frozen material will not be updatable but should be faster to render
  36502. */
  36503. unfreezeMaterials(): void;
  36504. /**
  36505. * Releases all held ressources
  36506. */
  36507. dispose(): void;
  36508. /**
  36509. * Gets if the scene is already disposed
  36510. */
  36511. get isDisposed(): boolean;
  36512. /**
  36513. * Call this function to reduce memory footprint of the scene.
  36514. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36515. */
  36516. clearCachedVertexData(): void;
  36517. /**
  36518. * This function will remove the local cached buffer data from texture.
  36519. * It will save memory but will prevent the texture from being rebuilt
  36520. */
  36521. cleanCachedTextureBuffer(): void;
  36522. /**
  36523. * Get the world extend vectors with an optional filter
  36524. *
  36525. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36526. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36527. */
  36528. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36529. min: Vector3;
  36530. max: Vector3;
  36531. };
  36532. /**
  36533. * Creates a ray that can be used to pick in the scene
  36534. * @param x defines the x coordinate of the origin (on-screen)
  36535. * @param y defines the y coordinate of the origin (on-screen)
  36536. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36537. * @param camera defines the camera to use for the picking
  36538. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36539. * @returns a Ray
  36540. */
  36541. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36542. /**
  36543. * Creates a ray that can be used to pick in the scene
  36544. * @param x defines the x coordinate of the origin (on-screen)
  36545. * @param y defines the y coordinate of the origin (on-screen)
  36546. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36547. * @param result defines the ray where to store the picking ray
  36548. * @param camera defines the camera to use for the picking
  36549. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36550. * @returns the current scene
  36551. */
  36552. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36553. /**
  36554. * Creates a ray that can be used to pick in the scene
  36555. * @param x defines the x coordinate of the origin (on-screen)
  36556. * @param y defines the y coordinate of the origin (on-screen)
  36557. * @param camera defines the camera to use for the picking
  36558. * @returns a Ray
  36559. */
  36560. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36561. /**
  36562. * Creates a ray that can be used to pick in the scene
  36563. * @param x defines the x coordinate of the origin (on-screen)
  36564. * @param y defines the y coordinate of the origin (on-screen)
  36565. * @param result defines the ray where to store the picking ray
  36566. * @param camera defines the camera to use for the picking
  36567. * @returns the current scene
  36568. */
  36569. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36570. /** Launch a ray to try to pick a mesh in the scene
  36571. * @param x position on screen
  36572. * @param y position on screen
  36573. * @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
  36574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36575. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36576. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36577. * @returns a PickingInfo
  36578. */
  36579. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36580. /** Use the given ray to pick a mesh in the scene
  36581. * @param ray The ray to use to pick meshes
  36582. * @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
  36583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36585. * @returns a PickingInfo
  36586. */
  36587. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36588. /**
  36589. * Launch a ray to try to pick a mesh in the scene
  36590. * @param x X position on screen
  36591. * @param y Y position on screen
  36592. * @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
  36593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36594. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36595. * @returns an array of PickingInfo
  36596. */
  36597. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36598. /**
  36599. * Launch a ray to try to pick a mesh in the scene
  36600. * @param ray Ray to use
  36601. * @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
  36602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36603. * @returns an array of PickingInfo
  36604. */
  36605. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36606. /**
  36607. * Force the value of meshUnderPointer
  36608. * @param mesh defines the mesh to use
  36609. */
  36610. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36611. /**
  36612. * Gets the mesh under the pointer
  36613. * @returns a Mesh or null if no mesh is under the pointer
  36614. */
  36615. getPointerOverMesh(): Nullable<AbstractMesh>;
  36616. /** @hidden */
  36617. _rebuildGeometries(): void;
  36618. /** @hidden */
  36619. _rebuildTextures(): void;
  36620. private _getByTags;
  36621. /**
  36622. * Get a list of meshes by tags
  36623. * @param tagsQuery defines the tags query to use
  36624. * @param forEach defines a predicate used to filter results
  36625. * @returns an array of Mesh
  36626. */
  36627. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36628. /**
  36629. * Get a list of cameras by tags
  36630. * @param tagsQuery defines the tags query to use
  36631. * @param forEach defines a predicate used to filter results
  36632. * @returns an array of Camera
  36633. */
  36634. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36635. /**
  36636. * Get a list of lights by tags
  36637. * @param tagsQuery defines the tags query to use
  36638. * @param forEach defines a predicate used to filter results
  36639. * @returns an array of Light
  36640. */
  36641. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36642. /**
  36643. * Get a list of materials by tags
  36644. * @param tagsQuery defines the tags query to use
  36645. * @param forEach defines a predicate used to filter results
  36646. * @returns an array of Material
  36647. */
  36648. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36649. /**
  36650. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36651. * This allowed control for front to back rendering or reversly depending of the special needs.
  36652. *
  36653. * @param renderingGroupId The rendering group id corresponding to its index
  36654. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36655. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36656. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36657. */
  36658. 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;
  36659. /**
  36660. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36661. *
  36662. * @param renderingGroupId The rendering group id corresponding to its index
  36663. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36664. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36665. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36666. */
  36667. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36668. /**
  36669. * Gets the current auto clear configuration for one rendering group of the rendering
  36670. * manager.
  36671. * @param index the rendering group index to get the information for
  36672. * @returns The auto clear setup for the requested rendering group
  36673. */
  36674. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36675. private _blockMaterialDirtyMechanism;
  36676. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36677. get blockMaterialDirtyMechanism(): boolean;
  36678. set blockMaterialDirtyMechanism(value: boolean);
  36679. /**
  36680. * Will flag all materials as dirty to trigger new shader compilation
  36681. * @param flag defines the flag used to specify which material part must be marked as dirty
  36682. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36683. */
  36684. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36685. /** @hidden */
  36686. _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;
  36687. /** @hidden */
  36688. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36689. /** @hidden */
  36690. _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;
  36691. /** @hidden */
  36692. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36693. /** @hidden */
  36694. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36695. /** @hidden */
  36696. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * Set of assets to keep when moving a scene into an asset container.
  36702. */
  36703. export class KeepAssets extends AbstractScene {
  36704. }
  36705. /**
  36706. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36707. */
  36708. export class InstantiatedEntries {
  36709. /**
  36710. * List of new root nodes (eg. nodes with no parent)
  36711. */
  36712. rootNodes: TransformNode[];
  36713. /**
  36714. * List of new skeletons
  36715. */
  36716. skeletons: Skeleton[];
  36717. /**
  36718. * List of new animation groups
  36719. */
  36720. animationGroups: AnimationGroup[];
  36721. }
  36722. /**
  36723. * Container with a set of assets that can be added or removed from a scene.
  36724. */
  36725. export class AssetContainer extends AbstractScene {
  36726. /**
  36727. * The scene the AssetContainer belongs to.
  36728. */
  36729. scene: Scene;
  36730. /**
  36731. * Instantiates an AssetContainer.
  36732. * @param scene The scene the AssetContainer belongs to.
  36733. */
  36734. constructor(scene: Scene);
  36735. /**
  36736. * Instantiate or clone all meshes and add the new ones to the scene.
  36737. * Skeletons and animation groups will all be cloned
  36738. * @param nameFunction defines an optional function used to get new names for clones
  36739. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36740. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36741. */
  36742. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36743. /**
  36744. * Adds all the assets from the container to the scene.
  36745. */
  36746. addAllToScene(): void;
  36747. /**
  36748. * Removes all the assets in the container from the scene
  36749. */
  36750. removeAllFromScene(): void;
  36751. /**
  36752. * Disposes all the assets in the container
  36753. */
  36754. dispose(): void;
  36755. private _moveAssets;
  36756. /**
  36757. * Removes all the assets contained in the scene and adds them to the container.
  36758. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36759. */
  36760. moveAllFromScene(keepAssets?: KeepAssets): void;
  36761. /**
  36762. * 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.
  36763. * @returns the root mesh
  36764. */
  36765. createRootMesh(): Mesh;
  36766. /**
  36767. * Merge animations from this asset container into a scene
  36768. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36769. * @param animatables set of animatables to retarget to a node from the scene
  36770. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36771. */
  36772. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36773. }
  36774. }
  36775. declare module BABYLON {
  36776. /**
  36777. * Defines how the parser contract is defined.
  36778. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36779. */
  36780. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36781. /**
  36782. * Defines how the individual parser contract is defined.
  36783. * These parser can parse an individual asset
  36784. */
  36785. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36786. /**
  36787. * Base class of the scene acting as a container for the different elements composing a scene.
  36788. * This class is dynamically extended by the different components of the scene increasing
  36789. * flexibility and reducing coupling
  36790. */
  36791. export abstract class AbstractScene {
  36792. /**
  36793. * Stores the list of available parsers in the application.
  36794. */
  36795. private static _BabylonFileParsers;
  36796. /**
  36797. * Stores the list of available individual parsers in the application.
  36798. */
  36799. private static _IndividualBabylonFileParsers;
  36800. /**
  36801. * Adds a parser in the list of available ones
  36802. * @param name Defines the name of the parser
  36803. * @param parser Defines the parser to add
  36804. */
  36805. static AddParser(name: string, parser: BabylonFileParser): void;
  36806. /**
  36807. * Gets a general parser from the list of avaialble ones
  36808. * @param name Defines the name of the parser
  36809. * @returns the requested parser or null
  36810. */
  36811. static GetParser(name: string): Nullable<BabylonFileParser>;
  36812. /**
  36813. * Adds n individual parser in the list of available ones
  36814. * @param name Defines the name of the parser
  36815. * @param parser Defines the parser to add
  36816. */
  36817. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36818. /**
  36819. * Gets an individual parser from the list of avaialble ones
  36820. * @param name Defines the name of the parser
  36821. * @returns the requested parser or null
  36822. */
  36823. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36824. /**
  36825. * Parser json data and populate both a scene and its associated container object
  36826. * @param jsonData Defines the data to parse
  36827. * @param scene Defines the scene to parse the data for
  36828. * @param container Defines the container attached to the parsing sequence
  36829. * @param rootUrl Defines the root url of the data
  36830. */
  36831. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36832. /**
  36833. * Gets the list of root nodes (ie. nodes with no parent)
  36834. */
  36835. rootNodes: Node[];
  36836. /** All of the cameras added to this scene
  36837. * @see http://doc.babylonjs.com/babylon101/cameras
  36838. */
  36839. cameras: Camera[];
  36840. /**
  36841. * All of the lights added to this scene
  36842. * @see http://doc.babylonjs.com/babylon101/lights
  36843. */
  36844. lights: Light[];
  36845. /**
  36846. * All of the (abstract) meshes added to this scene
  36847. */
  36848. meshes: AbstractMesh[];
  36849. /**
  36850. * The list of skeletons added to the scene
  36851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36852. */
  36853. skeletons: Skeleton[];
  36854. /**
  36855. * All of the particle systems added to this scene
  36856. * @see http://doc.babylonjs.com/babylon101/particles
  36857. */
  36858. particleSystems: IParticleSystem[];
  36859. /**
  36860. * Gets a list of Animations associated with the scene
  36861. */
  36862. animations: Animation[];
  36863. /**
  36864. * All of the animation groups added to this scene
  36865. * @see http://doc.babylonjs.com/how_to/group
  36866. */
  36867. animationGroups: AnimationGroup[];
  36868. /**
  36869. * All of the multi-materials added to this scene
  36870. * @see http://doc.babylonjs.com/how_to/multi_materials
  36871. */
  36872. multiMaterials: MultiMaterial[];
  36873. /**
  36874. * All of the materials added to this scene
  36875. * In the context of a Scene, it is not supposed to be modified manually.
  36876. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36877. * Note also that the order of the Material within the array is not significant and might change.
  36878. * @see http://doc.babylonjs.com/babylon101/materials
  36879. */
  36880. materials: Material[];
  36881. /**
  36882. * The list of morph target managers added to the scene
  36883. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36884. */
  36885. morphTargetManagers: MorphTargetManager[];
  36886. /**
  36887. * The list of geometries used in the scene.
  36888. */
  36889. geometries: Geometry[];
  36890. /**
  36891. * All of the tranform nodes added to this scene
  36892. * In the context of a Scene, it is not supposed to be modified manually.
  36893. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36894. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36895. * @see http://doc.babylonjs.com/how_to/transformnode
  36896. */
  36897. transformNodes: TransformNode[];
  36898. /**
  36899. * ActionManagers available on the scene.
  36900. */
  36901. actionManagers: AbstractActionManager[];
  36902. /**
  36903. * Textures to keep.
  36904. */
  36905. textures: BaseTexture[];
  36906. /**
  36907. * Environment texture for the scene
  36908. */
  36909. environmentTexture: Nullable<BaseTexture>;
  36910. /**
  36911. * @returns all meshes, lights, cameras, transformNodes and bones
  36912. */
  36913. getNodes(): Array<Node>;
  36914. }
  36915. }
  36916. declare module BABYLON {
  36917. /**
  36918. * Interface used to define options for Sound class
  36919. */
  36920. export interface ISoundOptions {
  36921. /**
  36922. * Does the sound autoplay once loaded.
  36923. */
  36924. autoplay?: boolean;
  36925. /**
  36926. * Does the sound loop after it finishes playing once.
  36927. */
  36928. loop?: boolean;
  36929. /**
  36930. * Sound's volume
  36931. */
  36932. volume?: number;
  36933. /**
  36934. * Is it a spatial sound?
  36935. */
  36936. spatialSound?: boolean;
  36937. /**
  36938. * Maximum distance to hear that sound
  36939. */
  36940. maxDistance?: number;
  36941. /**
  36942. * Uses user defined attenuation function
  36943. */
  36944. useCustomAttenuation?: boolean;
  36945. /**
  36946. * Define the roll off factor of spatial sounds.
  36947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36948. */
  36949. rolloffFactor?: number;
  36950. /**
  36951. * Define the reference distance the sound should be heard perfectly.
  36952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36953. */
  36954. refDistance?: number;
  36955. /**
  36956. * Define the distance attenuation model the sound will follow.
  36957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36958. */
  36959. distanceModel?: string;
  36960. /**
  36961. * Defines the playback speed (1 by default)
  36962. */
  36963. playbackRate?: number;
  36964. /**
  36965. * Defines if the sound is from a streaming source
  36966. */
  36967. streaming?: boolean;
  36968. /**
  36969. * Defines an optional length (in seconds) inside the sound file
  36970. */
  36971. length?: number;
  36972. /**
  36973. * Defines an optional offset (in seconds) inside the sound file
  36974. */
  36975. offset?: number;
  36976. /**
  36977. * If true, URLs will not be required to state the audio file codec to use.
  36978. */
  36979. skipCodecCheck?: boolean;
  36980. }
  36981. /**
  36982. * Defines a sound that can be played in the application.
  36983. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36985. */
  36986. export class Sound {
  36987. /**
  36988. * The name of the sound in the scene.
  36989. */
  36990. name: string;
  36991. /**
  36992. * Does the sound autoplay once loaded.
  36993. */
  36994. autoplay: boolean;
  36995. /**
  36996. * Does the sound loop after it finishes playing once.
  36997. */
  36998. loop: boolean;
  36999. /**
  37000. * Does the sound use a custom attenuation curve to simulate the falloff
  37001. * happening when the source gets further away from the camera.
  37002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37003. */
  37004. useCustomAttenuation: boolean;
  37005. /**
  37006. * The sound track id this sound belongs to.
  37007. */
  37008. soundTrackId: number;
  37009. /**
  37010. * Is this sound currently played.
  37011. */
  37012. isPlaying: boolean;
  37013. /**
  37014. * Is this sound currently paused.
  37015. */
  37016. isPaused: boolean;
  37017. /**
  37018. * Does this sound enables spatial sound.
  37019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37020. */
  37021. spatialSound: boolean;
  37022. /**
  37023. * Define the reference distance the sound should be heard perfectly.
  37024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37025. */
  37026. refDistance: number;
  37027. /**
  37028. * Define the roll off factor of spatial sounds.
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37030. */
  37031. rolloffFactor: number;
  37032. /**
  37033. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37035. */
  37036. maxDistance: number;
  37037. /**
  37038. * Define the distance attenuation model the sound will follow.
  37039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37040. */
  37041. distanceModel: string;
  37042. /**
  37043. * @hidden
  37044. * Back Compat
  37045. **/
  37046. onended: () => any;
  37047. /**
  37048. * Observable event when the current playing sound finishes.
  37049. */
  37050. onEndedObservable: Observable<Sound>;
  37051. private _panningModel;
  37052. private _playbackRate;
  37053. private _streaming;
  37054. private _startTime;
  37055. private _startOffset;
  37056. private _position;
  37057. /** @hidden */
  37058. _positionInEmitterSpace: boolean;
  37059. private _localDirection;
  37060. private _volume;
  37061. private _isReadyToPlay;
  37062. private _isDirectional;
  37063. private _readyToPlayCallback;
  37064. private _audioBuffer;
  37065. private _soundSource;
  37066. private _streamingSource;
  37067. private _soundPanner;
  37068. private _soundGain;
  37069. private _inputAudioNode;
  37070. private _outputAudioNode;
  37071. private _coneInnerAngle;
  37072. private _coneOuterAngle;
  37073. private _coneOuterGain;
  37074. private _scene;
  37075. private _connectedTransformNode;
  37076. private _customAttenuationFunction;
  37077. private _registerFunc;
  37078. private _isOutputConnected;
  37079. private _htmlAudioElement;
  37080. private _urlType;
  37081. private _length?;
  37082. private _offset?;
  37083. /** @hidden */
  37084. static _SceneComponentInitialization: (scene: Scene) => void;
  37085. /**
  37086. * Create a sound and attach it to a scene
  37087. * @param name Name of your sound
  37088. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37089. * @param scene defines the scene the sound belongs to
  37090. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37091. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37092. */
  37093. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37094. /**
  37095. * Release the sound and its associated resources
  37096. */
  37097. dispose(): void;
  37098. /**
  37099. * Gets if the sounds is ready to be played or not.
  37100. * @returns true if ready, otherwise false
  37101. */
  37102. isReady(): boolean;
  37103. private _soundLoaded;
  37104. /**
  37105. * Sets the data of the sound from an audiobuffer
  37106. * @param audioBuffer The audioBuffer containing the data
  37107. */
  37108. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37109. /**
  37110. * Updates the current sounds options such as maxdistance, loop...
  37111. * @param options A JSON object containing values named as the object properties
  37112. */
  37113. updateOptions(options: ISoundOptions): void;
  37114. private _createSpatialParameters;
  37115. private _updateSpatialParameters;
  37116. /**
  37117. * Switch the panning model to HRTF:
  37118. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37120. */
  37121. switchPanningModelToHRTF(): void;
  37122. /**
  37123. * Switch the panning model to Equal Power:
  37124. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37126. */
  37127. switchPanningModelToEqualPower(): void;
  37128. private _switchPanningModel;
  37129. /**
  37130. * Connect this sound to a sound track audio node like gain...
  37131. * @param soundTrackAudioNode the sound track audio node to connect to
  37132. */
  37133. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37134. /**
  37135. * Transform this sound into a directional source
  37136. * @param coneInnerAngle Size of the inner cone in degree
  37137. * @param coneOuterAngle Size of the outer cone in degree
  37138. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37139. */
  37140. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37141. /**
  37142. * Gets or sets the inner angle for the directional cone.
  37143. */
  37144. get directionalConeInnerAngle(): number;
  37145. /**
  37146. * Gets or sets the inner angle for the directional cone.
  37147. */
  37148. set directionalConeInnerAngle(value: number);
  37149. /**
  37150. * Gets or sets the outer angle for the directional cone.
  37151. */
  37152. get directionalConeOuterAngle(): number;
  37153. /**
  37154. * Gets or sets the outer angle for the directional cone.
  37155. */
  37156. set directionalConeOuterAngle(value: number);
  37157. /**
  37158. * Sets the position of the emitter if spatial sound is enabled
  37159. * @param newPosition Defines the new posisiton
  37160. */
  37161. setPosition(newPosition: Vector3): void;
  37162. /**
  37163. * Sets the local direction of the emitter if spatial sound is enabled
  37164. * @param newLocalDirection Defines the new local direction
  37165. */
  37166. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37167. private _updateDirection;
  37168. /** @hidden */
  37169. updateDistanceFromListener(): void;
  37170. /**
  37171. * Sets a new custom attenuation function for the sound.
  37172. * @param callback Defines the function used for the attenuation
  37173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37174. */
  37175. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37176. /**
  37177. * Play the sound
  37178. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37179. * @param offset (optional) Start the sound at a specific time in seconds
  37180. * @param length (optional) Sound duration (in seconds)
  37181. */
  37182. play(time?: number, offset?: number, length?: number): void;
  37183. private _onended;
  37184. /**
  37185. * Stop the sound
  37186. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37187. */
  37188. stop(time?: number): void;
  37189. /**
  37190. * Put the sound in pause
  37191. */
  37192. pause(): void;
  37193. /**
  37194. * Sets a dedicated volume for this sounds
  37195. * @param newVolume Define the new volume of the sound
  37196. * @param time Define time for gradual change to new volume
  37197. */
  37198. setVolume(newVolume: number, time?: number): void;
  37199. /**
  37200. * Set the sound play back rate
  37201. * @param newPlaybackRate Define the playback rate the sound should be played at
  37202. */
  37203. setPlaybackRate(newPlaybackRate: number): void;
  37204. /**
  37205. * Gets the volume of the sound.
  37206. * @returns the volume of the sound
  37207. */
  37208. getVolume(): number;
  37209. /**
  37210. * Attach the sound to a dedicated mesh
  37211. * @param transformNode The transform node to connect the sound with
  37212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37213. */
  37214. attachToMesh(transformNode: TransformNode): void;
  37215. /**
  37216. * Detach the sound from the previously attached mesh
  37217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37218. */
  37219. detachFromMesh(): void;
  37220. private _onRegisterAfterWorldMatrixUpdate;
  37221. /**
  37222. * Clone the current sound in the scene.
  37223. * @returns the new sound clone
  37224. */
  37225. clone(): Nullable<Sound>;
  37226. /**
  37227. * Gets the current underlying audio buffer containing the data
  37228. * @returns the audio buffer
  37229. */
  37230. getAudioBuffer(): Nullable<AudioBuffer>;
  37231. /**
  37232. * Serializes the Sound in a JSON representation
  37233. * @returns the JSON representation of the sound
  37234. */
  37235. serialize(): any;
  37236. /**
  37237. * Parse a JSON representation of a sound to innstantiate in a given scene
  37238. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37239. * @param scene Define the scene the new parsed sound should be created in
  37240. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37241. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37242. * @returns the newly parsed sound
  37243. */
  37244. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37245. }
  37246. }
  37247. declare module BABYLON {
  37248. /**
  37249. * This defines an action helpful to play a defined sound on a triggered action.
  37250. */
  37251. export class PlaySoundAction extends Action {
  37252. private _sound;
  37253. /**
  37254. * Instantiate the action
  37255. * @param triggerOptions defines the trigger options
  37256. * @param sound defines the sound to play
  37257. * @param condition defines the trigger related conditions
  37258. */
  37259. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37260. /** @hidden */
  37261. _prepare(): void;
  37262. /**
  37263. * Execute the action and play the sound.
  37264. */
  37265. execute(): void;
  37266. /**
  37267. * Serializes the actions and its related information.
  37268. * @param parent defines the object to serialize in
  37269. * @returns the serialized object
  37270. */
  37271. serialize(parent: any): any;
  37272. }
  37273. /**
  37274. * This defines an action helpful to stop a defined sound on a triggered action.
  37275. */
  37276. export class StopSoundAction extends Action {
  37277. private _sound;
  37278. /**
  37279. * Instantiate the action
  37280. * @param triggerOptions defines the trigger options
  37281. * @param sound defines the sound to stop
  37282. * @param condition defines the trigger related conditions
  37283. */
  37284. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37285. /** @hidden */
  37286. _prepare(): void;
  37287. /**
  37288. * Execute the action and stop the sound.
  37289. */
  37290. execute(): void;
  37291. /**
  37292. * Serializes the actions and its related information.
  37293. * @param parent defines the object to serialize in
  37294. * @returns the serialized object
  37295. */
  37296. serialize(parent: any): any;
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * This defines an action responsible to change the value of a property
  37302. * by interpolating between its current value and the newly set one once triggered.
  37303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37304. */
  37305. export class InterpolateValueAction extends Action {
  37306. /**
  37307. * Defines the path of the property where the value should be interpolated
  37308. */
  37309. propertyPath: string;
  37310. /**
  37311. * Defines the target value at the end of the interpolation.
  37312. */
  37313. value: any;
  37314. /**
  37315. * Defines the time it will take for the property to interpolate to the value.
  37316. */
  37317. duration: number;
  37318. /**
  37319. * Defines if the other scene animations should be stopped when the action has been triggered
  37320. */
  37321. stopOtherAnimations?: boolean;
  37322. /**
  37323. * Defines a callback raised once the interpolation animation has been done.
  37324. */
  37325. onInterpolationDone?: () => void;
  37326. /**
  37327. * Observable triggered once the interpolation animation has been done.
  37328. */
  37329. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37330. private _target;
  37331. private _effectiveTarget;
  37332. private _property;
  37333. /**
  37334. * Instantiate the action
  37335. * @param triggerOptions defines the trigger options
  37336. * @param target defines the object containing the value to interpolate
  37337. * @param propertyPath defines the path to the property in the target object
  37338. * @param value defines the target value at the end of the interpolation
  37339. * @param duration deines the time it will take for the property to interpolate to the value.
  37340. * @param condition defines the trigger related conditions
  37341. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37342. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37343. */
  37344. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37345. /** @hidden */
  37346. _prepare(): void;
  37347. /**
  37348. * Execute the action starts the value interpolation.
  37349. */
  37350. execute(): void;
  37351. /**
  37352. * Serializes the actions and its related information.
  37353. * @param parent defines the object to serialize in
  37354. * @returns the serialized object
  37355. */
  37356. serialize(parent: any): any;
  37357. }
  37358. }
  37359. declare module BABYLON {
  37360. /**
  37361. * Options allowed during the creation of a sound track.
  37362. */
  37363. export interface ISoundTrackOptions {
  37364. /**
  37365. * The volume the sound track should take during creation
  37366. */
  37367. volume?: number;
  37368. /**
  37369. * Define if the sound track is the main sound track of the scene
  37370. */
  37371. mainTrack?: boolean;
  37372. }
  37373. /**
  37374. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37375. * It will be also used in a future release to apply effects on a specific track.
  37376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37377. */
  37378. export class SoundTrack {
  37379. /**
  37380. * The unique identifier of the sound track in the scene.
  37381. */
  37382. id: number;
  37383. /**
  37384. * The list of sounds included in the sound track.
  37385. */
  37386. soundCollection: Array<Sound>;
  37387. private _outputAudioNode;
  37388. private _scene;
  37389. private _connectedAnalyser;
  37390. private _options;
  37391. private _isInitialized;
  37392. /**
  37393. * Creates a new sound track.
  37394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37395. * @param scene Define the scene the sound track belongs to
  37396. * @param options
  37397. */
  37398. constructor(scene: Scene, options?: ISoundTrackOptions);
  37399. private _initializeSoundTrackAudioGraph;
  37400. /**
  37401. * Release the sound track and its associated resources
  37402. */
  37403. dispose(): void;
  37404. /**
  37405. * Adds a sound to this sound track
  37406. * @param sound define the cound to add
  37407. * @ignoreNaming
  37408. */
  37409. AddSound(sound: Sound): void;
  37410. /**
  37411. * Removes a sound to this sound track
  37412. * @param sound define the cound to remove
  37413. * @ignoreNaming
  37414. */
  37415. RemoveSound(sound: Sound): void;
  37416. /**
  37417. * Set a global volume for the full sound track.
  37418. * @param newVolume Define the new volume of the sound track
  37419. */
  37420. setVolume(newVolume: number): void;
  37421. /**
  37422. * Switch the panning model to HRTF:
  37423. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37425. */
  37426. switchPanningModelToHRTF(): void;
  37427. /**
  37428. * Switch the panning model to Equal Power:
  37429. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37431. */
  37432. switchPanningModelToEqualPower(): void;
  37433. /**
  37434. * Connect the sound track to an audio analyser allowing some amazing
  37435. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37437. * @param analyser The analyser to connect to the engine
  37438. */
  37439. connectToAnalyser(analyser: Analyser): void;
  37440. }
  37441. }
  37442. declare module BABYLON {
  37443. interface AbstractScene {
  37444. /**
  37445. * The list of sounds used in the scene.
  37446. */
  37447. sounds: Nullable<Array<Sound>>;
  37448. }
  37449. interface Scene {
  37450. /**
  37451. * @hidden
  37452. * Backing field
  37453. */
  37454. _mainSoundTrack: SoundTrack;
  37455. /**
  37456. * The main sound track played by the scene.
  37457. * It cotains your primary collection of sounds.
  37458. */
  37459. mainSoundTrack: SoundTrack;
  37460. /**
  37461. * The list of sound tracks added to the scene
  37462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37463. */
  37464. soundTracks: Nullable<Array<SoundTrack>>;
  37465. /**
  37466. * Gets a sound using a given name
  37467. * @param name defines the name to search for
  37468. * @return the found sound or null if not found at all.
  37469. */
  37470. getSoundByName(name: string): Nullable<Sound>;
  37471. /**
  37472. * Gets or sets if audio support is enabled
  37473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37474. */
  37475. audioEnabled: boolean;
  37476. /**
  37477. * Gets or sets if audio will be output to headphones
  37478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37479. */
  37480. headphone: boolean;
  37481. /**
  37482. * Gets or sets custom audio listener position provider
  37483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37484. */
  37485. audioListenerPositionProvider: Nullable<() => Vector3>;
  37486. /**
  37487. * Gets or sets a refresh rate when using 3D audio positioning
  37488. */
  37489. audioPositioningRefreshRate: number;
  37490. }
  37491. /**
  37492. * Defines the sound scene component responsible to manage any sounds
  37493. * in a given scene.
  37494. */
  37495. export class AudioSceneComponent implements ISceneSerializableComponent {
  37496. /**
  37497. * The component name helpfull to identify the component in the list of scene components.
  37498. */
  37499. readonly name: string;
  37500. /**
  37501. * The scene the component belongs to.
  37502. */
  37503. scene: Scene;
  37504. private _audioEnabled;
  37505. /**
  37506. * Gets whether audio is enabled or not.
  37507. * Please use related enable/disable method to switch state.
  37508. */
  37509. get audioEnabled(): boolean;
  37510. private _headphone;
  37511. /**
  37512. * Gets whether audio is outputing to headphone or not.
  37513. * Please use the according Switch methods to change output.
  37514. */
  37515. get headphone(): boolean;
  37516. /**
  37517. * Gets or sets a refresh rate when using 3D audio positioning
  37518. */
  37519. audioPositioningRefreshRate: number;
  37520. private _audioListenerPositionProvider;
  37521. /**
  37522. * Gets the current audio listener position provider
  37523. */
  37524. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37525. /**
  37526. * Sets a custom listener position for all sounds in the scene
  37527. * By default, this is the position of the first active camera
  37528. */
  37529. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37530. /**
  37531. * Creates a new instance of the component for the given scene
  37532. * @param scene Defines the scene to register the component in
  37533. */
  37534. constructor(scene: Scene);
  37535. /**
  37536. * Registers the component in a given scene
  37537. */
  37538. register(): void;
  37539. /**
  37540. * Rebuilds the elements related to this component in case of
  37541. * context lost for instance.
  37542. */
  37543. rebuild(): void;
  37544. /**
  37545. * Serializes the component data to the specified json object
  37546. * @param serializationObject The object to serialize to
  37547. */
  37548. serialize(serializationObject: any): void;
  37549. /**
  37550. * Adds all the elements from the container to the scene
  37551. * @param container the container holding the elements
  37552. */
  37553. addFromContainer(container: AbstractScene): void;
  37554. /**
  37555. * Removes all the elements in the container from the scene
  37556. * @param container contains the elements to remove
  37557. * @param dispose if the removed element should be disposed (default: false)
  37558. */
  37559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37560. /**
  37561. * Disposes the component and the associated ressources.
  37562. */
  37563. dispose(): void;
  37564. /**
  37565. * Disables audio in the associated scene.
  37566. */
  37567. disableAudio(): void;
  37568. /**
  37569. * Enables audio in the associated scene.
  37570. */
  37571. enableAudio(): void;
  37572. /**
  37573. * Switch audio to headphone output.
  37574. */
  37575. switchAudioModeForHeadphones(): void;
  37576. /**
  37577. * Switch audio to normal speakers.
  37578. */
  37579. switchAudioModeForNormalSpeakers(): void;
  37580. private _cachedCameraDirection;
  37581. private _cachedCameraPosition;
  37582. private _lastCheck;
  37583. private _afterRender;
  37584. }
  37585. }
  37586. declare module BABYLON {
  37587. /**
  37588. * Wraps one or more Sound objects and selects one with random weight for playback.
  37589. */
  37590. export class WeightedSound {
  37591. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37592. loop: boolean;
  37593. private _coneInnerAngle;
  37594. private _coneOuterAngle;
  37595. private _volume;
  37596. /** A Sound is currently playing. */
  37597. isPlaying: boolean;
  37598. /** A Sound is currently paused. */
  37599. isPaused: boolean;
  37600. private _sounds;
  37601. private _weights;
  37602. private _currentIndex?;
  37603. /**
  37604. * Creates a new WeightedSound from the list of sounds given.
  37605. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37606. * @param sounds Array of Sounds that will be selected from.
  37607. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37608. */
  37609. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37610. /**
  37611. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37612. */
  37613. get directionalConeInnerAngle(): number;
  37614. /**
  37615. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37616. */
  37617. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  37623. /**
  37624. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37625. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37626. */
  37627. set directionalConeOuterAngle(value: number);
  37628. /**
  37629. * Playback volume.
  37630. */
  37631. get volume(): number;
  37632. /**
  37633. * Playback volume.
  37634. */
  37635. set volume(value: number);
  37636. private _onended;
  37637. /**
  37638. * Suspend playback
  37639. */
  37640. pause(): void;
  37641. /**
  37642. * Stop playback
  37643. */
  37644. stop(): void;
  37645. /**
  37646. * Start playback.
  37647. * @param startOffset Position the clip head at a specific time in seconds.
  37648. */
  37649. play(startOffset?: number): void;
  37650. }
  37651. }
  37652. declare module BABYLON {
  37653. /**
  37654. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37655. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37656. */
  37657. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37658. /**
  37659. * Gets the name of the behavior.
  37660. */
  37661. get name(): string;
  37662. /**
  37663. * The easing function used by animations
  37664. */
  37665. static EasingFunction: BackEase;
  37666. /**
  37667. * The easing mode used by animations
  37668. */
  37669. static EasingMode: number;
  37670. /**
  37671. * The duration of the animation, in milliseconds
  37672. */
  37673. transitionDuration: number;
  37674. /**
  37675. * Length of the distance animated by the transition when lower radius is reached
  37676. */
  37677. lowerRadiusTransitionRange: number;
  37678. /**
  37679. * Length of the distance animated by the transition when upper radius is reached
  37680. */
  37681. upperRadiusTransitionRange: number;
  37682. private _autoTransitionRange;
  37683. /**
  37684. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37685. */
  37686. get autoTransitionRange(): boolean;
  37687. /**
  37688. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37689. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37690. */
  37691. set autoTransitionRange(value: boolean);
  37692. private _attachedCamera;
  37693. private _onAfterCheckInputsObserver;
  37694. private _onMeshTargetChangedObserver;
  37695. /**
  37696. * Initializes the behavior.
  37697. */
  37698. init(): void;
  37699. /**
  37700. * Attaches the behavior to its arc rotate camera.
  37701. * @param camera Defines the camera to attach the behavior to
  37702. */
  37703. attach(camera: ArcRotateCamera): void;
  37704. /**
  37705. * Detaches the behavior from its current arc rotate camera.
  37706. */
  37707. detach(): void;
  37708. private _radiusIsAnimating;
  37709. private _radiusBounceTransition;
  37710. private _animatables;
  37711. private _cachedWheelPrecision;
  37712. /**
  37713. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37714. * @param radiusLimit The limit to check against.
  37715. * @return Bool to indicate if at limit.
  37716. */
  37717. private _isRadiusAtLimit;
  37718. /**
  37719. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37720. * @param radiusDelta The delta by which to animate to. Can be negative.
  37721. */
  37722. private _applyBoundRadiusAnimation;
  37723. /**
  37724. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37725. */
  37726. protected _clearAnimationLocks(): void;
  37727. /**
  37728. * Stops and removes all animations that have been applied to the camera
  37729. */
  37730. stopAllAnimations(): void;
  37731. }
  37732. }
  37733. declare module BABYLON {
  37734. /**
  37735. * 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.
  37736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37737. */
  37738. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37739. /**
  37740. * Gets the name of the behavior.
  37741. */
  37742. get name(): string;
  37743. private _mode;
  37744. private _radiusScale;
  37745. private _positionScale;
  37746. private _defaultElevation;
  37747. private _elevationReturnTime;
  37748. private _elevationReturnWaitTime;
  37749. private _zoomStopsAnimation;
  37750. private _framingTime;
  37751. /**
  37752. * The easing function used by animations
  37753. */
  37754. static EasingFunction: ExponentialEase;
  37755. /**
  37756. * The easing mode used by animations
  37757. */
  37758. static EasingMode: number;
  37759. /**
  37760. * Sets the current mode used by the behavior
  37761. */
  37762. set mode(mode: number);
  37763. /**
  37764. * Gets current mode used by the behavior.
  37765. */
  37766. get mode(): number;
  37767. /**
  37768. * Sets the scale applied to the radius (1 by default)
  37769. */
  37770. set radiusScale(radius: number);
  37771. /**
  37772. * Gets the scale applied to the radius
  37773. */
  37774. get radiusScale(): number;
  37775. /**
  37776. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37777. */
  37778. set positionScale(scale: number);
  37779. /**
  37780. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37781. */
  37782. get positionScale(): number;
  37783. /**
  37784. * Sets 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. set defaultElevation(elevation: number);
  37788. /**
  37789. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37790. * behaviour is triggered, in radians.
  37791. */
  37792. get defaultElevation(): number;
  37793. /**
  37794. * Sets the time (in milliseconds) taken to return to the default beta position.
  37795. * Negative value indicates camera should not return to default.
  37796. */
  37797. set elevationReturnTime(speed: number);
  37798. /**
  37799. * Gets the time (in milliseconds) taken to return to the default beta position.
  37800. * Negative value indicates camera should not return to default.
  37801. */
  37802. get elevationReturnTime(): number;
  37803. /**
  37804. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37805. */
  37806. set elevationReturnWaitTime(time: number);
  37807. /**
  37808. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37809. */
  37810. get elevationReturnWaitTime(): number;
  37811. /**
  37812. * Sets the flag that indicates if user zooming should stop animation.
  37813. */
  37814. set zoomStopsAnimation(flag: boolean);
  37815. /**
  37816. * Gets the flag that indicates if user zooming should stop animation.
  37817. */
  37818. get zoomStopsAnimation(): boolean;
  37819. /**
  37820. * Sets the transition time when framing the mesh, in milliseconds
  37821. */
  37822. set framingTime(time: number);
  37823. /**
  37824. * Gets the transition time when framing the mesh, in milliseconds
  37825. */
  37826. get framingTime(): number;
  37827. /**
  37828. * Define if the behavior should automatically change the configured
  37829. * camera limits and sensibilities.
  37830. */
  37831. autoCorrectCameraLimitsAndSensibility: boolean;
  37832. private _onPrePointerObservableObserver;
  37833. private _onAfterCheckInputsObserver;
  37834. private _onMeshTargetChangedObserver;
  37835. private _attachedCamera;
  37836. private _isPointerDown;
  37837. private _lastInteractionTime;
  37838. /**
  37839. * Initializes the behavior.
  37840. */
  37841. init(): void;
  37842. /**
  37843. * Attaches the behavior to its arc rotate camera.
  37844. * @param camera Defines the camera to attach the behavior to
  37845. */
  37846. attach(camera: ArcRotateCamera): void;
  37847. /**
  37848. * Detaches the behavior from its current arc rotate camera.
  37849. */
  37850. detach(): void;
  37851. private _animatables;
  37852. private _betaIsAnimating;
  37853. private _betaTransition;
  37854. private _radiusTransition;
  37855. private _vectorTransition;
  37856. /**
  37857. * Targets the given mesh and updates zoom level accordingly.
  37858. * @param mesh The mesh to target.
  37859. * @param radius Optional. If a cached radius position already exists, overrides default.
  37860. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37861. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37862. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37863. */
  37864. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37865. /**
  37866. * Targets the given mesh with its children and updates zoom level accordingly.
  37867. * @param mesh The mesh to target.
  37868. * @param radius Optional. If a cached radius position already exists, overrides default.
  37869. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37870. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37871. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37872. */
  37873. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37874. /**
  37875. * Targets the given meshes with their children and updates zoom level accordingly.
  37876. * @param meshes The mesh to target.
  37877. * @param radius Optional. If a cached radius position already exists, overrides default.
  37878. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37879. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37880. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37881. */
  37882. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37883. /**
  37884. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37885. * @param minimumWorld Determines the smaller position of the bounding box extend
  37886. * @param maximumWorld Determines the bigger position of the bounding box extend
  37887. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37888. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37889. */
  37890. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37891. /**
  37892. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37893. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37894. * frustum width.
  37895. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37896. * to fully enclose the mesh in the viewing frustum.
  37897. */
  37898. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37899. /**
  37900. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37901. * is automatically returned to its default position (expected to be above ground plane).
  37902. */
  37903. private _maintainCameraAboveGround;
  37904. /**
  37905. * Returns the frustum slope based on the canvas ratio and camera FOV
  37906. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37907. */
  37908. private _getFrustumSlope;
  37909. /**
  37910. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37911. */
  37912. private _clearAnimationLocks;
  37913. /**
  37914. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37915. */
  37916. private _applyUserInteraction;
  37917. /**
  37918. * Stops and removes all animations that have been applied to the camera
  37919. */
  37920. stopAllAnimations(): void;
  37921. /**
  37922. * Gets a value indicating if the user is moving the camera
  37923. */
  37924. get isUserIsMoving(): boolean;
  37925. /**
  37926. * The camera can move all the way towards the mesh.
  37927. */
  37928. static IgnoreBoundsSizeMode: number;
  37929. /**
  37930. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37931. */
  37932. static FitFrustumSidesMode: number;
  37933. }
  37934. }
  37935. declare module BABYLON {
  37936. /**
  37937. * Base class for Camera Pointer Inputs.
  37938. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37939. * for example usage.
  37940. */
  37941. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37942. /**
  37943. * Defines the camera the input is attached to.
  37944. */
  37945. abstract camera: Camera;
  37946. /**
  37947. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37948. */
  37949. protected _altKey: boolean;
  37950. protected _ctrlKey: boolean;
  37951. protected _metaKey: boolean;
  37952. protected _shiftKey: boolean;
  37953. /**
  37954. * Which mouse buttons were pressed at time of last mouse event.
  37955. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37956. */
  37957. protected _buttonsPressed: number;
  37958. /**
  37959. * Defines the buttons associated with the input to handle camera move.
  37960. */
  37961. buttons: number[];
  37962. /**
  37963. * Attach the input controls to a specific dom element to get the input from.
  37964. * @param element Defines the element the controls should be listened from
  37965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37966. */
  37967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37968. /**
  37969. * Detach the current controls from the specified dom element.
  37970. * @param element Defines the element to stop listening the inputs from
  37971. */
  37972. detachControl(element: Nullable<HTMLElement>): void;
  37973. /**
  37974. * Gets the class name of the current input.
  37975. * @returns the class name
  37976. */
  37977. getClassName(): string;
  37978. /**
  37979. * Get the friendly name associated with the input class.
  37980. * @returns the input friendly name
  37981. */
  37982. getSimpleName(): string;
  37983. /**
  37984. * Called on pointer POINTERDOUBLETAP event.
  37985. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37986. */
  37987. protected onDoubleTap(type: string): void;
  37988. /**
  37989. * Called on pointer POINTERMOVE event if only a single touch is active.
  37990. * Override this method to provide functionality.
  37991. */
  37992. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37993. /**
  37994. * Called on pointer POINTERMOVE event if multiple touches are active.
  37995. * Override this method to provide functionality.
  37996. */
  37997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37998. /**
  37999. * Called on JS contextmenu event.
  38000. * Override this method to provide functionality.
  38001. */
  38002. protected onContextMenu(evt: PointerEvent): void;
  38003. /**
  38004. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38005. * press.
  38006. * Override this method to provide functionality.
  38007. */
  38008. protected onButtonDown(evt: PointerEvent): void;
  38009. /**
  38010. * Called each time a new POINTERUP event occurs. Ie, for each button
  38011. * release.
  38012. * Override this method to provide functionality.
  38013. */
  38014. protected onButtonUp(evt: PointerEvent): void;
  38015. /**
  38016. * Called when window becomes inactive.
  38017. * Override this method to provide functionality.
  38018. */
  38019. protected onLostFocus(): void;
  38020. private _pointerInput;
  38021. private _observer;
  38022. private _onLostFocus;
  38023. private pointA;
  38024. private pointB;
  38025. }
  38026. }
  38027. declare module BABYLON {
  38028. /**
  38029. * Manage the pointers inputs to control an arc rotate camera.
  38030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38031. */
  38032. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38033. /**
  38034. * Defines the camera the input is attached to.
  38035. */
  38036. camera: ArcRotateCamera;
  38037. /**
  38038. * Gets the class name of the current input.
  38039. * @returns the class name
  38040. */
  38041. getClassName(): string;
  38042. /**
  38043. * Defines the buttons associated with the input to handle camera move.
  38044. */
  38045. buttons: number[];
  38046. /**
  38047. * Defines the pointer angular sensibility along the X axis or how fast is
  38048. * the camera rotating.
  38049. */
  38050. angularSensibilityX: number;
  38051. /**
  38052. * Defines the pointer angular sensibility along the Y axis or how fast is
  38053. * the camera rotating.
  38054. */
  38055. angularSensibilityY: number;
  38056. /**
  38057. * Defines the pointer pinch precision or how fast is the camera zooming.
  38058. */
  38059. pinchPrecision: number;
  38060. /**
  38061. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38062. * from 0.
  38063. * It defines the percentage of current camera.radius to use as delta when
  38064. * pinch zoom is used.
  38065. */
  38066. pinchDeltaPercentage: number;
  38067. /**
  38068. * Defines the pointer panning sensibility or how fast is the camera moving.
  38069. */
  38070. panningSensibility: number;
  38071. /**
  38072. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38073. */
  38074. multiTouchPanning: boolean;
  38075. /**
  38076. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38077. * zoom (pinch) through multitouch.
  38078. */
  38079. multiTouchPanAndZoom: boolean;
  38080. /**
  38081. * Revers pinch action direction.
  38082. */
  38083. pinchInwards: boolean;
  38084. private _isPanClick;
  38085. private _twoFingerActivityCount;
  38086. private _isPinching;
  38087. /**
  38088. * Called on pointer POINTERMOVE event if only a single touch is active.
  38089. */
  38090. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38091. /**
  38092. * Called on pointer POINTERDOUBLETAP event.
  38093. */
  38094. protected onDoubleTap(type: string): void;
  38095. /**
  38096. * Called on pointer POINTERMOVE event if multiple touches are active.
  38097. */
  38098. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38099. /**
  38100. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38101. * press.
  38102. */
  38103. protected onButtonDown(evt: PointerEvent): void;
  38104. /**
  38105. * Called each time a new POINTERUP event occurs. Ie, for each button
  38106. * release.
  38107. */
  38108. protected onButtonUp(evt: PointerEvent): void;
  38109. /**
  38110. * Called when window becomes inactive.
  38111. */
  38112. protected onLostFocus(): void;
  38113. }
  38114. }
  38115. declare module BABYLON {
  38116. /**
  38117. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38119. */
  38120. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38121. /**
  38122. * Defines the camera the input is attached to.
  38123. */
  38124. camera: ArcRotateCamera;
  38125. /**
  38126. * Defines the list of key codes associated with the up action (increase alpha)
  38127. */
  38128. keysUp: number[];
  38129. /**
  38130. * Defines the list of key codes associated with the down action (decrease alpha)
  38131. */
  38132. keysDown: number[];
  38133. /**
  38134. * Defines the list of key codes associated with the left action (increase beta)
  38135. */
  38136. keysLeft: number[];
  38137. /**
  38138. * Defines the list of key codes associated with the right action (decrease beta)
  38139. */
  38140. keysRight: number[];
  38141. /**
  38142. * Defines the list of key codes associated with the reset action.
  38143. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38144. */
  38145. keysReset: number[];
  38146. /**
  38147. * Defines the panning sensibility of the inputs.
  38148. * (How fast is the camera paning)
  38149. */
  38150. panningSensibility: number;
  38151. /**
  38152. * Defines the zooming sensibility of the inputs.
  38153. * (How fast is the camera zooming)
  38154. */
  38155. zoomingSensibility: number;
  38156. /**
  38157. * Defines wether maintaining the alt key down switch the movement mode from
  38158. * orientation to zoom.
  38159. */
  38160. useAltToZoom: boolean;
  38161. /**
  38162. * Rotation speed of the camera
  38163. */
  38164. angularSpeed: number;
  38165. private _keys;
  38166. private _ctrlPressed;
  38167. private _altPressed;
  38168. private _onCanvasBlurObserver;
  38169. private _onKeyboardObserver;
  38170. private _engine;
  38171. private _scene;
  38172. /**
  38173. * Attach the input controls to a specific dom element to get the input from.
  38174. * @param element Defines the element the controls should be listened from
  38175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38176. */
  38177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38178. /**
  38179. * Detach the current controls from the specified dom element.
  38180. * @param element Defines the element to stop listening the inputs from
  38181. */
  38182. detachControl(element: Nullable<HTMLElement>): void;
  38183. /**
  38184. * Update the current camera state depending on the inputs that have been used this frame.
  38185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38186. */
  38187. checkInputs(): void;
  38188. /**
  38189. * Gets the class name of the current intput.
  38190. * @returns the class name
  38191. */
  38192. getClassName(): string;
  38193. /**
  38194. * Get the friendly name associated with the input class.
  38195. * @returns the input friendly name
  38196. */
  38197. getSimpleName(): string;
  38198. }
  38199. }
  38200. declare module BABYLON {
  38201. /**
  38202. * Manage the mouse wheel inputs to control an arc rotate camera.
  38203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38204. */
  38205. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38206. /**
  38207. * Defines the camera the input is attached to.
  38208. */
  38209. camera: ArcRotateCamera;
  38210. /**
  38211. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38212. */
  38213. wheelPrecision: number;
  38214. /**
  38215. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38216. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38217. */
  38218. wheelDeltaPercentage: number;
  38219. private _wheel;
  38220. private _observer;
  38221. private computeDeltaFromMouseWheelLegacyEvent;
  38222. /**
  38223. * Attach the input controls to a specific dom element to get the input from.
  38224. * @param element Defines the element the controls should be listened from
  38225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38226. */
  38227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38228. /**
  38229. * Detach the current controls from the specified dom element.
  38230. * @param element Defines the element to stop listening the inputs from
  38231. */
  38232. detachControl(element: Nullable<HTMLElement>): void;
  38233. /**
  38234. * Gets the class name of the current intput.
  38235. * @returns the class name
  38236. */
  38237. getClassName(): string;
  38238. /**
  38239. * Get the friendly name associated with the input class.
  38240. * @returns the input friendly name
  38241. */
  38242. getSimpleName(): string;
  38243. }
  38244. }
  38245. declare module BABYLON {
  38246. /**
  38247. * Default Inputs manager for the ArcRotateCamera.
  38248. * It groups all the default supported inputs for ease of use.
  38249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38250. */
  38251. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38252. /**
  38253. * Instantiates a new ArcRotateCameraInputsManager.
  38254. * @param camera Defines the camera the inputs belong to
  38255. */
  38256. constructor(camera: ArcRotateCamera);
  38257. /**
  38258. * Add mouse wheel input support to the input manager.
  38259. * @returns the current input manager
  38260. */
  38261. addMouseWheel(): ArcRotateCameraInputsManager;
  38262. /**
  38263. * Add pointers input support to the input manager.
  38264. * @returns the current input manager
  38265. */
  38266. addPointers(): ArcRotateCameraInputsManager;
  38267. /**
  38268. * Add keyboard input support to the input manager.
  38269. * @returns the current input manager
  38270. */
  38271. addKeyboard(): ArcRotateCameraInputsManager;
  38272. }
  38273. }
  38274. declare module BABYLON {
  38275. /**
  38276. * This represents an orbital type of camera.
  38277. *
  38278. * 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.
  38279. * 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.
  38280. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38281. */
  38282. export class ArcRotateCamera extends TargetCamera {
  38283. /**
  38284. * Defines the rotation angle of the camera along the longitudinal axis.
  38285. */
  38286. alpha: number;
  38287. /**
  38288. * Defines the rotation angle of the camera along the latitudinal axis.
  38289. */
  38290. beta: number;
  38291. /**
  38292. * Defines the radius of the camera from it s target point.
  38293. */
  38294. radius: number;
  38295. protected _target: Vector3;
  38296. protected _targetHost: Nullable<AbstractMesh>;
  38297. /**
  38298. * Defines the target point of the camera.
  38299. * The camera looks towards it form the radius distance.
  38300. */
  38301. get target(): Vector3;
  38302. set target(value: Vector3);
  38303. /**
  38304. * Define the current local position of the camera in the scene
  38305. */
  38306. get position(): Vector3;
  38307. set position(newPosition: Vector3);
  38308. protected _upVector: Vector3;
  38309. protected _upToYMatrix: Matrix;
  38310. protected _YToUpMatrix: Matrix;
  38311. /**
  38312. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38313. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38314. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38315. */
  38316. set upVector(vec: Vector3);
  38317. get upVector(): Vector3;
  38318. /**
  38319. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38320. */
  38321. setMatUp(): void;
  38322. /**
  38323. * Current inertia value on the longitudinal axis.
  38324. * The bigger this number the longer it will take for the camera to stop.
  38325. */
  38326. inertialAlphaOffset: number;
  38327. /**
  38328. * Current inertia value on the latitudinal axis.
  38329. * The bigger this number the longer it will take for the camera to stop.
  38330. */
  38331. inertialBetaOffset: number;
  38332. /**
  38333. * Current inertia value on the radius axis.
  38334. * The bigger this number the longer it will take for the camera to stop.
  38335. */
  38336. inertialRadiusOffset: number;
  38337. /**
  38338. * Minimum allowed angle on the longitudinal axis.
  38339. * This can help limiting how the Camera is able to move in the scene.
  38340. */
  38341. lowerAlphaLimit: Nullable<number>;
  38342. /**
  38343. * Maximum allowed angle on the longitudinal axis.
  38344. * This can help limiting how the Camera is able to move in the scene.
  38345. */
  38346. upperAlphaLimit: Nullable<number>;
  38347. /**
  38348. * Minimum allowed angle on the latitudinal axis.
  38349. * This can help limiting how the Camera is able to move in the scene.
  38350. */
  38351. lowerBetaLimit: number;
  38352. /**
  38353. * Maximum allowed angle on the latitudinal axis.
  38354. * This can help limiting how the Camera is able to move in the scene.
  38355. */
  38356. upperBetaLimit: number;
  38357. /**
  38358. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38359. * This can help limiting how the Camera is able to move in the scene.
  38360. */
  38361. lowerRadiusLimit: Nullable<number>;
  38362. /**
  38363. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38364. * This can help limiting how the Camera is able to move in the scene.
  38365. */
  38366. upperRadiusLimit: Nullable<number>;
  38367. /**
  38368. * Defines the current inertia value used during panning of the camera along the X axis.
  38369. */
  38370. inertialPanningX: number;
  38371. /**
  38372. * Defines the current inertia value used during panning of the camera along the Y axis.
  38373. */
  38374. inertialPanningY: number;
  38375. /**
  38376. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38377. * Basically if your fingers moves away from more than this distance you will be considered
  38378. * in pinch mode.
  38379. */
  38380. pinchToPanMaxDistance: number;
  38381. /**
  38382. * Defines the maximum distance the camera can pan.
  38383. * This could help keeping the cammera always in your scene.
  38384. */
  38385. panningDistanceLimit: Nullable<number>;
  38386. /**
  38387. * Defines the target of the camera before paning.
  38388. */
  38389. panningOriginTarget: Vector3;
  38390. /**
  38391. * Defines the value of the inertia used during panning.
  38392. * 0 would mean stop inertia and one would mean no decelleration at all.
  38393. */
  38394. panningInertia: number;
  38395. /**
  38396. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38397. */
  38398. get angularSensibilityX(): number;
  38399. set angularSensibilityX(value: number);
  38400. /**
  38401. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38402. */
  38403. get angularSensibilityY(): number;
  38404. set angularSensibilityY(value: number);
  38405. /**
  38406. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38407. */
  38408. get pinchPrecision(): number;
  38409. set pinchPrecision(value: number);
  38410. /**
  38411. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38412. * It will be used instead of pinchDeltaPrecision if different from 0.
  38413. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38414. */
  38415. get pinchDeltaPercentage(): number;
  38416. set pinchDeltaPercentage(value: number);
  38417. /**
  38418. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38419. */
  38420. get panningSensibility(): number;
  38421. set panningSensibility(value: number);
  38422. /**
  38423. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38424. */
  38425. get keysUp(): number[];
  38426. set keysUp(value: number[]);
  38427. /**
  38428. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38429. */
  38430. get keysDown(): number[];
  38431. set keysDown(value: number[]);
  38432. /**
  38433. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38434. */
  38435. get keysLeft(): number[];
  38436. set keysLeft(value: number[]);
  38437. /**
  38438. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38439. */
  38440. get keysRight(): number[];
  38441. set keysRight(value: number[]);
  38442. /**
  38443. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38444. */
  38445. get wheelPrecision(): number;
  38446. set wheelPrecision(value: number);
  38447. /**
  38448. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38449. * It will be used instead of pinchDeltaPrecision if different from 0.
  38450. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38451. */
  38452. get wheelDeltaPercentage(): number;
  38453. set wheelDeltaPercentage(value: number);
  38454. /**
  38455. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38456. */
  38457. zoomOnFactor: number;
  38458. /**
  38459. * Defines a screen offset for the camera position.
  38460. */
  38461. targetScreenOffset: Vector2;
  38462. /**
  38463. * Allows the camera to be completely reversed.
  38464. * If false the camera can not arrive upside down.
  38465. */
  38466. allowUpsideDown: boolean;
  38467. /**
  38468. * Define if double tap/click is used to restore the previously saved state of the camera.
  38469. */
  38470. useInputToRestoreState: boolean;
  38471. /** @hidden */
  38472. _viewMatrix: Matrix;
  38473. /** @hidden */
  38474. _useCtrlForPanning: boolean;
  38475. /** @hidden */
  38476. _panningMouseButton: number;
  38477. /**
  38478. * Defines the input associated to the camera.
  38479. */
  38480. inputs: ArcRotateCameraInputsManager;
  38481. /** @hidden */
  38482. _reset: () => void;
  38483. /**
  38484. * Defines the allowed panning axis.
  38485. */
  38486. panningAxis: Vector3;
  38487. protected _localDirection: Vector3;
  38488. protected _transformedDirection: Vector3;
  38489. private _bouncingBehavior;
  38490. /**
  38491. * Gets the bouncing behavior of the camera if it has been enabled.
  38492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38493. */
  38494. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38495. /**
  38496. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38498. */
  38499. get useBouncingBehavior(): boolean;
  38500. set useBouncingBehavior(value: boolean);
  38501. private _framingBehavior;
  38502. /**
  38503. * Gets the framing behavior of the camera if it has been enabled.
  38504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38505. */
  38506. get framingBehavior(): Nullable<FramingBehavior>;
  38507. /**
  38508. * Defines if the framing behavior of the camera is enabled on the camera.
  38509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38510. */
  38511. get useFramingBehavior(): boolean;
  38512. set useFramingBehavior(value: boolean);
  38513. private _autoRotationBehavior;
  38514. /**
  38515. * Gets the auto rotation behavior of the camera if it has been enabled.
  38516. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38517. */
  38518. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38519. /**
  38520. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38522. */
  38523. get useAutoRotationBehavior(): boolean;
  38524. set useAutoRotationBehavior(value: boolean);
  38525. /**
  38526. * Observable triggered when the mesh target has been changed on the camera.
  38527. */
  38528. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38529. /**
  38530. * Event raised when the camera is colliding with a mesh.
  38531. */
  38532. onCollide: (collidedMesh: AbstractMesh) => void;
  38533. /**
  38534. * Defines whether the camera should check collision with the objects oh the scene.
  38535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38536. */
  38537. checkCollisions: boolean;
  38538. /**
  38539. * Defines the collision radius of the camera.
  38540. * This simulates a sphere around the camera.
  38541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38542. */
  38543. collisionRadius: Vector3;
  38544. protected _collider: Collider;
  38545. protected _previousPosition: Vector3;
  38546. protected _collisionVelocity: Vector3;
  38547. protected _newPosition: Vector3;
  38548. protected _previousAlpha: number;
  38549. protected _previousBeta: number;
  38550. protected _previousRadius: number;
  38551. protected _collisionTriggered: boolean;
  38552. protected _targetBoundingCenter: Nullable<Vector3>;
  38553. private _computationVector;
  38554. /**
  38555. * Instantiates a new ArcRotateCamera in a given scene
  38556. * @param name Defines the name of the camera
  38557. * @param alpha Defines the camera rotation along the logitudinal axis
  38558. * @param beta Defines the camera rotation along the latitudinal axis
  38559. * @param radius Defines the camera distance from its target
  38560. * @param target Defines the camera target
  38561. * @param scene Defines the scene the camera belongs to
  38562. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38563. */
  38564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38565. /** @hidden */
  38566. _initCache(): void;
  38567. /** @hidden */
  38568. _updateCache(ignoreParentClass?: boolean): void;
  38569. protected _getTargetPosition(): Vector3;
  38570. private _storedAlpha;
  38571. private _storedBeta;
  38572. private _storedRadius;
  38573. private _storedTarget;
  38574. private _storedTargetScreenOffset;
  38575. /**
  38576. * Stores the current state of the camera (alpha, beta, radius and target)
  38577. * @returns the camera itself
  38578. */
  38579. storeState(): Camera;
  38580. /**
  38581. * @hidden
  38582. * Restored camera state. You must call storeState() first
  38583. */
  38584. _restoreStateValues(): boolean;
  38585. /** @hidden */
  38586. _isSynchronizedViewMatrix(): boolean;
  38587. /**
  38588. * Attached controls to the current camera.
  38589. * @param element Defines the element the controls should be listened from
  38590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38591. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38592. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38593. */
  38594. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38595. /**
  38596. * Detach the current controls from the camera.
  38597. * The camera will stop reacting to inputs.
  38598. * @param element Defines the element to stop listening the inputs from
  38599. */
  38600. detachControl(element: HTMLElement): void;
  38601. /** @hidden */
  38602. _checkInputs(): void;
  38603. protected _checkLimits(): void;
  38604. /**
  38605. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38606. */
  38607. rebuildAnglesAndRadius(): void;
  38608. /**
  38609. * Use a position to define the current camera related information like alpha, beta and radius
  38610. * @param position Defines the position to set the camera at
  38611. */
  38612. setPosition(position: Vector3): void;
  38613. /**
  38614. * Defines the target the camera should look at.
  38615. * This will automatically adapt alpha beta and radius to fit within the new target.
  38616. * @param target Defines the new target as a Vector or a mesh
  38617. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38618. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38619. */
  38620. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38621. /** @hidden */
  38622. _getViewMatrix(): Matrix;
  38623. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38624. /**
  38625. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38626. * @param meshes Defines the mesh to zoom on
  38627. * @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)
  38628. */
  38629. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38630. /**
  38631. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38632. * The target will be changed but the radius
  38633. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38634. * @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)
  38635. */
  38636. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38637. min: Vector3;
  38638. max: Vector3;
  38639. distance: number;
  38640. }, doNotUpdateMaxZ?: boolean): void;
  38641. /**
  38642. * @override
  38643. * Override Camera.createRigCamera
  38644. */
  38645. createRigCamera(name: string, cameraIndex: number): Camera;
  38646. /**
  38647. * @hidden
  38648. * @override
  38649. * Override Camera._updateRigCameras
  38650. */
  38651. _updateRigCameras(): void;
  38652. /**
  38653. * Destroy the camera and release the current resources hold by it.
  38654. */
  38655. dispose(): void;
  38656. /**
  38657. * Gets the current object class name.
  38658. * @return the class name
  38659. */
  38660. getClassName(): string;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /**
  38665. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38667. */
  38668. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38669. /**
  38670. * Gets the name of the behavior.
  38671. */
  38672. get name(): string;
  38673. private _zoomStopsAnimation;
  38674. private _idleRotationSpeed;
  38675. private _idleRotationWaitTime;
  38676. private _idleRotationSpinupTime;
  38677. /**
  38678. * Sets the flag that indicates if user zooming should stop animation.
  38679. */
  38680. set zoomStopsAnimation(flag: boolean);
  38681. /**
  38682. * Gets the flag that indicates if user zooming should stop animation.
  38683. */
  38684. get zoomStopsAnimation(): boolean;
  38685. /**
  38686. * Sets the default speed at which the camera rotates around the model.
  38687. */
  38688. set idleRotationSpeed(speed: number);
  38689. /**
  38690. * Gets the default speed at which the camera rotates around the model.
  38691. */
  38692. get idleRotationSpeed(): number;
  38693. /**
  38694. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38695. */
  38696. set idleRotationWaitTime(time: number);
  38697. /**
  38698. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38699. */
  38700. get idleRotationWaitTime(): number;
  38701. /**
  38702. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38703. */
  38704. set idleRotationSpinupTime(time: number);
  38705. /**
  38706. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38707. */
  38708. get idleRotationSpinupTime(): number;
  38709. /**
  38710. * Gets a value indicating if the camera is currently rotating because of this behavior
  38711. */
  38712. get rotationInProgress(): boolean;
  38713. private _onPrePointerObservableObserver;
  38714. private _onAfterCheckInputsObserver;
  38715. private _attachedCamera;
  38716. private _isPointerDown;
  38717. private _lastFrameTime;
  38718. private _lastInteractionTime;
  38719. private _cameraRotationSpeed;
  38720. /**
  38721. * Initializes the behavior.
  38722. */
  38723. init(): void;
  38724. /**
  38725. * Attaches the behavior to its arc rotate camera.
  38726. * @param camera Defines the camera to attach the behavior to
  38727. */
  38728. attach(camera: ArcRotateCamera): void;
  38729. /**
  38730. * Detaches the behavior from its current arc rotate camera.
  38731. */
  38732. detach(): void;
  38733. /**
  38734. * Returns true if user is scrolling.
  38735. * @return true if user is scrolling.
  38736. */
  38737. private _userIsZooming;
  38738. private _lastFrameRadius;
  38739. private _shouldAnimationStopForInteraction;
  38740. /**
  38741. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38742. */
  38743. private _applyUserInteraction;
  38744. private _userIsMoving;
  38745. }
  38746. }
  38747. declare module BABYLON {
  38748. /**
  38749. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38750. */
  38751. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38752. private ui;
  38753. /**
  38754. * The name of the behavior
  38755. */
  38756. name: string;
  38757. /**
  38758. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38759. */
  38760. distanceAwayFromFace: number;
  38761. /**
  38762. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38763. */
  38764. distanceAwayFromBottomOfFace: number;
  38765. private _faceVectors;
  38766. private _target;
  38767. private _scene;
  38768. private _onRenderObserver;
  38769. private _tmpMatrix;
  38770. private _tmpVector;
  38771. /**
  38772. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38773. * @param ui The transform node that should be attched to the mesh
  38774. */
  38775. constructor(ui: TransformNode);
  38776. /**
  38777. * Initializes the behavior
  38778. */
  38779. init(): void;
  38780. private _closestFace;
  38781. private _zeroVector;
  38782. private _lookAtTmpMatrix;
  38783. private _lookAtToRef;
  38784. /**
  38785. * Attaches the AttachToBoxBehavior to the passed in mesh
  38786. * @param target The mesh that the specified node will be attached to
  38787. */
  38788. attach(target: Mesh): void;
  38789. /**
  38790. * Detaches the behavior from the mesh
  38791. */
  38792. detach(): void;
  38793. }
  38794. }
  38795. declare module BABYLON {
  38796. /**
  38797. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38798. */
  38799. export class FadeInOutBehavior implements Behavior<Mesh> {
  38800. /**
  38801. * Time in milliseconds to delay before fading in (Default: 0)
  38802. */
  38803. delay: number;
  38804. /**
  38805. * Time in milliseconds for the mesh to fade in (Default: 300)
  38806. */
  38807. fadeInTime: number;
  38808. private _millisecondsPerFrame;
  38809. private _hovered;
  38810. private _hoverValue;
  38811. private _ownerNode;
  38812. /**
  38813. * Instatiates the FadeInOutBehavior
  38814. */
  38815. constructor();
  38816. /**
  38817. * The name of the behavior
  38818. */
  38819. get name(): string;
  38820. /**
  38821. * Initializes the behavior
  38822. */
  38823. init(): void;
  38824. /**
  38825. * Attaches the fade behavior on the passed in mesh
  38826. * @param ownerNode The mesh that will be faded in/out once attached
  38827. */
  38828. attach(ownerNode: Mesh): void;
  38829. /**
  38830. * Detaches the behavior from the mesh
  38831. */
  38832. detach(): void;
  38833. /**
  38834. * Triggers the mesh to begin fading in or out
  38835. * @param value if the object should fade in or out (true to fade in)
  38836. */
  38837. fadeIn(value: boolean): void;
  38838. private _update;
  38839. private _setAllVisibility;
  38840. }
  38841. }
  38842. declare module BABYLON {
  38843. /**
  38844. * Class containing a set of static utilities functions for managing Pivots
  38845. * @hidden
  38846. */
  38847. export class PivotTools {
  38848. private static _PivotCached;
  38849. private static _OldPivotPoint;
  38850. private static _PivotTranslation;
  38851. private static _PivotTmpVector;
  38852. /** @hidden */
  38853. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38854. /** @hidden */
  38855. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38856. }
  38857. }
  38858. declare module BABYLON {
  38859. /**
  38860. * Class containing static functions to help procedurally build meshes
  38861. */
  38862. export class PlaneBuilder {
  38863. /**
  38864. * Creates a plane mesh
  38865. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38866. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38867. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38869. * * 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
  38870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38871. * @param name defines the name of the mesh
  38872. * @param options defines the options used to create the mesh
  38873. * @param scene defines the hosting scene
  38874. * @returns the plane mesh
  38875. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38876. */
  38877. static CreatePlane(name: string, options: {
  38878. size?: number;
  38879. width?: number;
  38880. height?: number;
  38881. sideOrientation?: number;
  38882. frontUVs?: Vector4;
  38883. backUVs?: Vector4;
  38884. updatable?: boolean;
  38885. sourcePlane?: Plane;
  38886. }, scene?: Nullable<Scene>): Mesh;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. /**
  38891. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38892. */
  38893. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38894. private static _AnyMouseID;
  38895. /**
  38896. * Abstract mesh the behavior is set on
  38897. */
  38898. attachedNode: AbstractMesh;
  38899. private _dragPlane;
  38900. private _scene;
  38901. private _pointerObserver;
  38902. private _beforeRenderObserver;
  38903. private static _planeScene;
  38904. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38905. /**
  38906. * 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)
  38907. */
  38908. maxDragAngle: number;
  38909. /**
  38910. * @hidden
  38911. */
  38912. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38913. /**
  38914. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38915. */
  38916. currentDraggingPointerID: number;
  38917. /**
  38918. * The last position where the pointer hit the drag plane in world space
  38919. */
  38920. lastDragPosition: Vector3;
  38921. /**
  38922. * If the behavior is currently in a dragging state
  38923. */
  38924. dragging: boolean;
  38925. /**
  38926. * 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)
  38927. */
  38928. dragDeltaRatio: number;
  38929. /**
  38930. * If the drag plane orientation should be updated during the dragging (Default: true)
  38931. */
  38932. updateDragPlane: boolean;
  38933. private _debugMode;
  38934. private _moving;
  38935. /**
  38936. * Fires each time the attached mesh is dragged with the pointer
  38937. * * delta between last drag position and current drag position in world space
  38938. * * dragDistance along the drag axis
  38939. * * dragPlaneNormal normal of the current drag plane used during the drag
  38940. * * dragPlanePoint in world space where the drag intersects the drag plane
  38941. */
  38942. onDragObservable: Observable<{
  38943. delta: Vector3;
  38944. dragPlanePoint: Vector3;
  38945. dragPlaneNormal: Vector3;
  38946. dragDistance: number;
  38947. pointerId: number;
  38948. }>;
  38949. /**
  38950. * Fires each time a drag begins (eg. mouse down on mesh)
  38951. */
  38952. onDragStartObservable: Observable<{
  38953. dragPlanePoint: Vector3;
  38954. pointerId: number;
  38955. }>;
  38956. /**
  38957. * Fires each time a drag ends (eg. mouse release after drag)
  38958. */
  38959. onDragEndObservable: Observable<{
  38960. dragPlanePoint: Vector3;
  38961. pointerId: number;
  38962. }>;
  38963. /**
  38964. * If the attached mesh should be moved when dragged
  38965. */
  38966. moveAttached: boolean;
  38967. /**
  38968. * If the drag behavior will react to drag events (Default: true)
  38969. */
  38970. enabled: boolean;
  38971. /**
  38972. * If pointer events should start and release the drag (Default: true)
  38973. */
  38974. startAndReleaseDragOnPointerEvents: boolean;
  38975. /**
  38976. * If camera controls should be detached during the drag
  38977. */
  38978. detachCameraControls: boolean;
  38979. /**
  38980. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38981. */
  38982. useObjectOrientationForDragging: boolean;
  38983. private _options;
  38984. /**
  38985. * Gets the options used by the behavior
  38986. */
  38987. get options(): {
  38988. dragAxis?: Vector3;
  38989. dragPlaneNormal?: Vector3;
  38990. };
  38991. /**
  38992. * Sets the options used by the behavior
  38993. */
  38994. set options(options: {
  38995. dragAxis?: Vector3;
  38996. dragPlaneNormal?: Vector3;
  38997. });
  38998. /**
  38999. * Creates a pointer drag behavior that can be attached to a mesh
  39000. * @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)
  39001. */
  39002. constructor(options?: {
  39003. dragAxis?: Vector3;
  39004. dragPlaneNormal?: Vector3;
  39005. });
  39006. /**
  39007. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39008. */
  39009. validateDrag: (targetPosition: Vector3) => boolean;
  39010. /**
  39011. * The name of the behavior
  39012. */
  39013. get name(): string;
  39014. /**
  39015. * Initializes the behavior
  39016. */
  39017. init(): void;
  39018. private _tmpVector;
  39019. private _alternatePickedPoint;
  39020. private _worldDragAxis;
  39021. private _targetPosition;
  39022. private _attachedElement;
  39023. /**
  39024. * Attaches the drag behavior the passed in mesh
  39025. * @param ownerNode The mesh that will be dragged around once attached
  39026. * @param predicate Predicate to use for pick filtering
  39027. */
  39028. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39029. /**
  39030. * Force relase the drag action by code.
  39031. */
  39032. releaseDrag(): void;
  39033. private _startDragRay;
  39034. private _lastPointerRay;
  39035. /**
  39036. * Simulates the start of a pointer drag event on the behavior
  39037. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39038. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39039. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39040. */
  39041. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39042. private _startDrag;
  39043. private _dragDelta;
  39044. private _moveDrag;
  39045. private _pickWithRayOnDragPlane;
  39046. private _pointA;
  39047. private _pointB;
  39048. private _pointC;
  39049. private _lineA;
  39050. private _lineB;
  39051. private _localAxis;
  39052. private _lookAt;
  39053. private _updateDragPlanePosition;
  39054. /**
  39055. * Detaches the behavior from the mesh
  39056. */
  39057. detach(): void;
  39058. }
  39059. }
  39060. declare module BABYLON {
  39061. /**
  39062. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39063. */
  39064. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39065. private _dragBehaviorA;
  39066. private _dragBehaviorB;
  39067. private _startDistance;
  39068. private _initialScale;
  39069. private _targetScale;
  39070. private _ownerNode;
  39071. private _sceneRenderObserver;
  39072. /**
  39073. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39074. */
  39075. constructor();
  39076. /**
  39077. * The name of the behavior
  39078. */
  39079. get name(): string;
  39080. /**
  39081. * Initializes the behavior
  39082. */
  39083. init(): void;
  39084. private _getCurrentDistance;
  39085. /**
  39086. * Attaches the scale behavior the passed in mesh
  39087. * @param ownerNode The mesh that will be scaled around once attached
  39088. */
  39089. attach(ownerNode: Mesh): void;
  39090. /**
  39091. * Detaches the behavior from the mesh
  39092. */
  39093. detach(): void;
  39094. }
  39095. }
  39096. declare module BABYLON {
  39097. /**
  39098. * 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
  39099. */
  39100. export class SixDofDragBehavior implements Behavior<Mesh> {
  39101. private static _virtualScene;
  39102. private _ownerNode;
  39103. private _sceneRenderObserver;
  39104. private _scene;
  39105. private _targetPosition;
  39106. private _virtualOriginMesh;
  39107. private _virtualDragMesh;
  39108. private _pointerObserver;
  39109. private _moving;
  39110. private _startingOrientation;
  39111. /**
  39112. * 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)
  39113. */
  39114. private zDragFactor;
  39115. /**
  39116. * If the object should rotate to face the drag origin
  39117. */
  39118. rotateDraggedObject: boolean;
  39119. /**
  39120. * If the behavior is currently in a dragging state
  39121. */
  39122. dragging: boolean;
  39123. /**
  39124. * 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)
  39125. */
  39126. dragDeltaRatio: number;
  39127. /**
  39128. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39129. */
  39130. currentDraggingPointerID: number;
  39131. /**
  39132. * If camera controls should be detached during the drag
  39133. */
  39134. detachCameraControls: boolean;
  39135. /**
  39136. * Fires each time a drag starts
  39137. */
  39138. onDragStartObservable: Observable<{}>;
  39139. /**
  39140. * Fires each time a drag ends (eg. mouse release after drag)
  39141. */
  39142. onDragEndObservable: Observable<{}>;
  39143. /**
  39144. * 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
  39145. */
  39146. constructor();
  39147. /**
  39148. * The name of the behavior
  39149. */
  39150. get name(): string;
  39151. /**
  39152. * Initializes the behavior
  39153. */
  39154. init(): void;
  39155. /**
  39156. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39157. */
  39158. private get _pointerCamera();
  39159. /**
  39160. * Attaches the scale behavior the passed in mesh
  39161. * @param ownerNode The mesh that will be scaled around once attached
  39162. */
  39163. attach(ownerNode: Mesh): void;
  39164. /**
  39165. * Detaches the behavior from the mesh
  39166. */
  39167. detach(): void;
  39168. }
  39169. }
  39170. declare module BABYLON {
  39171. /**
  39172. * Class used to apply inverse kinematics to bones
  39173. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39174. */
  39175. export class BoneIKController {
  39176. private static _tmpVecs;
  39177. private static _tmpQuat;
  39178. private static _tmpMats;
  39179. /**
  39180. * Gets or sets the target mesh
  39181. */
  39182. targetMesh: AbstractMesh;
  39183. /** Gets or sets the mesh used as pole */
  39184. poleTargetMesh: AbstractMesh;
  39185. /**
  39186. * Gets or sets the bone used as pole
  39187. */
  39188. poleTargetBone: Nullable<Bone>;
  39189. /**
  39190. * Gets or sets the target position
  39191. */
  39192. targetPosition: Vector3;
  39193. /**
  39194. * Gets or sets the pole target position
  39195. */
  39196. poleTargetPosition: Vector3;
  39197. /**
  39198. * Gets or sets the pole target local offset
  39199. */
  39200. poleTargetLocalOffset: Vector3;
  39201. /**
  39202. * Gets or sets the pole angle
  39203. */
  39204. poleAngle: number;
  39205. /**
  39206. * Gets or sets the mesh associated with the controller
  39207. */
  39208. mesh: AbstractMesh;
  39209. /**
  39210. * 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)
  39211. */
  39212. slerpAmount: number;
  39213. private _bone1Quat;
  39214. private _bone1Mat;
  39215. private _bone2Ang;
  39216. private _bone1;
  39217. private _bone2;
  39218. private _bone1Length;
  39219. private _bone2Length;
  39220. private _maxAngle;
  39221. private _maxReach;
  39222. private _rightHandedSystem;
  39223. private _bendAxis;
  39224. private _slerping;
  39225. private _adjustRoll;
  39226. /**
  39227. * Gets or sets maximum allowed angle
  39228. */
  39229. get maxAngle(): number;
  39230. set maxAngle(value: number);
  39231. /**
  39232. * Creates a new BoneIKController
  39233. * @param mesh defines the mesh to control
  39234. * @param bone defines the bone to control
  39235. * @param options defines options to set up the controller
  39236. */
  39237. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39238. targetMesh?: AbstractMesh;
  39239. poleTargetMesh?: AbstractMesh;
  39240. poleTargetBone?: Bone;
  39241. poleTargetLocalOffset?: Vector3;
  39242. poleAngle?: number;
  39243. bendAxis?: Vector3;
  39244. maxAngle?: number;
  39245. slerpAmount?: number;
  39246. });
  39247. private _setMaxAngle;
  39248. /**
  39249. * Force the controller to update the bones
  39250. */
  39251. update(): void;
  39252. }
  39253. }
  39254. declare module BABYLON {
  39255. /**
  39256. * Class used to make a bone look toward a point in space
  39257. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39258. */
  39259. export class BoneLookController {
  39260. private static _tmpVecs;
  39261. private static _tmpQuat;
  39262. private static _tmpMats;
  39263. /**
  39264. * The target Vector3 that the bone will look at
  39265. */
  39266. target: Vector3;
  39267. /**
  39268. * The mesh that the bone is attached to
  39269. */
  39270. mesh: AbstractMesh;
  39271. /**
  39272. * The bone that will be looking to the target
  39273. */
  39274. bone: Bone;
  39275. /**
  39276. * The up axis of the coordinate system that is used when the bone is rotated
  39277. */
  39278. upAxis: Vector3;
  39279. /**
  39280. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39281. */
  39282. upAxisSpace: Space;
  39283. /**
  39284. * Used to make an adjustment to the yaw of the bone
  39285. */
  39286. adjustYaw: number;
  39287. /**
  39288. * Used to make an adjustment to the pitch of the bone
  39289. */
  39290. adjustPitch: number;
  39291. /**
  39292. * Used to make an adjustment to the roll of the bone
  39293. */
  39294. adjustRoll: number;
  39295. /**
  39296. * 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)
  39297. */
  39298. slerpAmount: number;
  39299. private _minYaw;
  39300. private _maxYaw;
  39301. private _minPitch;
  39302. private _maxPitch;
  39303. private _minYawSin;
  39304. private _minYawCos;
  39305. private _maxYawSin;
  39306. private _maxYawCos;
  39307. private _midYawConstraint;
  39308. private _minPitchTan;
  39309. private _maxPitchTan;
  39310. private _boneQuat;
  39311. private _slerping;
  39312. private _transformYawPitch;
  39313. private _transformYawPitchInv;
  39314. private _firstFrameSkipped;
  39315. private _yawRange;
  39316. private _fowardAxis;
  39317. /**
  39318. * Gets or sets the minimum yaw angle that the bone can look to
  39319. */
  39320. get minYaw(): number;
  39321. set minYaw(value: number);
  39322. /**
  39323. * Gets or sets the maximum yaw angle that the bone can look to
  39324. */
  39325. get maxYaw(): number;
  39326. set maxYaw(value: number);
  39327. /**
  39328. * Gets or sets the minimum pitch angle that the bone can look to
  39329. */
  39330. get minPitch(): number;
  39331. set minPitch(value: number);
  39332. /**
  39333. * Gets or sets the maximum pitch angle that the bone can look to
  39334. */
  39335. get maxPitch(): number;
  39336. set maxPitch(value: number);
  39337. /**
  39338. * Create a BoneLookController
  39339. * @param mesh the mesh that the bone belongs to
  39340. * @param bone the bone that will be looking to the target
  39341. * @param target the target Vector3 to look at
  39342. * @param options optional settings:
  39343. * * maxYaw: the maximum angle the bone will yaw to
  39344. * * minYaw: the minimum angle the bone will yaw to
  39345. * * maxPitch: the maximum angle the bone will pitch to
  39346. * * minPitch: the minimum angle the bone will yaw to
  39347. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39348. * * upAxis: the up axis of the coordinate system
  39349. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39350. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39351. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39352. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39353. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39354. * * adjustRoll: used to make an adjustment to the roll of the bone
  39355. **/
  39356. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39357. maxYaw?: number;
  39358. minYaw?: number;
  39359. maxPitch?: number;
  39360. minPitch?: number;
  39361. slerpAmount?: number;
  39362. upAxis?: Vector3;
  39363. upAxisSpace?: Space;
  39364. yawAxis?: Vector3;
  39365. pitchAxis?: Vector3;
  39366. adjustYaw?: number;
  39367. adjustPitch?: number;
  39368. adjustRoll?: number;
  39369. });
  39370. /**
  39371. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39372. */
  39373. update(): void;
  39374. private _getAngleDiff;
  39375. private _getAngleBetween;
  39376. private _isAngleBetween;
  39377. }
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * Manage the gamepad inputs to control an arc rotate camera.
  39382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39383. */
  39384. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39385. /**
  39386. * Defines the camera the input is attached to.
  39387. */
  39388. camera: ArcRotateCamera;
  39389. /**
  39390. * Defines the gamepad the input is gathering event from.
  39391. */
  39392. gamepad: Nullable<Gamepad>;
  39393. /**
  39394. * Defines the gamepad rotation sensiblity.
  39395. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39396. */
  39397. gamepadRotationSensibility: number;
  39398. /**
  39399. * Defines the gamepad move sensiblity.
  39400. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39401. */
  39402. gamepadMoveSensibility: number;
  39403. private _yAxisScale;
  39404. /**
  39405. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39406. */
  39407. get invertYAxis(): boolean;
  39408. set invertYAxis(value: boolean);
  39409. private _onGamepadConnectedObserver;
  39410. private _onGamepadDisconnectedObserver;
  39411. /**
  39412. * Attach the input controls to a specific dom element to get the input from.
  39413. * @param element Defines the element the controls should be listened from
  39414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39415. */
  39416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39417. /**
  39418. * Detach the current controls from the specified dom element.
  39419. * @param element Defines the element to stop listening the inputs from
  39420. */
  39421. detachControl(element: Nullable<HTMLElement>): void;
  39422. /**
  39423. * Update the current camera state depending on the inputs that have been used this frame.
  39424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39425. */
  39426. checkInputs(): void;
  39427. /**
  39428. * Gets the class name of the current intput.
  39429. * @returns the class name
  39430. */
  39431. getClassName(): string;
  39432. /**
  39433. * Get the friendly name associated with the input class.
  39434. * @returns the input friendly name
  39435. */
  39436. getSimpleName(): string;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. interface ArcRotateCameraInputsManager {
  39441. /**
  39442. * Add orientation input support to the input manager.
  39443. * @returns the current input manager
  39444. */
  39445. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39446. }
  39447. /**
  39448. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39450. */
  39451. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39452. /**
  39453. * Defines the camera the input is attached to.
  39454. */
  39455. camera: ArcRotateCamera;
  39456. /**
  39457. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39458. */
  39459. alphaCorrection: number;
  39460. /**
  39461. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39462. */
  39463. gammaCorrection: number;
  39464. private _alpha;
  39465. private _gamma;
  39466. private _dirty;
  39467. private _deviceOrientationHandler;
  39468. /**
  39469. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39470. */
  39471. constructor();
  39472. /**
  39473. * Attach the input controls to a specific dom element to get the input from.
  39474. * @param element Defines the element the controls should be listened from
  39475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39476. */
  39477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39478. /** @hidden */
  39479. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39480. /**
  39481. * Update the current camera state depending on the inputs that have been used this frame.
  39482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39483. */
  39484. checkInputs(): void;
  39485. /**
  39486. * Detach the current controls from the specified dom element.
  39487. * @param element Defines the element to stop listening the inputs from
  39488. */
  39489. detachControl(element: Nullable<HTMLElement>): void;
  39490. /**
  39491. * Gets the class name of the current intput.
  39492. * @returns the class name
  39493. */
  39494. getClassName(): string;
  39495. /**
  39496. * Get the friendly name associated with the input class.
  39497. * @returns the input friendly name
  39498. */
  39499. getSimpleName(): string;
  39500. }
  39501. }
  39502. declare module BABYLON {
  39503. /**
  39504. * Listen to mouse events to control the camera.
  39505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39506. */
  39507. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39508. /**
  39509. * Defines the camera the input is attached to.
  39510. */
  39511. camera: FlyCamera;
  39512. /**
  39513. * Defines if touch is enabled. (Default is true.)
  39514. */
  39515. touchEnabled: boolean;
  39516. /**
  39517. * Defines the buttons associated with the input to handle camera rotation.
  39518. */
  39519. buttons: number[];
  39520. /**
  39521. * Assign buttons for Yaw control.
  39522. */
  39523. buttonsYaw: number[];
  39524. /**
  39525. * Assign buttons for Pitch control.
  39526. */
  39527. buttonsPitch: number[];
  39528. /**
  39529. * Assign buttons for Roll control.
  39530. */
  39531. buttonsRoll: number[];
  39532. /**
  39533. * Detect if any button is being pressed while mouse is moved.
  39534. * -1 = Mouse locked.
  39535. * 0 = Left button.
  39536. * 1 = Middle Button.
  39537. * 2 = Right Button.
  39538. */
  39539. activeButton: number;
  39540. /**
  39541. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39542. * Higher values reduce its sensitivity.
  39543. */
  39544. angularSensibility: number;
  39545. private _mousemoveCallback;
  39546. private _observer;
  39547. private _rollObserver;
  39548. private previousPosition;
  39549. private noPreventDefault;
  39550. private element;
  39551. /**
  39552. * Listen to mouse events to control the camera.
  39553. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39555. */
  39556. constructor(touchEnabled?: boolean);
  39557. /**
  39558. * Attach the mouse control to the HTML DOM element.
  39559. * @param element Defines the element that listens to the input events.
  39560. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39561. */
  39562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39563. /**
  39564. * Detach the current controls from the specified dom element.
  39565. * @param element Defines the element to stop listening the inputs from
  39566. */
  39567. detachControl(element: Nullable<HTMLElement>): void;
  39568. /**
  39569. * Gets the class name of the current input.
  39570. * @returns the class name.
  39571. */
  39572. getClassName(): string;
  39573. /**
  39574. * Get the friendly name associated with the input class.
  39575. * @returns the input's friendly name.
  39576. */
  39577. getSimpleName(): string;
  39578. private _pointerInput;
  39579. private _onMouseMove;
  39580. /**
  39581. * Rotate camera by mouse offset.
  39582. */
  39583. private rotateCamera;
  39584. }
  39585. }
  39586. declare module BABYLON {
  39587. /**
  39588. * Default Inputs manager for the FlyCamera.
  39589. * It groups all the default supported inputs for ease of use.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39593. /**
  39594. * Instantiates a new FlyCameraInputsManager.
  39595. * @param camera Defines the camera the inputs belong to.
  39596. */
  39597. constructor(camera: FlyCamera);
  39598. /**
  39599. * Add keyboard input support to the input manager.
  39600. * @returns the new FlyCameraKeyboardMoveInput().
  39601. */
  39602. addKeyboard(): FlyCameraInputsManager;
  39603. /**
  39604. * Add mouse input support to the input manager.
  39605. * @param touchEnabled Enable touch screen support.
  39606. * @returns the new FlyCameraMouseInput().
  39607. */
  39608. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. /**
  39613. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39614. * such as in a 3D Space Shooter or a Flight Simulator.
  39615. */
  39616. export class FlyCamera extends TargetCamera {
  39617. /**
  39618. * Define the collision ellipsoid of the camera.
  39619. * This is helpful for simulating a camera body, like a player's body.
  39620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39621. */
  39622. ellipsoid: Vector3;
  39623. /**
  39624. * Define an offset for the position of the ellipsoid around the camera.
  39625. * This can be helpful if the camera is attached away from the player's body center,
  39626. * such as at its head.
  39627. */
  39628. ellipsoidOffset: Vector3;
  39629. /**
  39630. * Enable or disable collisions of the camera with the rest of the scene objects.
  39631. */
  39632. checkCollisions: boolean;
  39633. /**
  39634. * Enable or disable gravity on the camera.
  39635. */
  39636. applyGravity: boolean;
  39637. /**
  39638. * Define the current direction the camera is moving to.
  39639. */
  39640. cameraDirection: Vector3;
  39641. /**
  39642. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39643. * This overrides and empties cameraRotation.
  39644. */
  39645. rotationQuaternion: Quaternion;
  39646. /**
  39647. * Track Roll to maintain the wanted Rolling when looking around.
  39648. */
  39649. _trackRoll: number;
  39650. /**
  39651. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39652. */
  39653. rollCorrect: number;
  39654. /**
  39655. * Mimic a banked turn, Rolling the camera when Yawing.
  39656. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39657. */
  39658. bankedTurn: boolean;
  39659. /**
  39660. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39661. */
  39662. bankedTurnLimit: number;
  39663. /**
  39664. * Value of 0 disables the banked Roll.
  39665. * Value of 1 is equal to the Yaw angle in radians.
  39666. */
  39667. bankedTurnMultiplier: number;
  39668. /**
  39669. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39670. */
  39671. inputs: FlyCameraInputsManager;
  39672. /**
  39673. * Gets the input sensibility for mouse input.
  39674. * Higher values reduce sensitivity.
  39675. */
  39676. get angularSensibility(): number;
  39677. /**
  39678. * Sets the input sensibility for a mouse input.
  39679. * Higher values reduce sensitivity.
  39680. */
  39681. set angularSensibility(value: number);
  39682. /**
  39683. * Get the keys for camera movement forward.
  39684. */
  39685. get keysForward(): number[];
  39686. /**
  39687. * Set the keys for camera movement forward.
  39688. */
  39689. set keysForward(value: number[]);
  39690. /**
  39691. * Get the keys for camera movement backward.
  39692. */
  39693. get keysBackward(): number[];
  39694. set keysBackward(value: number[]);
  39695. /**
  39696. * Get the keys for camera movement up.
  39697. */
  39698. get keysUp(): number[];
  39699. /**
  39700. * Set the keys for camera movement up.
  39701. */
  39702. set keysUp(value: number[]);
  39703. /**
  39704. * Get the keys for camera movement down.
  39705. */
  39706. get keysDown(): number[];
  39707. /**
  39708. * Set the keys for camera movement down.
  39709. */
  39710. set keysDown(value: number[]);
  39711. /**
  39712. * Get the keys for camera movement left.
  39713. */
  39714. get keysLeft(): number[];
  39715. /**
  39716. * Set the keys for camera movement left.
  39717. */
  39718. set keysLeft(value: number[]);
  39719. /**
  39720. * Set the keys for camera movement right.
  39721. */
  39722. get keysRight(): number[];
  39723. /**
  39724. * Set the keys for camera movement right.
  39725. */
  39726. set keysRight(value: number[]);
  39727. /**
  39728. * Event raised when the camera collides with a mesh in the scene.
  39729. */
  39730. onCollide: (collidedMesh: AbstractMesh) => void;
  39731. private _collider;
  39732. private _needMoveForGravity;
  39733. private _oldPosition;
  39734. private _diffPosition;
  39735. private _newPosition;
  39736. /** @hidden */
  39737. _localDirection: Vector3;
  39738. /** @hidden */
  39739. _transformedDirection: Vector3;
  39740. /**
  39741. * Instantiates a FlyCamera.
  39742. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39743. * such as in a 3D Space Shooter or a Flight Simulator.
  39744. * @param name Define the name of the camera in the scene.
  39745. * @param position Define the starting position of the camera in the scene.
  39746. * @param scene Define the scene the camera belongs to.
  39747. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39748. */
  39749. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39750. /**
  39751. * Attach a control to the HTML DOM element.
  39752. * @param element Defines the element that listens to the input events.
  39753. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39754. */
  39755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39756. /**
  39757. * Detach a control from the HTML DOM element.
  39758. * The camera will stop reacting to that input.
  39759. * @param element Defines the element that listens to the input events.
  39760. */
  39761. detachControl(element: HTMLElement): void;
  39762. private _collisionMask;
  39763. /**
  39764. * Get the mask that the camera ignores in collision events.
  39765. */
  39766. get collisionMask(): number;
  39767. /**
  39768. * Set the mask that the camera ignores in collision events.
  39769. */
  39770. set collisionMask(mask: number);
  39771. /** @hidden */
  39772. _collideWithWorld(displacement: Vector3): void;
  39773. /** @hidden */
  39774. private _onCollisionPositionChange;
  39775. /** @hidden */
  39776. _checkInputs(): void;
  39777. /** @hidden */
  39778. _decideIfNeedsToMove(): boolean;
  39779. /** @hidden */
  39780. _updatePosition(): void;
  39781. /**
  39782. * Restore the Roll to its target value at the rate specified.
  39783. * @param rate - Higher means slower restoring.
  39784. * @hidden
  39785. */
  39786. restoreRoll(rate: number): void;
  39787. /**
  39788. * Destroy the camera and release the current resources held by it.
  39789. */
  39790. dispose(): void;
  39791. /**
  39792. * Get the current object class name.
  39793. * @returns the class name.
  39794. */
  39795. getClassName(): string;
  39796. }
  39797. }
  39798. declare module BABYLON {
  39799. /**
  39800. * Listen to keyboard events to control the camera.
  39801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39802. */
  39803. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39804. /**
  39805. * Defines the camera the input is attached to.
  39806. */
  39807. camera: FlyCamera;
  39808. /**
  39809. * The list of keyboard keys used to control the forward move of the camera.
  39810. */
  39811. keysForward: number[];
  39812. /**
  39813. * The list of keyboard keys used to control the backward move of the camera.
  39814. */
  39815. keysBackward: number[];
  39816. /**
  39817. * The list of keyboard keys used to control the forward move of the camera.
  39818. */
  39819. keysUp: number[];
  39820. /**
  39821. * The list of keyboard keys used to control the backward move of the camera.
  39822. */
  39823. keysDown: number[];
  39824. /**
  39825. * The list of keyboard keys used to control the right strafe move of the camera.
  39826. */
  39827. keysRight: number[];
  39828. /**
  39829. * The list of keyboard keys used to control the left strafe move of the camera.
  39830. */
  39831. keysLeft: number[];
  39832. private _keys;
  39833. private _onCanvasBlurObserver;
  39834. private _onKeyboardObserver;
  39835. private _engine;
  39836. private _scene;
  39837. /**
  39838. * Attach the input controls to a specific dom element to get the input from.
  39839. * @param element Defines the element the controls should be listened from
  39840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39841. */
  39842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39843. /**
  39844. * Detach the current controls from the specified dom element.
  39845. * @param element Defines the element to stop listening the inputs from
  39846. */
  39847. detachControl(element: Nullable<HTMLElement>): void;
  39848. /**
  39849. * Gets the class name of the current intput.
  39850. * @returns the class name
  39851. */
  39852. getClassName(): string;
  39853. /** @hidden */
  39854. _onLostFocus(e: FocusEvent): void;
  39855. /**
  39856. * Get the friendly name associated with the input class.
  39857. * @returns the input friendly name
  39858. */
  39859. getSimpleName(): string;
  39860. /**
  39861. * Update the current camera state depending on the inputs that have been used this frame.
  39862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39863. */
  39864. checkInputs(): void;
  39865. }
  39866. }
  39867. declare module BABYLON {
  39868. /**
  39869. * Manage the mouse wheel inputs to control a follow camera.
  39870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39871. */
  39872. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39873. /**
  39874. * Defines the camera the input is attached to.
  39875. */
  39876. camera: FollowCamera;
  39877. /**
  39878. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39879. */
  39880. axisControlRadius: boolean;
  39881. /**
  39882. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39883. */
  39884. axisControlHeight: boolean;
  39885. /**
  39886. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39887. */
  39888. axisControlRotation: boolean;
  39889. /**
  39890. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39891. * relation to mouseWheel events.
  39892. */
  39893. wheelPrecision: number;
  39894. /**
  39895. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39896. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39897. */
  39898. wheelDeltaPercentage: number;
  39899. private _wheel;
  39900. private _observer;
  39901. /**
  39902. * Attach the input controls to a specific dom element to get the input from.
  39903. * @param element Defines the element the controls should be listened from
  39904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39905. */
  39906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39907. /**
  39908. * Detach the current controls from the specified dom element.
  39909. * @param element Defines the element to stop listening the inputs from
  39910. */
  39911. detachControl(element: Nullable<HTMLElement>): void;
  39912. /**
  39913. * Gets the class name of the current intput.
  39914. * @returns the class name
  39915. */
  39916. getClassName(): string;
  39917. /**
  39918. * Get the friendly name associated with the input class.
  39919. * @returns the input friendly name
  39920. */
  39921. getSimpleName(): string;
  39922. }
  39923. }
  39924. declare module BABYLON {
  39925. /**
  39926. * Manage the pointers inputs to control an follow camera.
  39927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39928. */
  39929. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39930. /**
  39931. * Defines the camera the input is attached to.
  39932. */
  39933. camera: FollowCamera;
  39934. /**
  39935. * Gets the class name of the current input.
  39936. * @returns the class name
  39937. */
  39938. getClassName(): string;
  39939. /**
  39940. * Defines the pointer angular sensibility along the X axis or how fast is
  39941. * the camera rotating.
  39942. * A negative number will reverse the axis direction.
  39943. */
  39944. angularSensibilityX: number;
  39945. /**
  39946. * Defines the pointer angular sensibility along the Y axis or how fast is
  39947. * the camera rotating.
  39948. * A negative number will reverse the axis direction.
  39949. */
  39950. angularSensibilityY: number;
  39951. /**
  39952. * Defines the pointer pinch precision or how fast is the camera zooming.
  39953. * A negative number will reverse the axis direction.
  39954. */
  39955. pinchPrecision: number;
  39956. /**
  39957. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39958. * from 0.
  39959. * It defines the percentage of current camera.radius to use as delta when
  39960. * pinch zoom is used.
  39961. */
  39962. pinchDeltaPercentage: number;
  39963. /**
  39964. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39965. */
  39966. axisXControlRadius: boolean;
  39967. /**
  39968. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39969. */
  39970. axisXControlHeight: boolean;
  39971. /**
  39972. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39973. */
  39974. axisXControlRotation: boolean;
  39975. /**
  39976. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39977. */
  39978. axisYControlRadius: boolean;
  39979. /**
  39980. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39981. */
  39982. axisYControlHeight: boolean;
  39983. /**
  39984. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39985. */
  39986. axisYControlRotation: boolean;
  39987. /**
  39988. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39989. */
  39990. axisPinchControlRadius: boolean;
  39991. /**
  39992. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39993. */
  39994. axisPinchControlHeight: boolean;
  39995. /**
  39996. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39997. */
  39998. axisPinchControlRotation: boolean;
  39999. /**
  40000. * Log error messages if basic misconfiguration has occurred.
  40001. */
  40002. warningEnable: boolean;
  40003. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40004. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40005. private _warningCounter;
  40006. private _warning;
  40007. }
  40008. }
  40009. declare module BABYLON {
  40010. /**
  40011. * Default Inputs manager for the FollowCamera.
  40012. * It groups all the default supported inputs for ease of use.
  40013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40014. */
  40015. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40016. /**
  40017. * Instantiates a new FollowCameraInputsManager.
  40018. * @param camera Defines the camera the inputs belong to
  40019. */
  40020. constructor(camera: FollowCamera);
  40021. /**
  40022. * Add keyboard input support to the input manager.
  40023. * @returns the current input manager
  40024. */
  40025. addKeyboard(): FollowCameraInputsManager;
  40026. /**
  40027. * Add mouse wheel input support to the input manager.
  40028. * @returns the current input manager
  40029. */
  40030. addMouseWheel(): FollowCameraInputsManager;
  40031. /**
  40032. * Add pointers input support to the input manager.
  40033. * @returns the current input manager
  40034. */
  40035. addPointers(): FollowCameraInputsManager;
  40036. /**
  40037. * Add orientation input support to the input manager.
  40038. * @returns the current input manager
  40039. */
  40040. addVRDeviceOrientation(): FollowCameraInputsManager;
  40041. }
  40042. }
  40043. declare module BABYLON {
  40044. /**
  40045. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40046. * an arc rotate version arcFollowCamera are available.
  40047. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40048. */
  40049. export class FollowCamera extends TargetCamera {
  40050. /**
  40051. * Distance the follow camera should follow an object at
  40052. */
  40053. radius: number;
  40054. /**
  40055. * Minimum allowed distance of the camera to the axis of rotation
  40056. * (The camera can not get closer).
  40057. * This can help limiting how the Camera is able to move in the scene.
  40058. */
  40059. lowerRadiusLimit: Nullable<number>;
  40060. /**
  40061. * Maximum allowed distance of the camera to the axis of rotation
  40062. * (The camera can not get further).
  40063. * This can help limiting how the Camera is able to move in the scene.
  40064. */
  40065. upperRadiusLimit: Nullable<number>;
  40066. /**
  40067. * Define a rotation offset between the camera and the object it follows
  40068. */
  40069. rotationOffset: number;
  40070. /**
  40071. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  40075. /**
  40076. * Maximum allowed angle to camera position relative to target object.
  40077. * This can help limiting how the Camera is able to move in the scene.
  40078. */
  40079. upperRotationOffsetLimit: Nullable<number>;
  40080. /**
  40081. * Define a height offset between the camera and the object it follows.
  40082. * It can help following an object from the top (like a car chaing a plane)
  40083. */
  40084. heightOffset: number;
  40085. /**
  40086. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  40090. /**
  40091. * Maximum allowed height of camera position relative to target object.
  40092. * This can help limiting how the Camera is able to move in the scene.
  40093. */
  40094. upperHeightOffsetLimit: Nullable<number>;
  40095. /**
  40096. * Define how fast the camera can accelerate to follow it s target.
  40097. */
  40098. cameraAcceleration: number;
  40099. /**
  40100. * Define the speed limit of the camera following an object.
  40101. */
  40102. maxCameraSpeed: number;
  40103. /**
  40104. * Define the target of the camera.
  40105. */
  40106. lockedTarget: Nullable<AbstractMesh>;
  40107. /**
  40108. * Defines the input associated with the camera.
  40109. */
  40110. inputs: FollowCameraInputsManager;
  40111. /**
  40112. * Instantiates the follow camera.
  40113. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40114. * @param name Define the name of the camera in the scene
  40115. * @param position Define the position of the camera
  40116. * @param scene Define the scene the camera belong to
  40117. * @param lockedTarget Define the target of the camera
  40118. */
  40119. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40120. private _follow;
  40121. /**
  40122. * Attached controls to the current camera.
  40123. * @param element Defines the element the controls should be listened from
  40124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40125. */
  40126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40127. /**
  40128. * Detach the current controls from the camera.
  40129. * The camera will stop reacting to inputs.
  40130. * @param element Defines the element to stop listening the inputs from
  40131. */
  40132. detachControl(element: HTMLElement): void;
  40133. /** @hidden */
  40134. _checkInputs(): void;
  40135. private _checkLimits;
  40136. /**
  40137. * Gets the camera class name.
  40138. * @returns the class name
  40139. */
  40140. getClassName(): string;
  40141. }
  40142. /**
  40143. * Arc Rotate version of the follow camera.
  40144. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40145. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40146. */
  40147. export class ArcFollowCamera extends TargetCamera {
  40148. /** The longitudinal angle of the camera */
  40149. alpha: number;
  40150. /** The latitudinal angle of the camera */
  40151. beta: number;
  40152. /** The radius of the camera from its target */
  40153. radius: number;
  40154. /** Define the camera target (the messh it should follow) */
  40155. target: Nullable<AbstractMesh>;
  40156. private _cartesianCoordinates;
  40157. /**
  40158. * Instantiates a new ArcFollowCamera
  40159. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40160. * @param name Define the name of the camera
  40161. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40162. * @param beta Define the rotation angle of the camera around the elevation axis
  40163. * @param radius Define the radius of the camera from its target point
  40164. * @param target Define the target of the camera
  40165. * @param scene Define the scene the camera belongs to
  40166. */
  40167. constructor(name: string,
  40168. /** The longitudinal angle of the camera */
  40169. alpha: number,
  40170. /** The latitudinal angle of the camera */
  40171. beta: number,
  40172. /** The radius of the camera from its target */
  40173. radius: number,
  40174. /** Define the camera target (the messh it should follow) */
  40175. target: Nullable<AbstractMesh>, scene: Scene);
  40176. private _follow;
  40177. /** @hidden */
  40178. _checkInputs(): void;
  40179. /**
  40180. * Returns the class name of the object.
  40181. * It is mostly used internally for serialization purposes.
  40182. */
  40183. getClassName(): string;
  40184. }
  40185. }
  40186. declare module BABYLON {
  40187. /**
  40188. * Manage the keyboard inputs to control the movement of a follow camera.
  40189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40190. */
  40191. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40192. /**
  40193. * Defines the camera the input is attached to.
  40194. */
  40195. camera: FollowCamera;
  40196. /**
  40197. * Defines the list of key codes associated with the up action (increase heightOffset)
  40198. */
  40199. keysHeightOffsetIncr: number[];
  40200. /**
  40201. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40202. */
  40203. keysHeightOffsetDecr: number[];
  40204. /**
  40205. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40206. */
  40207. keysHeightOffsetModifierAlt: boolean;
  40208. /**
  40209. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40210. */
  40211. keysHeightOffsetModifierCtrl: boolean;
  40212. /**
  40213. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40214. */
  40215. keysHeightOffsetModifierShift: boolean;
  40216. /**
  40217. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40218. */
  40219. keysRotationOffsetIncr: number[];
  40220. /**
  40221. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40222. */
  40223. keysRotationOffsetDecr: number[];
  40224. /**
  40225. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40226. */
  40227. keysRotationOffsetModifierAlt: boolean;
  40228. /**
  40229. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40230. */
  40231. keysRotationOffsetModifierCtrl: boolean;
  40232. /**
  40233. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40234. */
  40235. keysRotationOffsetModifierShift: boolean;
  40236. /**
  40237. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40238. */
  40239. keysRadiusIncr: number[];
  40240. /**
  40241. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40242. */
  40243. keysRadiusDecr: number[];
  40244. /**
  40245. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40246. */
  40247. keysRadiusModifierAlt: boolean;
  40248. /**
  40249. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40250. */
  40251. keysRadiusModifierCtrl: boolean;
  40252. /**
  40253. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40254. */
  40255. keysRadiusModifierShift: boolean;
  40256. /**
  40257. * Defines the rate of change of heightOffset.
  40258. */
  40259. heightSensibility: number;
  40260. /**
  40261. * Defines the rate of change of rotationOffset.
  40262. */
  40263. rotationSensibility: number;
  40264. /**
  40265. * Defines the rate of change of radius.
  40266. */
  40267. radiusSensibility: number;
  40268. private _keys;
  40269. private _ctrlPressed;
  40270. private _altPressed;
  40271. private _shiftPressed;
  40272. private _onCanvasBlurObserver;
  40273. private _onKeyboardObserver;
  40274. private _engine;
  40275. private _scene;
  40276. /**
  40277. * Attach the input controls to a specific dom element to get the input from.
  40278. * @param element Defines the element the controls should be listened from
  40279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40280. */
  40281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40282. /**
  40283. * Detach the current controls from the specified dom element.
  40284. * @param element Defines the element to stop listening the inputs from
  40285. */
  40286. detachControl(element: Nullable<HTMLElement>): void;
  40287. /**
  40288. * Update the current camera state depending on the inputs that have been used this frame.
  40289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40290. */
  40291. checkInputs(): void;
  40292. /**
  40293. * Gets the class name of the current input.
  40294. * @returns the class name
  40295. */
  40296. getClassName(): string;
  40297. /**
  40298. * Get the friendly name associated with the input class.
  40299. * @returns the input friendly name
  40300. */
  40301. getSimpleName(): string;
  40302. /**
  40303. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40304. * allow modification of the heightOffset value.
  40305. */
  40306. private _modifierHeightOffset;
  40307. /**
  40308. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40309. * allow modification of the rotationOffset value.
  40310. */
  40311. private _modifierRotationOffset;
  40312. /**
  40313. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40314. * allow modification of the radius value.
  40315. */
  40316. private _modifierRadius;
  40317. }
  40318. }
  40319. declare module BABYLON {
  40320. interface FreeCameraInputsManager {
  40321. /**
  40322. * @hidden
  40323. */
  40324. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40325. /**
  40326. * Add orientation input support to the input manager.
  40327. * @returns the current input manager
  40328. */
  40329. addDeviceOrientation(): FreeCameraInputsManager;
  40330. }
  40331. /**
  40332. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40333. * Screen rotation is taken into account.
  40334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40335. */
  40336. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40337. private _camera;
  40338. private _screenOrientationAngle;
  40339. private _constantTranform;
  40340. private _screenQuaternion;
  40341. private _alpha;
  40342. private _beta;
  40343. private _gamma;
  40344. /**
  40345. * Can be used to detect if a device orientation sensor is available on a device
  40346. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40347. * @returns a promise that will resolve on orientation change
  40348. */
  40349. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40350. /**
  40351. * @hidden
  40352. */
  40353. _onDeviceOrientationChangedObservable: Observable<void>;
  40354. /**
  40355. * Instantiates a new input
  40356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40357. */
  40358. constructor();
  40359. /**
  40360. * Define the camera controlled by the input.
  40361. */
  40362. get camera(): FreeCamera;
  40363. set camera(camera: FreeCamera);
  40364. /**
  40365. * Attach the input controls to a specific dom element to get the input from.
  40366. * @param element Defines the element the controls should be listened from
  40367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40368. */
  40369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40370. private _orientationChanged;
  40371. private _deviceOrientation;
  40372. /**
  40373. * Detach the current controls from the specified dom element.
  40374. * @param element Defines the element to stop listening the inputs from
  40375. */
  40376. detachControl(element: Nullable<HTMLElement>): void;
  40377. /**
  40378. * Update the current camera state depending on the inputs that have been used this frame.
  40379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40380. */
  40381. checkInputs(): void;
  40382. /**
  40383. * Gets the class name of the current intput.
  40384. * @returns the class name
  40385. */
  40386. getClassName(): string;
  40387. /**
  40388. * Get the friendly name associated with the input class.
  40389. * @returns the input friendly name
  40390. */
  40391. getSimpleName(): string;
  40392. }
  40393. }
  40394. declare module BABYLON {
  40395. /**
  40396. * Manage the gamepad inputs to control a free camera.
  40397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40398. */
  40399. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40400. /**
  40401. * Define the camera the input is attached to.
  40402. */
  40403. camera: FreeCamera;
  40404. /**
  40405. * Define the Gamepad controlling the input
  40406. */
  40407. gamepad: Nullable<Gamepad>;
  40408. /**
  40409. * Defines the gamepad rotation sensiblity.
  40410. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40411. */
  40412. gamepadAngularSensibility: number;
  40413. /**
  40414. * Defines the gamepad move sensiblity.
  40415. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40416. */
  40417. gamepadMoveSensibility: number;
  40418. private _yAxisScale;
  40419. /**
  40420. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40421. */
  40422. get invertYAxis(): boolean;
  40423. set invertYAxis(value: boolean);
  40424. private _onGamepadConnectedObserver;
  40425. private _onGamepadDisconnectedObserver;
  40426. private _cameraTransform;
  40427. private _deltaTransform;
  40428. private _vector3;
  40429. private _vector2;
  40430. /**
  40431. * Attach the input controls to a specific dom element to get the input from.
  40432. * @param element Defines the element the controls should be listened from
  40433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40434. */
  40435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40436. /**
  40437. * Detach the current controls from the specified dom element.
  40438. * @param element Defines the element to stop listening the inputs from
  40439. */
  40440. detachControl(element: Nullable<HTMLElement>): void;
  40441. /**
  40442. * Update the current camera state depending on the inputs that have been used this frame.
  40443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40444. */
  40445. checkInputs(): void;
  40446. /**
  40447. * Gets the class name of the current intput.
  40448. * @returns the class name
  40449. */
  40450. getClassName(): string;
  40451. /**
  40452. * Get the friendly name associated with the input class.
  40453. * @returns the input friendly name
  40454. */
  40455. getSimpleName(): string;
  40456. }
  40457. }
  40458. declare module BABYLON {
  40459. /**
  40460. * Defines the potential axis of a Joystick
  40461. */
  40462. export enum JoystickAxis {
  40463. /** X axis */
  40464. X = 0,
  40465. /** Y axis */
  40466. Y = 1,
  40467. /** Z axis */
  40468. Z = 2
  40469. }
  40470. /**
  40471. * Class used to define virtual joystick (used in touch mode)
  40472. */
  40473. export class VirtualJoystick {
  40474. /**
  40475. * Gets or sets a boolean indicating that left and right values must be inverted
  40476. */
  40477. reverseLeftRight: boolean;
  40478. /**
  40479. * Gets or sets a boolean indicating that up and down values must be inverted
  40480. */
  40481. reverseUpDown: boolean;
  40482. /**
  40483. * Gets the offset value for the position (ie. the change of the position value)
  40484. */
  40485. deltaPosition: Vector3;
  40486. /**
  40487. * Gets a boolean indicating if the virtual joystick was pressed
  40488. */
  40489. pressed: boolean;
  40490. /**
  40491. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40492. */
  40493. static Canvas: Nullable<HTMLCanvasElement>;
  40494. private static _globalJoystickIndex;
  40495. private static vjCanvasContext;
  40496. private static vjCanvasWidth;
  40497. private static vjCanvasHeight;
  40498. private static halfWidth;
  40499. private _action;
  40500. private _axisTargetedByLeftAndRight;
  40501. private _axisTargetedByUpAndDown;
  40502. private _joystickSensibility;
  40503. private _inversedSensibility;
  40504. private _joystickPointerID;
  40505. private _joystickColor;
  40506. private _joystickPointerPos;
  40507. private _joystickPreviousPointerPos;
  40508. private _joystickPointerStartPos;
  40509. private _deltaJoystickVector;
  40510. private _leftJoystick;
  40511. private _touches;
  40512. private _onPointerDownHandlerRef;
  40513. private _onPointerMoveHandlerRef;
  40514. private _onPointerUpHandlerRef;
  40515. private _onResize;
  40516. /**
  40517. * Creates a new virtual joystick
  40518. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40519. */
  40520. constructor(leftJoystick?: boolean);
  40521. /**
  40522. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40523. * @param newJoystickSensibility defines the new sensibility
  40524. */
  40525. setJoystickSensibility(newJoystickSensibility: number): void;
  40526. private _onPointerDown;
  40527. private _onPointerMove;
  40528. private _onPointerUp;
  40529. /**
  40530. * Change the color of the virtual joystick
  40531. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40532. */
  40533. setJoystickColor(newColor: string): void;
  40534. /**
  40535. * Defines a callback to call when the joystick is touched
  40536. * @param action defines the callback
  40537. */
  40538. setActionOnTouch(action: () => any): void;
  40539. /**
  40540. * Defines which axis you'd like to control for left & right
  40541. * @param axis defines the axis to use
  40542. */
  40543. setAxisForLeftRight(axis: JoystickAxis): void;
  40544. /**
  40545. * Defines which axis you'd like to control for up & down
  40546. * @param axis defines the axis to use
  40547. */
  40548. setAxisForUpDown(axis: JoystickAxis): void;
  40549. private _drawVirtualJoystick;
  40550. /**
  40551. * Release internal HTML canvas
  40552. */
  40553. releaseCanvas(): void;
  40554. }
  40555. }
  40556. declare module BABYLON {
  40557. interface FreeCameraInputsManager {
  40558. /**
  40559. * Add virtual joystick input support to the input manager.
  40560. * @returns the current input manager
  40561. */
  40562. addVirtualJoystick(): FreeCameraInputsManager;
  40563. }
  40564. /**
  40565. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40567. */
  40568. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40569. /**
  40570. * Defines the camera the input is attached to.
  40571. */
  40572. camera: FreeCamera;
  40573. private _leftjoystick;
  40574. private _rightjoystick;
  40575. /**
  40576. * Gets the left stick of the virtual joystick.
  40577. * @returns The virtual Joystick
  40578. */
  40579. getLeftJoystick(): VirtualJoystick;
  40580. /**
  40581. * Gets the right stick of the virtual joystick.
  40582. * @returns The virtual Joystick
  40583. */
  40584. getRightJoystick(): VirtualJoystick;
  40585. /**
  40586. * Update the current camera state depending on the inputs that have been used this frame.
  40587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40588. */
  40589. checkInputs(): void;
  40590. /**
  40591. * Attach the input controls to a specific dom element to get the input from.
  40592. * @param element Defines the element the controls should be listened from
  40593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40594. */
  40595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40596. /**
  40597. * Detach the current controls from the specified dom element.
  40598. * @param element Defines the element to stop listening the inputs from
  40599. */
  40600. detachControl(element: Nullable<HTMLElement>): void;
  40601. /**
  40602. * Gets the class name of the current intput.
  40603. * @returns the class name
  40604. */
  40605. getClassName(): string;
  40606. /**
  40607. * Get the friendly name associated with the input class.
  40608. * @returns the input friendly name
  40609. */
  40610. getSimpleName(): string;
  40611. }
  40612. }
  40613. declare module BABYLON {
  40614. /**
  40615. * This represents a FPS type of camera controlled by touch.
  40616. * This is like a universal camera minus the Gamepad controls.
  40617. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40618. */
  40619. export class TouchCamera extends FreeCamera {
  40620. /**
  40621. * Defines the touch sensibility for rotation.
  40622. * The higher the faster.
  40623. */
  40624. get touchAngularSensibility(): number;
  40625. set touchAngularSensibility(value: number);
  40626. /**
  40627. * Defines the touch sensibility for move.
  40628. * The higher the faster.
  40629. */
  40630. get touchMoveSensibility(): number;
  40631. set touchMoveSensibility(value: number);
  40632. /**
  40633. * Instantiates a new touch camera.
  40634. * This represents a FPS type of camera controlled by touch.
  40635. * This is like a universal camera minus the Gamepad controls.
  40636. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40637. * @param name Define the name of the camera in the scene
  40638. * @param position Define the start position of the camera in the scene
  40639. * @param scene Define the scene the camera belongs to
  40640. */
  40641. constructor(name: string, position: Vector3, scene: Scene);
  40642. /**
  40643. * Gets the current object class name.
  40644. * @return the class name
  40645. */
  40646. getClassName(): string;
  40647. /** @hidden */
  40648. _setupInputs(): void;
  40649. }
  40650. }
  40651. declare module BABYLON {
  40652. /**
  40653. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40654. * being tilted forward or back and left or right.
  40655. */
  40656. export class DeviceOrientationCamera extends FreeCamera {
  40657. private _initialQuaternion;
  40658. private _quaternionCache;
  40659. private _tmpDragQuaternion;
  40660. private _disablePointerInputWhenUsingDeviceOrientation;
  40661. /**
  40662. * Creates a new device orientation camera
  40663. * @param name The name of the camera
  40664. * @param position The start position camera
  40665. * @param scene The scene the camera belongs to
  40666. */
  40667. constructor(name: string, position: Vector3, scene: Scene);
  40668. /**
  40669. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40670. */
  40671. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40672. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40673. private _dragFactor;
  40674. /**
  40675. * Enabled turning on the y axis when the orientation sensor is active
  40676. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40677. */
  40678. enableHorizontalDragging(dragFactor?: number): void;
  40679. /**
  40680. * Gets the current instance class name ("DeviceOrientationCamera").
  40681. * This helps avoiding instanceof at run time.
  40682. * @returns the class name
  40683. */
  40684. getClassName(): string;
  40685. /**
  40686. * @hidden
  40687. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40688. */
  40689. _checkInputs(): void;
  40690. /**
  40691. * Reset the camera to its default orientation on the specified axis only.
  40692. * @param axis The axis to reset
  40693. */
  40694. resetToCurrentRotation(axis?: Axis): void;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. /**
  40699. * Defines supported buttons for XBox360 compatible gamepads
  40700. */
  40701. export enum Xbox360Button {
  40702. /** A */
  40703. A = 0,
  40704. /** B */
  40705. B = 1,
  40706. /** X */
  40707. X = 2,
  40708. /** Y */
  40709. Y = 3,
  40710. /** Start */
  40711. Start = 4,
  40712. /** Back */
  40713. Back = 5,
  40714. /** Left button */
  40715. LB = 6,
  40716. /** Right button */
  40717. RB = 7,
  40718. /** Left stick */
  40719. LeftStick = 8,
  40720. /** Right stick */
  40721. RightStick = 9
  40722. }
  40723. /** Defines values for XBox360 DPad */
  40724. export enum Xbox360Dpad {
  40725. /** Up */
  40726. Up = 0,
  40727. /** Down */
  40728. Down = 1,
  40729. /** Left */
  40730. Left = 2,
  40731. /** Right */
  40732. Right = 3
  40733. }
  40734. /**
  40735. * Defines a XBox360 gamepad
  40736. */
  40737. export class Xbox360Pad extends Gamepad {
  40738. private _leftTrigger;
  40739. private _rightTrigger;
  40740. private _onlefttriggerchanged;
  40741. private _onrighttriggerchanged;
  40742. private _onbuttondown;
  40743. private _onbuttonup;
  40744. private _ondpaddown;
  40745. private _ondpadup;
  40746. /** Observable raised when a button is pressed */
  40747. onButtonDownObservable: Observable<Xbox360Button>;
  40748. /** Observable raised when a button is released */
  40749. onButtonUpObservable: Observable<Xbox360Button>;
  40750. /** Observable raised when a pad is pressed */
  40751. onPadDownObservable: Observable<Xbox360Dpad>;
  40752. /** Observable raised when a pad is released */
  40753. onPadUpObservable: Observable<Xbox360Dpad>;
  40754. private _buttonA;
  40755. private _buttonB;
  40756. private _buttonX;
  40757. private _buttonY;
  40758. private _buttonBack;
  40759. private _buttonStart;
  40760. private _buttonLB;
  40761. private _buttonRB;
  40762. private _buttonLeftStick;
  40763. private _buttonRightStick;
  40764. private _dPadUp;
  40765. private _dPadDown;
  40766. private _dPadLeft;
  40767. private _dPadRight;
  40768. private _isXboxOnePad;
  40769. /**
  40770. * Creates a new XBox360 gamepad object
  40771. * @param id defines the id of this gamepad
  40772. * @param index defines its index
  40773. * @param gamepad defines the internal HTML gamepad object
  40774. * @param xboxOne defines if it is a XBox One gamepad
  40775. */
  40776. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40777. /**
  40778. * Defines the callback to call when left trigger is pressed
  40779. * @param callback defines the callback to use
  40780. */
  40781. onlefttriggerchanged(callback: (value: number) => void): void;
  40782. /**
  40783. * Defines the callback to call when right trigger is pressed
  40784. * @param callback defines the callback to use
  40785. */
  40786. onrighttriggerchanged(callback: (value: number) => void): void;
  40787. /**
  40788. * Gets the left trigger value
  40789. */
  40790. get leftTrigger(): number;
  40791. /**
  40792. * Sets the left trigger value
  40793. */
  40794. set leftTrigger(newValue: number);
  40795. /**
  40796. * Gets the right trigger value
  40797. */
  40798. get rightTrigger(): number;
  40799. /**
  40800. * Sets the right trigger value
  40801. */
  40802. set rightTrigger(newValue: number);
  40803. /**
  40804. * Defines the callback to call when a button is pressed
  40805. * @param callback defines the callback to use
  40806. */
  40807. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40808. /**
  40809. * Defines the callback to call when a button is released
  40810. * @param callback defines the callback to use
  40811. */
  40812. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40813. /**
  40814. * Defines the callback to call when a pad is pressed
  40815. * @param callback defines the callback to use
  40816. */
  40817. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40818. /**
  40819. * Defines the callback to call when a pad is released
  40820. * @param callback defines the callback to use
  40821. */
  40822. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40823. private _setButtonValue;
  40824. private _setDPadValue;
  40825. /**
  40826. * Gets the value of the `A` button
  40827. */
  40828. get buttonA(): number;
  40829. /**
  40830. * Sets the value of the `A` button
  40831. */
  40832. set buttonA(value: number);
  40833. /**
  40834. * Gets the value of the `B` button
  40835. */
  40836. get buttonB(): number;
  40837. /**
  40838. * Sets the value of the `B` button
  40839. */
  40840. set buttonB(value: number);
  40841. /**
  40842. * Gets the value of the `X` button
  40843. */
  40844. get buttonX(): number;
  40845. /**
  40846. * Sets the value of the `X` button
  40847. */
  40848. set buttonX(value: number);
  40849. /**
  40850. * Gets the value of the `Y` button
  40851. */
  40852. get buttonY(): number;
  40853. /**
  40854. * Sets the value of the `Y` button
  40855. */
  40856. set buttonY(value: number);
  40857. /**
  40858. * Gets the value of the `Start` button
  40859. */
  40860. get buttonStart(): number;
  40861. /**
  40862. * Sets the value of the `Start` button
  40863. */
  40864. set buttonStart(value: number);
  40865. /**
  40866. * Gets the value of the `Back` button
  40867. */
  40868. get buttonBack(): number;
  40869. /**
  40870. * Sets the value of the `Back` button
  40871. */
  40872. set buttonBack(value: number);
  40873. /**
  40874. * Gets the value of the `Left` button
  40875. */
  40876. get buttonLB(): number;
  40877. /**
  40878. * Sets the value of the `Left` button
  40879. */
  40880. set buttonLB(value: number);
  40881. /**
  40882. * Gets the value of the `Right` button
  40883. */
  40884. get buttonRB(): number;
  40885. /**
  40886. * Sets the value of the `Right` button
  40887. */
  40888. set buttonRB(value: number);
  40889. /**
  40890. * Gets the value of the Left joystick
  40891. */
  40892. get buttonLeftStick(): number;
  40893. /**
  40894. * Sets the value of the Left joystick
  40895. */
  40896. set buttonLeftStick(value: number);
  40897. /**
  40898. * Gets the value of the Right joystick
  40899. */
  40900. get buttonRightStick(): number;
  40901. /**
  40902. * Sets the value of the Right joystick
  40903. */
  40904. set buttonRightStick(value: number);
  40905. /**
  40906. * Gets the value of D-pad up
  40907. */
  40908. get dPadUp(): number;
  40909. /**
  40910. * Sets the value of D-pad up
  40911. */
  40912. set dPadUp(value: number);
  40913. /**
  40914. * Gets the value of D-pad down
  40915. */
  40916. get dPadDown(): number;
  40917. /**
  40918. * Sets the value of D-pad down
  40919. */
  40920. set dPadDown(value: number);
  40921. /**
  40922. * Gets the value of D-pad left
  40923. */
  40924. get dPadLeft(): number;
  40925. /**
  40926. * Sets the value of D-pad left
  40927. */
  40928. set dPadLeft(value: number);
  40929. /**
  40930. * Gets the value of D-pad right
  40931. */
  40932. get dPadRight(): number;
  40933. /**
  40934. * Sets the value of D-pad right
  40935. */
  40936. set dPadRight(value: number);
  40937. /**
  40938. * Force the gamepad to synchronize with device values
  40939. */
  40940. update(): void;
  40941. /**
  40942. * Disposes the gamepad
  40943. */
  40944. dispose(): void;
  40945. }
  40946. }
  40947. declare module BABYLON {
  40948. /**
  40949. * Defines supported buttons for DualShock compatible gamepads
  40950. */
  40951. export enum DualShockButton {
  40952. /** Cross */
  40953. Cross = 0,
  40954. /** Circle */
  40955. Circle = 1,
  40956. /** Square */
  40957. Square = 2,
  40958. /** Triangle */
  40959. Triangle = 3,
  40960. /** Options */
  40961. Options = 4,
  40962. /** Share */
  40963. Share = 5,
  40964. /** L1 */
  40965. L1 = 6,
  40966. /** R1 */
  40967. R1 = 7,
  40968. /** Left stick */
  40969. LeftStick = 8,
  40970. /** Right stick */
  40971. RightStick = 9
  40972. }
  40973. /** Defines values for DualShock DPad */
  40974. export enum DualShockDpad {
  40975. /** Up */
  40976. Up = 0,
  40977. /** Down */
  40978. Down = 1,
  40979. /** Left */
  40980. Left = 2,
  40981. /** Right */
  40982. Right = 3
  40983. }
  40984. /**
  40985. * Defines a DualShock gamepad
  40986. */
  40987. export class DualShockPad extends Gamepad {
  40988. private _leftTrigger;
  40989. private _rightTrigger;
  40990. private _onlefttriggerchanged;
  40991. private _onrighttriggerchanged;
  40992. private _onbuttondown;
  40993. private _onbuttonup;
  40994. private _ondpaddown;
  40995. private _ondpadup;
  40996. /** Observable raised when a button is pressed */
  40997. onButtonDownObservable: Observable<DualShockButton>;
  40998. /** Observable raised when a button is released */
  40999. onButtonUpObservable: Observable<DualShockButton>;
  41000. /** Observable raised when a pad is pressed */
  41001. onPadDownObservable: Observable<DualShockDpad>;
  41002. /** Observable raised when a pad is released */
  41003. onPadUpObservable: Observable<DualShockDpad>;
  41004. private _buttonCross;
  41005. private _buttonCircle;
  41006. private _buttonSquare;
  41007. private _buttonTriangle;
  41008. private _buttonShare;
  41009. private _buttonOptions;
  41010. private _buttonL1;
  41011. private _buttonR1;
  41012. private _buttonLeftStick;
  41013. private _buttonRightStick;
  41014. private _dPadUp;
  41015. private _dPadDown;
  41016. private _dPadLeft;
  41017. private _dPadRight;
  41018. /**
  41019. * Creates a new DualShock gamepad object
  41020. * @param id defines the id of this gamepad
  41021. * @param index defines its index
  41022. * @param gamepad defines the internal HTML gamepad object
  41023. */
  41024. constructor(id: string, index: number, gamepad: any);
  41025. /**
  41026. * Defines the callback to call when left trigger is pressed
  41027. * @param callback defines the callback to use
  41028. */
  41029. onlefttriggerchanged(callback: (value: number) => void): void;
  41030. /**
  41031. * Defines the callback to call when right trigger is pressed
  41032. * @param callback defines the callback to use
  41033. */
  41034. onrighttriggerchanged(callback: (value: number) => void): void;
  41035. /**
  41036. * Gets the left trigger value
  41037. */
  41038. get leftTrigger(): number;
  41039. /**
  41040. * Sets the left trigger value
  41041. */
  41042. set leftTrigger(newValue: number);
  41043. /**
  41044. * Gets the right trigger value
  41045. */
  41046. get rightTrigger(): number;
  41047. /**
  41048. * Sets the right trigger value
  41049. */
  41050. set rightTrigger(newValue: number);
  41051. /**
  41052. * Defines the callback to call when a button is pressed
  41053. * @param callback defines the callback to use
  41054. */
  41055. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41056. /**
  41057. * Defines the callback to call when a button is released
  41058. * @param callback defines the callback to use
  41059. */
  41060. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41061. /**
  41062. * Defines the callback to call when a pad is pressed
  41063. * @param callback defines the callback to use
  41064. */
  41065. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41066. /**
  41067. * Defines the callback to call when a pad is released
  41068. * @param callback defines the callback to use
  41069. */
  41070. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41071. private _setButtonValue;
  41072. private _setDPadValue;
  41073. /**
  41074. * Gets the value of the `Cross` button
  41075. */
  41076. get buttonCross(): number;
  41077. /**
  41078. * Sets the value of the `Cross` button
  41079. */
  41080. set buttonCross(value: number);
  41081. /**
  41082. * Gets the value of the `Circle` button
  41083. */
  41084. get buttonCircle(): number;
  41085. /**
  41086. * Sets the value of the `Circle` button
  41087. */
  41088. set buttonCircle(value: number);
  41089. /**
  41090. * Gets the value of the `Square` button
  41091. */
  41092. get buttonSquare(): number;
  41093. /**
  41094. * Sets the value of the `Square` button
  41095. */
  41096. set buttonSquare(value: number);
  41097. /**
  41098. * Gets the value of the `Triangle` button
  41099. */
  41100. get buttonTriangle(): number;
  41101. /**
  41102. * Sets the value of the `Triangle` button
  41103. */
  41104. set buttonTriangle(value: number);
  41105. /**
  41106. * Gets the value of the `Options` button
  41107. */
  41108. get buttonOptions(): number;
  41109. /**
  41110. * Sets the value of the `Options` button
  41111. */
  41112. set buttonOptions(value: number);
  41113. /**
  41114. * Gets the value of the `Share` button
  41115. */
  41116. get buttonShare(): number;
  41117. /**
  41118. * Sets the value of the `Share` button
  41119. */
  41120. set buttonShare(value: number);
  41121. /**
  41122. * Gets the value of the `L1` button
  41123. */
  41124. get buttonL1(): number;
  41125. /**
  41126. * Sets the value of the `L1` button
  41127. */
  41128. set buttonL1(value: number);
  41129. /**
  41130. * Gets the value of the `R1` button
  41131. */
  41132. get buttonR1(): number;
  41133. /**
  41134. * Sets the value of the `R1` button
  41135. */
  41136. set buttonR1(value: number);
  41137. /**
  41138. * Gets the value of the Left joystick
  41139. */
  41140. get buttonLeftStick(): number;
  41141. /**
  41142. * Sets the value of the Left joystick
  41143. */
  41144. set buttonLeftStick(value: number);
  41145. /**
  41146. * Gets the value of the Right joystick
  41147. */
  41148. get buttonRightStick(): number;
  41149. /**
  41150. * Sets the value of the Right joystick
  41151. */
  41152. set buttonRightStick(value: number);
  41153. /**
  41154. * Gets the value of D-pad up
  41155. */
  41156. get dPadUp(): number;
  41157. /**
  41158. * Sets the value of D-pad up
  41159. */
  41160. set dPadUp(value: number);
  41161. /**
  41162. * Gets the value of D-pad down
  41163. */
  41164. get dPadDown(): number;
  41165. /**
  41166. * Sets the value of D-pad down
  41167. */
  41168. set dPadDown(value: number);
  41169. /**
  41170. * Gets the value of D-pad left
  41171. */
  41172. get dPadLeft(): number;
  41173. /**
  41174. * Sets the value of D-pad left
  41175. */
  41176. set dPadLeft(value: number);
  41177. /**
  41178. * Gets the value of D-pad right
  41179. */
  41180. get dPadRight(): number;
  41181. /**
  41182. * Sets the value of D-pad right
  41183. */
  41184. set dPadRight(value: number);
  41185. /**
  41186. * Force the gamepad to synchronize with device values
  41187. */
  41188. update(): void;
  41189. /**
  41190. * Disposes the gamepad
  41191. */
  41192. dispose(): void;
  41193. }
  41194. }
  41195. declare module BABYLON {
  41196. /**
  41197. * Manager for handling gamepads
  41198. */
  41199. export class GamepadManager {
  41200. private _scene?;
  41201. private _babylonGamepads;
  41202. private _oneGamepadConnected;
  41203. /** @hidden */
  41204. _isMonitoring: boolean;
  41205. private _gamepadEventSupported;
  41206. private _gamepadSupport?;
  41207. /**
  41208. * observable to be triggered when the gamepad controller has been connected
  41209. */
  41210. onGamepadConnectedObservable: Observable<Gamepad>;
  41211. /**
  41212. * observable to be triggered when the gamepad controller has been disconnected
  41213. */
  41214. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41215. private _onGamepadConnectedEvent;
  41216. private _onGamepadDisconnectedEvent;
  41217. /**
  41218. * Initializes the gamepad manager
  41219. * @param _scene BabylonJS scene
  41220. */
  41221. constructor(_scene?: Scene | undefined);
  41222. /**
  41223. * The gamepads in the game pad manager
  41224. */
  41225. get gamepads(): Gamepad[];
  41226. /**
  41227. * Get the gamepad controllers based on type
  41228. * @param type The type of gamepad controller
  41229. * @returns Nullable gamepad
  41230. */
  41231. getGamepadByType(type?: number): Nullable<Gamepad>;
  41232. /**
  41233. * Disposes the gamepad manager
  41234. */
  41235. dispose(): void;
  41236. private _addNewGamepad;
  41237. private _startMonitoringGamepads;
  41238. private _stopMonitoringGamepads;
  41239. /** @hidden */
  41240. _checkGamepadsStatus(): void;
  41241. private _updateGamepadObjects;
  41242. }
  41243. }
  41244. declare module BABYLON {
  41245. interface Scene {
  41246. /** @hidden */
  41247. _gamepadManager: Nullable<GamepadManager>;
  41248. /**
  41249. * Gets the gamepad manager associated with the scene
  41250. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41251. */
  41252. gamepadManager: GamepadManager;
  41253. }
  41254. /**
  41255. * Interface representing a free camera inputs manager
  41256. */
  41257. interface FreeCameraInputsManager {
  41258. /**
  41259. * Adds gamepad input support to the FreeCameraInputsManager.
  41260. * @returns the FreeCameraInputsManager
  41261. */
  41262. addGamepad(): FreeCameraInputsManager;
  41263. }
  41264. /**
  41265. * Interface representing an arc rotate camera inputs manager
  41266. */
  41267. interface ArcRotateCameraInputsManager {
  41268. /**
  41269. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41270. * @returns the camera inputs manager
  41271. */
  41272. addGamepad(): ArcRotateCameraInputsManager;
  41273. }
  41274. /**
  41275. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41276. */
  41277. export class GamepadSystemSceneComponent implements ISceneComponent {
  41278. /**
  41279. * The component name helpfull to identify the component in the list of scene components.
  41280. */
  41281. readonly name: string;
  41282. /**
  41283. * The scene the component belongs to.
  41284. */
  41285. scene: Scene;
  41286. /**
  41287. * Creates a new instance of the component for the given scene
  41288. * @param scene Defines the scene to register the component in
  41289. */
  41290. constructor(scene: Scene);
  41291. /**
  41292. * Registers the component in a given scene
  41293. */
  41294. register(): void;
  41295. /**
  41296. * Rebuilds the elements related to this component in case of
  41297. * context lost for instance.
  41298. */
  41299. rebuild(): void;
  41300. /**
  41301. * Disposes the component and the associated ressources
  41302. */
  41303. dispose(): void;
  41304. private _beforeCameraUpdate;
  41305. }
  41306. }
  41307. declare module BABYLON {
  41308. /**
  41309. * 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,
  41310. * which still works and will still be found in many Playgrounds.
  41311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41312. */
  41313. export class UniversalCamera extends TouchCamera {
  41314. /**
  41315. * Defines the gamepad rotation sensiblity.
  41316. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41317. */
  41318. get gamepadAngularSensibility(): number;
  41319. set gamepadAngularSensibility(value: number);
  41320. /**
  41321. * Defines the gamepad move sensiblity.
  41322. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41323. */
  41324. get gamepadMoveSensibility(): number;
  41325. set gamepadMoveSensibility(value: number);
  41326. /**
  41327. * 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,
  41328. * which still works and will still be found in many Playgrounds.
  41329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41330. * @param name Define the name of the camera in the scene
  41331. * @param position Define the start position of the camera in the scene
  41332. * @param scene Define the scene the camera belongs to
  41333. */
  41334. constructor(name: string, position: Vector3, scene: Scene);
  41335. /**
  41336. * Gets the current object class name.
  41337. * @return the class name
  41338. */
  41339. getClassName(): string;
  41340. }
  41341. }
  41342. declare module BABYLON {
  41343. /**
  41344. * This represents a FPS type of camera. This is only here for back compat purpose.
  41345. * Please use the UniversalCamera instead as both are identical.
  41346. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41347. */
  41348. export class GamepadCamera extends UniversalCamera {
  41349. /**
  41350. * Instantiates a new Gamepad Camera
  41351. * This represents a FPS type of camera. This is only here for back compat purpose.
  41352. * Please use the UniversalCamera instead as both are identical.
  41353. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41354. * @param name Define the name of the camera in the scene
  41355. * @param position Define the start position of the camera in the scene
  41356. * @param scene Define the scene the camera belongs to
  41357. */
  41358. constructor(name: string, position: Vector3, scene: Scene);
  41359. /**
  41360. * Gets the current object class name.
  41361. * @return the class name
  41362. */
  41363. getClassName(): string;
  41364. }
  41365. }
  41366. declare module BABYLON {
  41367. /** @hidden */
  41368. export var passPixelShader: {
  41369. name: string;
  41370. shader: string;
  41371. };
  41372. }
  41373. declare module BABYLON {
  41374. /** @hidden */
  41375. export var passCubePixelShader: {
  41376. name: string;
  41377. shader: string;
  41378. };
  41379. }
  41380. declare module BABYLON {
  41381. /**
  41382. * PassPostProcess which produces an output the same as it's input
  41383. */
  41384. export class PassPostProcess extends PostProcess {
  41385. /**
  41386. * Creates the PassPostProcess
  41387. * @param name The name of the effect.
  41388. * @param options The required width/height ratio to downsize to before computing the render pass.
  41389. * @param camera The camera to apply the render pass to.
  41390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41391. * @param engine The engine which the post process will be applied. (default: current engine)
  41392. * @param reusable If the post process can be reused on the same frame. (default: false)
  41393. * @param textureType The type of texture to be used when performing the post processing.
  41394. * @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)
  41395. */
  41396. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41397. }
  41398. /**
  41399. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41400. */
  41401. export class PassCubePostProcess extends PostProcess {
  41402. private _face;
  41403. /**
  41404. * Gets or sets the cube face to display.
  41405. * * 0 is +X
  41406. * * 1 is -X
  41407. * * 2 is +Y
  41408. * * 3 is -Y
  41409. * * 4 is +Z
  41410. * * 5 is -Z
  41411. */
  41412. get face(): number;
  41413. set face(value: number);
  41414. /**
  41415. * Creates the PassCubePostProcess
  41416. * @param name The name of the effect.
  41417. * @param options The required width/height ratio to downsize to before computing the render pass.
  41418. * @param camera The camera to apply the render pass to.
  41419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41420. * @param engine The engine which the post process will be applied. (default: current engine)
  41421. * @param reusable If the post process can be reused on the same frame. (default: false)
  41422. * @param textureType The type of texture to be used when performing the post processing.
  41423. * @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)
  41424. */
  41425. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /** @hidden */
  41430. export var anaglyphPixelShader: {
  41431. name: string;
  41432. shader: string;
  41433. };
  41434. }
  41435. declare module BABYLON {
  41436. /**
  41437. * Postprocess used to generate anaglyphic rendering
  41438. */
  41439. export class AnaglyphPostProcess extends PostProcess {
  41440. private _passedProcess;
  41441. /**
  41442. * Creates a new AnaglyphPostProcess
  41443. * @param name defines postprocess name
  41444. * @param options defines creation options or target ratio scale
  41445. * @param rigCameras defines cameras using this postprocess
  41446. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41447. * @param engine defines hosting engine
  41448. * @param reusable defines if the postprocess will be reused multiple times per frame
  41449. */
  41450. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41451. }
  41452. }
  41453. declare module BABYLON {
  41454. /**
  41455. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41456. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41457. */
  41458. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41459. /**
  41460. * Creates a new AnaglyphArcRotateCamera
  41461. * @param name defines camera name
  41462. * @param alpha defines alpha angle (in radians)
  41463. * @param beta defines beta angle (in radians)
  41464. * @param radius defines radius
  41465. * @param target defines camera target
  41466. * @param interaxialDistance defines distance between each color axis
  41467. * @param scene defines the hosting scene
  41468. */
  41469. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41470. /**
  41471. * Gets camera class name
  41472. * @returns AnaglyphArcRotateCamera
  41473. */
  41474. getClassName(): string;
  41475. }
  41476. }
  41477. declare module BABYLON {
  41478. /**
  41479. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41480. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41481. */
  41482. export class AnaglyphFreeCamera extends FreeCamera {
  41483. /**
  41484. * Creates a new AnaglyphFreeCamera
  41485. * @param name defines camera name
  41486. * @param position defines initial position
  41487. * @param interaxialDistance defines distance between each color axis
  41488. * @param scene defines the hosting scene
  41489. */
  41490. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41491. /**
  41492. * Gets camera class name
  41493. * @returns AnaglyphFreeCamera
  41494. */
  41495. getClassName(): string;
  41496. }
  41497. }
  41498. declare module BABYLON {
  41499. /**
  41500. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41501. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41502. */
  41503. export class AnaglyphGamepadCamera extends GamepadCamera {
  41504. /**
  41505. * Creates a new AnaglyphGamepadCamera
  41506. * @param name defines camera name
  41507. * @param position defines initial position
  41508. * @param interaxialDistance defines distance between each color axis
  41509. * @param scene defines the hosting scene
  41510. */
  41511. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41512. /**
  41513. * Gets camera class name
  41514. * @returns AnaglyphGamepadCamera
  41515. */
  41516. getClassName(): string;
  41517. }
  41518. }
  41519. declare module BABYLON {
  41520. /**
  41521. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41522. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41523. */
  41524. export class AnaglyphUniversalCamera extends UniversalCamera {
  41525. /**
  41526. * Creates a new AnaglyphUniversalCamera
  41527. * @param name defines camera name
  41528. * @param position defines initial position
  41529. * @param interaxialDistance defines distance between each color axis
  41530. * @param scene defines the hosting scene
  41531. */
  41532. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41533. /**
  41534. * Gets camera class name
  41535. * @returns AnaglyphUniversalCamera
  41536. */
  41537. getClassName(): string;
  41538. }
  41539. }
  41540. declare module BABYLON {
  41541. /** @hidden */
  41542. export var stereoscopicInterlacePixelShader: {
  41543. name: string;
  41544. shader: string;
  41545. };
  41546. }
  41547. declare module BABYLON {
  41548. /**
  41549. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41550. */
  41551. export class StereoscopicInterlacePostProcess extends PostProcess {
  41552. private _stepSize;
  41553. private _passedProcess;
  41554. /**
  41555. * Initializes a StereoscopicInterlacePostProcess
  41556. * @param name The name of the effect.
  41557. * @param rigCameras The rig cameras to be appled to the post process
  41558. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41560. * @param engine The engine which the post process will be applied. (default: current engine)
  41561. * @param reusable If the post process can be reused on the same frame. (default: false)
  41562. */
  41563. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41569. * @see http://doc.babylonjs.com/features/cameras
  41570. */
  41571. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41572. /**
  41573. * Creates a new StereoscopicArcRotateCamera
  41574. * @param name defines camera name
  41575. * @param alpha defines alpha angle (in radians)
  41576. * @param beta defines beta angle (in radians)
  41577. * @param radius defines radius
  41578. * @param target defines camera target
  41579. * @param interaxialDistance defines distance between each color axis
  41580. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41581. * @param scene defines the hosting scene
  41582. */
  41583. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41584. /**
  41585. * Gets camera class name
  41586. * @returns StereoscopicArcRotateCamera
  41587. */
  41588. getClassName(): string;
  41589. }
  41590. }
  41591. declare module BABYLON {
  41592. /**
  41593. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41594. * @see http://doc.babylonjs.com/features/cameras
  41595. */
  41596. export class StereoscopicFreeCamera extends FreeCamera {
  41597. /**
  41598. * Creates a new StereoscopicFreeCamera
  41599. * @param name defines camera name
  41600. * @param position defines initial position
  41601. * @param interaxialDistance defines distance between each color axis
  41602. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41603. * @param scene defines the hosting scene
  41604. */
  41605. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41606. /**
  41607. * Gets camera class name
  41608. * @returns StereoscopicFreeCamera
  41609. */
  41610. getClassName(): string;
  41611. }
  41612. }
  41613. declare module BABYLON {
  41614. /**
  41615. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41616. * @see http://doc.babylonjs.com/features/cameras
  41617. */
  41618. export class StereoscopicGamepadCamera extends GamepadCamera {
  41619. /**
  41620. * Creates a new StereoscopicGamepadCamera
  41621. * @param name defines camera name
  41622. * @param position defines initial position
  41623. * @param interaxialDistance defines distance between each color axis
  41624. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41625. * @param scene defines the hosting scene
  41626. */
  41627. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41628. /**
  41629. * Gets camera class name
  41630. * @returns StereoscopicGamepadCamera
  41631. */
  41632. getClassName(): string;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /**
  41637. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41638. * @see http://doc.babylonjs.com/features/cameras
  41639. */
  41640. export class StereoscopicUniversalCamera extends UniversalCamera {
  41641. /**
  41642. * Creates a new StereoscopicUniversalCamera
  41643. * @param name defines camera name
  41644. * @param position defines initial position
  41645. * @param interaxialDistance defines distance between each color axis
  41646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41647. * @param scene defines the hosting scene
  41648. */
  41649. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41650. /**
  41651. * Gets camera class name
  41652. * @returns StereoscopicUniversalCamera
  41653. */
  41654. getClassName(): string;
  41655. }
  41656. }
  41657. declare module BABYLON {
  41658. /**
  41659. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41660. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41661. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41662. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41663. */
  41664. export class VirtualJoysticksCamera extends FreeCamera {
  41665. /**
  41666. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41667. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41668. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41669. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41670. * @param name Define the name of the camera in the scene
  41671. * @param position Define the start position of the camera in the scene
  41672. * @param scene Define the scene the camera belongs to
  41673. */
  41674. constructor(name: string, position: Vector3, scene: Scene);
  41675. /**
  41676. * Gets the current object class name.
  41677. * @return the class name
  41678. */
  41679. getClassName(): string;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * This represents all the required metrics to create a VR camera.
  41685. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41686. */
  41687. export class VRCameraMetrics {
  41688. /**
  41689. * Define the horizontal resolution off the screen.
  41690. */
  41691. hResolution: number;
  41692. /**
  41693. * Define the vertical resolution off the screen.
  41694. */
  41695. vResolution: number;
  41696. /**
  41697. * Define the horizontal screen size.
  41698. */
  41699. hScreenSize: number;
  41700. /**
  41701. * Define the vertical screen size.
  41702. */
  41703. vScreenSize: number;
  41704. /**
  41705. * Define the vertical screen center position.
  41706. */
  41707. vScreenCenter: number;
  41708. /**
  41709. * Define the distance of the eyes to the screen.
  41710. */
  41711. eyeToScreenDistance: number;
  41712. /**
  41713. * Define the distance between both lenses
  41714. */
  41715. lensSeparationDistance: number;
  41716. /**
  41717. * Define the distance between both viewer's eyes.
  41718. */
  41719. interpupillaryDistance: number;
  41720. /**
  41721. * Define the distortion factor of the VR postprocess.
  41722. * Please, touch with care.
  41723. */
  41724. distortionK: number[];
  41725. /**
  41726. * Define the chromatic aberration correction factors for the VR post process.
  41727. */
  41728. chromaAbCorrection: number[];
  41729. /**
  41730. * Define the scale factor of the post process.
  41731. * The smaller the better but the slower.
  41732. */
  41733. postProcessScaleFactor: number;
  41734. /**
  41735. * Define an offset for the lens center.
  41736. */
  41737. lensCenterOffset: number;
  41738. /**
  41739. * Define if the current vr camera should compensate the distortion of the lense or not.
  41740. */
  41741. compensateDistortion: boolean;
  41742. /**
  41743. * Defines if multiview should be enabled when rendering (Default: false)
  41744. */
  41745. multiviewEnabled: boolean;
  41746. /**
  41747. * Gets the rendering aspect ratio based on the provided resolutions.
  41748. */
  41749. get aspectRatio(): number;
  41750. /**
  41751. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41752. */
  41753. get aspectRatioFov(): number;
  41754. /**
  41755. * @hidden
  41756. */
  41757. get leftHMatrix(): Matrix;
  41758. /**
  41759. * @hidden
  41760. */
  41761. get rightHMatrix(): Matrix;
  41762. /**
  41763. * @hidden
  41764. */
  41765. get leftPreViewMatrix(): Matrix;
  41766. /**
  41767. * @hidden
  41768. */
  41769. get rightPreViewMatrix(): Matrix;
  41770. /**
  41771. * Get the default VRMetrics based on the most generic setup.
  41772. * @returns the default vr metrics
  41773. */
  41774. static GetDefault(): VRCameraMetrics;
  41775. }
  41776. }
  41777. declare module BABYLON {
  41778. /** @hidden */
  41779. export var vrDistortionCorrectionPixelShader: {
  41780. name: string;
  41781. shader: string;
  41782. };
  41783. }
  41784. declare module BABYLON {
  41785. /**
  41786. * VRDistortionCorrectionPostProcess used for mobile VR
  41787. */
  41788. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41789. private _isRightEye;
  41790. private _distortionFactors;
  41791. private _postProcessScaleFactor;
  41792. private _lensCenterOffset;
  41793. private _scaleIn;
  41794. private _scaleFactor;
  41795. private _lensCenter;
  41796. /**
  41797. * Initializes the VRDistortionCorrectionPostProcess
  41798. * @param name The name of the effect.
  41799. * @param camera The camera to apply the render pass to.
  41800. * @param isRightEye If this is for the right eye distortion
  41801. * @param vrMetrics All the required metrics for the VR camera
  41802. */
  41803. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41804. }
  41805. }
  41806. declare module BABYLON {
  41807. /**
  41808. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41809. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41810. */
  41811. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41812. /**
  41813. * Creates a new VRDeviceOrientationArcRotateCamera
  41814. * @param name defines camera name
  41815. * @param alpha defines the camera rotation along the logitudinal axis
  41816. * @param beta defines the camera rotation along the latitudinal axis
  41817. * @param radius defines the camera distance from its target
  41818. * @param target defines the camera target
  41819. * @param scene defines the scene the camera belongs to
  41820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41822. */
  41823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41824. /**
  41825. * Gets camera class name
  41826. * @returns VRDeviceOrientationArcRotateCamera
  41827. */
  41828. getClassName(): string;
  41829. }
  41830. }
  41831. declare module BABYLON {
  41832. /**
  41833. * Camera used to simulate VR rendering (based on FreeCamera)
  41834. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41835. */
  41836. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41837. /**
  41838. * Creates a new VRDeviceOrientationFreeCamera
  41839. * @param name defines camera name
  41840. * @param position defines the start position of the camera
  41841. * @param scene defines the scene the camera belongs to
  41842. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41843. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41844. */
  41845. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41846. /**
  41847. * Gets camera class name
  41848. * @returns VRDeviceOrientationFreeCamera
  41849. */
  41850. getClassName(): string;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41856. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41857. */
  41858. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41859. /**
  41860. * Creates a new VRDeviceOrientationGamepadCamera
  41861. * @param name defines camera name
  41862. * @param position defines the start position of the camera
  41863. * @param scene defines the scene the camera belongs to
  41864. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41865. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41866. */
  41867. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41868. /**
  41869. * Gets camera class name
  41870. * @returns VRDeviceOrientationGamepadCamera
  41871. */
  41872. getClassName(): string;
  41873. }
  41874. }
  41875. declare module BABYLON {
  41876. /** @hidden */
  41877. export var imageProcessingPixelShader: {
  41878. name: string;
  41879. shader: string;
  41880. };
  41881. }
  41882. declare module BABYLON {
  41883. /**
  41884. * ImageProcessingPostProcess
  41885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41886. */
  41887. export class ImageProcessingPostProcess extends PostProcess {
  41888. /**
  41889. * Default configuration related to image processing available in the PBR Material.
  41890. */
  41891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41892. /**
  41893. * Gets the image processing configuration used either in this material.
  41894. */
  41895. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41896. /**
  41897. * Sets the Default image processing configuration used either in the this material.
  41898. *
  41899. * If sets to null, the scene one is in use.
  41900. */
  41901. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41902. /**
  41903. * Keep track of the image processing observer to allow dispose and replace.
  41904. */
  41905. private _imageProcessingObserver;
  41906. /**
  41907. * Attaches a new image processing configuration to the PBR Material.
  41908. * @param configuration
  41909. */
  41910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41911. /**
  41912. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41913. */
  41914. get colorCurves(): Nullable<ColorCurves>;
  41915. /**
  41916. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41917. */
  41918. set colorCurves(value: Nullable<ColorCurves>);
  41919. /**
  41920. * Gets wether the color curves effect is enabled.
  41921. */
  41922. get colorCurvesEnabled(): boolean;
  41923. /**
  41924. * Sets wether the color curves effect is enabled.
  41925. */
  41926. set colorCurvesEnabled(value: boolean);
  41927. /**
  41928. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41929. */
  41930. get colorGradingTexture(): Nullable<BaseTexture>;
  41931. /**
  41932. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41933. */
  41934. set colorGradingTexture(value: Nullable<BaseTexture>);
  41935. /**
  41936. * Gets wether the color grading effect is enabled.
  41937. */
  41938. get colorGradingEnabled(): boolean;
  41939. /**
  41940. * Gets wether the color grading effect is enabled.
  41941. */
  41942. set colorGradingEnabled(value: boolean);
  41943. /**
  41944. * Gets exposure used in the effect.
  41945. */
  41946. get exposure(): number;
  41947. /**
  41948. * Sets exposure used in the effect.
  41949. */
  41950. set exposure(value: number);
  41951. /**
  41952. * Gets wether tonemapping is enabled or not.
  41953. */
  41954. get toneMappingEnabled(): boolean;
  41955. /**
  41956. * Sets wether tonemapping is enabled or not
  41957. */
  41958. set toneMappingEnabled(value: boolean);
  41959. /**
  41960. * Gets the type of tone mapping effect.
  41961. */
  41962. get toneMappingType(): number;
  41963. /**
  41964. * Sets the type of tone mapping effect.
  41965. */
  41966. set toneMappingType(value: number);
  41967. /**
  41968. * Gets contrast used in the effect.
  41969. */
  41970. get contrast(): number;
  41971. /**
  41972. * Sets contrast used in the effect.
  41973. */
  41974. set contrast(value: number);
  41975. /**
  41976. * Gets Vignette stretch size.
  41977. */
  41978. get vignetteStretch(): number;
  41979. /**
  41980. * Sets Vignette stretch size.
  41981. */
  41982. set vignetteStretch(value: number);
  41983. /**
  41984. * Gets Vignette centre X Offset.
  41985. */
  41986. get vignetteCentreX(): number;
  41987. /**
  41988. * Sets Vignette centre X Offset.
  41989. */
  41990. set vignetteCentreX(value: number);
  41991. /**
  41992. * Gets Vignette centre Y Offset.
  41993. */
  41994. get vignetteCentreY(): number;
  41995. /**
  41996. * Sets Vignette centre Y Offset.
  41997. */
  41998. set vignetteCentreY(value: number);
  41999. /**
  42000. * Gets Vignette weight or intensity of the vignette effect.
  42001. */
  42002. get vignetteWeight(): number;
  42003. /**
  42004. * Sets Vignette weight or intensity of the vignette effect.
  42005. */
  42006. set vignetteWeight(value: number);
  42007. /**
  42008. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42009. * if vignetteEnabled is set to true.
  42010. */
  42011. get vignetteColor(): Color4;
  42012. /**
  42013. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42014. * if vignetteEnabled is set to true.
  42015. */
  42016. set vignetteColor(value: Color4);
  42017. /**
  42018. * Gets Camera field of view used by the Vignette effect.
  42019. */
  42020. get vignetteCameraFov(): number;
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. set vignetteCameraFov(value: number);
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. get vignetteBlendMode(): number;
  42029. /**
  42030. * Sets the vignette blend mode allowing different kind of effect.
  42031. */
  42032. set vignetteBlendMode(value: number);
  42033. /**
  42034. * Gets wether the vignette effect is enabled.
  42035. */
  42036. get vignetteEnabled(): boolean;
  42037. /**
  42038. * Sets wether the vignette effect is enabled.
  42039. */
  42040. set vignetteEnabled(value: boolean);
  42041. private _fromLinearSpace;
  42042. /**
  42043. * Gets wether the input of the processing is in Gamma or Linear Space.
  42044. */
  42045. get fromLinearSpace(): boolean;
  42046. /**
  42047. * Sets wether the input of the processing is in Gamma or Linear Space.
  42048. */
  42049. set fromLinearSpace(value: boolean);
  42050. /**
  42051. * Defines cache preventing GC.
  42052. */
  42053. private _defines;
  42054. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42055. /**
  42056. * "ImageProcessingPostProcess"
  42057. * @returns "ImageProcessingPostProcess"
  42058. */
  42059. getClassName(): string;
  42060. protected _updateParameters(): void;
  42061. dispose(camera?: Camera): void;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * Class containing static functions to help procedurally build meshes
  42067. */
  42068. export class GroundBuilder {
  42069. /**
  42070. * Creates a ground mesh
  42071. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42072. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42074. * @param name defines the name of the mesh
  42075. * @param options defines the options used to create the mesh
  42076. * @param scene defines the hosting scene
  42077. * @returns the ground mesh
  42078. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42079. */
  42080. static CreateGround(name: string, options: {
  42081. width?: number;
  42082. height?: number;
  42083. subdivisions?: number;
  42084. subdivisionsX?: number;
  42085. subdivisionsY?: number;
  42086. updatable?: boolean;
  42087. }, scene: any): Mesh;
  42088. /**
  42089. * Creates a tiled ground mesh
  42090. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42091. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42092. * * 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
  42093. * * 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
  42094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42095. * @param name defines the name of the mesh
  42096. * @param options defines the options used to create the mesh
  42097. * @param scene defines the hosting scene
  42098. * @returns the tiled ground mesh
  42099. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42100. */
  42101. static CreateTiledGround(name: string, options: {
  42102. xmin: number;
  42103. zmin: number;
  42104. xmax: number;
  42105. zmax: number;
  42106. subdivisions?: {
  42107. w: number;
  42108. h: number;
  42109. };
  42110. precision?: {
  42111. w: number;
  42112. h: number;
  42113. };
  42114. updatable?: boolean;
  42115. }, scene?: Nullable<Scene>): Mesh;
  42116. /**
  42117. * Creates a ground mesh from a height map
  42118. * * The parameter `url` sets the URL of the height map image resource.
  42119. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42120. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42121. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42122. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42123. * * 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.
  42124. * * 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).
  42125. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42127. * @param name defines the name of the mesh
  42128. * @param url defines the url to the height map
  42129. * @param options defines the options used to create the mesh
  42130. * @param scene defines the hosting scene
  42131. * @returns the ground mesh
  42132. * @see https://doc.babylonjs.com/babylon101/height_map
  42133. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42134. */
  42135. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42136. width?: number;
  42137. height?: number;
  42138. subdivisions?: number;
  42139. minHeight?: number;
  42140. maxHeight?: number;
  42141. colorFilter?: Color3;
  42142. alphaFilter?: number;
  42143. updatable?: boolean;
  42144. onReady?: (mesh: GroundMesh) => void;
  42145. }, scene?: Nullable<Scene>): GroundMesh;
  42146. }
  42147. }
  42148. declare module BABYLON {
  42149. /**
  42150. * Class containing static functions to help procedurally build meshes
  42151. */
  42152. export class TorusBuilder {
  42153. /**
  42154. * Creates a torus mesh
  42155. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42156. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42157. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42159. * * 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
  42160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42161. * @param name defines the name of the mesh
  42162. * @param options defines the options used to create the mesh
  42163. * @param scene defines the hosting scene
  42164. * @returns the torus mesh
  42165. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42166. */
  42167. static CreateTorus(name: string, options: {
  42168. diameter?: number;
  42169. thickness?: number;
  42170. tessellation?: number;
  42171. updatable?: boolean;
  42172. sideOrientation?: number;
  42173. frontUVs?: Vector4;
  42174. backUVs?: Vector4;
  42175. }, scene: any): Mesh;
  42176. }
  42177. }
  42178. declare module BABYLON {
  42179. /**
  42180. * Class containing static functions to help procedurally build meshes
  42181. */
  42182. export class CylinderBuilder {
  42183. /**
  42184. * Creates a cylinder or a cone mesh
  42185. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42186. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42187. * * 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.
  42188. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42189. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42190. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42191. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42192. * * 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).
  42193. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42194. * * 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).
  42195. * * 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
  42196. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42197. * * 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
  42198. * * 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.
  42199. * * If `enclose` is false, a ring surface is one element.
  42200. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42201. * * 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
  42202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42203. * * 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
  42204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42205. * @param name defines the name of the mesh
  42206. * @param options defines the options used to create the mesh
  42207. * @param scene defines the hosting scene
  42208. * @returns the cylinder mesh
  42209. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42210. */
  42211. static CreateCylinder(name: string, options: {
  42212. height?: number;
  42213. diameterTop?: number;
  42214. diameterBottom?: number;
  42215. diameter?: number;
  42216. tessellation?: number;
  42217. subdivisions?: number;
  42218. arc?: number;
  42219. faceColors?: Color4[];
  42220. faceUV?: Vector4[];
  42221. updatable?: boolean;
  42222. hasRings?: boolean;
  42223. enclose?: boolean;
  42224. cap?: number;
  42225. sideOrientation?: number;
  42226. frontUVs?: Vector4;
  42227. backUVs?: Vector4;
  42228. }, scene: any): Mesh;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * States of the webXR experience
  42234. */
  42235. export enum WebXRState {
  42236. /**
  42237. * Transitioning to being in XR mode
  42238. */
  42239. ENTERING_XR = 0,
  42240. /**
  42241. * Transitioning to non XR mode
  42242. */
  42243. EXITING_XR = 1,
  42244. /**
  42245. * In XR mode and presenting
  42246. */
  42247. IN_XR = 2,
  42248. /**
  42249. * Not entered XR mode
  42250. */
  42251. NOT_IN_XR = 3
  42252. }
  42253. /**
  42254. * Abstraction of the XR render target
  42255. */
  42256. export interface WebXRRenderTarget extends IDisposable {
  42257. /**
  42258. * xrpresent context of the canvas which can be used to display/mirror xr content
  42259. */
  42260. canvasContext: WebGLRenderingContext;
  42261. /**
  42262. * xr layer for the canvas
  42263. */
  42264. xrLayer: Nullable<XRWebGLLayer>;
  42265. /**
  42266. * Initializes the xr layer for the session
  42267. * @param xrSession xr session
  42268. * @returns a promise that will resolve once the XR Layer has been created
  42269. */
  42270. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42271. }
  42272. }
  42273. declare module BABYLON {
  42274. /**
  42275. * COnfiguration object for WebXR output canvas
  42276. */
  42277. export class WebXRManagedOutputCanvasOptions {
  42278. /**
  42279. * Options for this XR Layer output
  42280. */
  42281. canvasOptions: XRWebGLLayerOptions;
  42282. /**
  42283. * CSS styling for a newly created canvas (if not provided)
  42284. */
  42285. newCanvasCssStyle?: string;
  42286. /**
  42287. * Get the default values of the configuration object
  42288. * @returns default values of this configuration object
  42289. */
  42290. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42291. }
  42292. /**
  42293. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42294. */
  42295. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42296. private configuration;
  42297. private _engine;
  42298. private _canvas;
  42299. /**
  42300. * xrpresent context of the canvas which can be used to display/mirror xr content
  42301. */
  42302. canvasContext: WebGLRenderingContext;
  42303. /**
  42304. * xr layer for the canvas
  42305. */
  42306. xrLayer: Nullable<XRWebGLLayer>;
  42307. /**
  42308. * Initializes the xr layer for the session
  42309. * @param xrSession xr session
  42310. * @returns a promise that will resolve once the XR Layer has been created
  42311. */
  42312. initializeXRLayerAsync(xrSession: any): any;
  42313. /**
  42314. * Initializes the canvas to be added/removed upon entering/exiting xr
  42315. * @param engine the Babylon engine
  42316. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42317. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42318. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42319. */
  42320. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42321. /**
  42322. * Disposes of the object
  42323. */
  42324. dispose(): void;
  42325. private _setManagedOutputCanvas;
  42326. private _addCanvas;
  42327. private _removeCanvas;
  42328. }
  42329. }
  42330. declare module BABYLON {
  42331. /**
  42332. * Manages an XRSession to work with Babylon's engine
  42333. * @see https://doc.babylonjs.com/how_to/webxr
  42334. */
  42335. export class WebXRSessionManager implements IDisposable {
  42336. /** The scene which the session should be created for */
  42337. scene: Scene;
  42338. /**
  42339. * Fires every time a new xrFrame arrives which can be used to update the camera
  42340. */
  42341. onXRFrameObservable: Observable<XRFrame>;
  42342. /**
  42343. * Fires when the xr session is ended either by the device or manually done
  42344. */
  42345. onXRSessionEnded: Observable<any>;
  42346. /**
  42347. * Fires when the xr session is ended either by the device or manually done
  42348. */
  42349. onXRSessionInit: Observable<XRSession>;
  42350. /**
  42351. * Underlying xr session
  42352. */
  42353. session: XRSession;
  42354. /**
  42355. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42356. * or get the offset the player is currently at.
  42357. */
  42358. viewerReferenceSpace: XRReferenceSpace;
  42359. /**
  42360. * The current reference space used in this session. This reference space can constantly change!
  42361. * It is mainly used to offset the camera's position.
  42362. */
  42363. referenceSpace: XRReferenceSpace;
  42364. /**
  42365. * The base reference space from which the session started. good if you want to reset your
  42366. * reference space
  42367. */
  42368. baseReferenceSpace: XRReferenceSpace;
  42369. /**
  42370. * Used just in case of a failure to initialize an immersive session.
  42371. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42372. */
  42373. defaultHeightCompensation: number;
  42374. /**
  42375. * Current XR frame
  42376. */
  42377. currentFrame: Nullable<XRFrame>;
  42378. /** WebXR timestamp updated every frame */
  42379. currentTimestamp: number;
  42380. private _xrNavigator;
  42381. private baseLayer;
  42382. private _rttProvider;
  42383. private _sessionEnded;
  42384. /**
  42385. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42386. * @param scene The scene which the session should be created for
  42387. */
  42388. constructor(
  42389. /** The scene which the session should be created for */
  42390. scene: Scene);
  42391. /**
  42392. * Initializes the manager
  42393. * After initialization enterXR can be called to start an XR session
  42394. * @returns Promise which resolves after it is initialized
  42395. */
  42396. initializeAsync(): Promise<void>;
  42397. /**
  42398. * Initializes an xr session
  42399. * @param xrSessionMode mode to initialize
  42400. * @param optionalFeatures defines optional values to pass to the session builder
  42401. * @returns a promise which will resolve once the session has been initialized
  42402. */
  42403. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42404. /**
  42405. * Sets the reference space on the xr session
  42406. * @param referenceSpace space to set
  42407. * @returns a promise that will resolve once the reference space has been set
  42408. */
  42409. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42410. /**
  42411. * Updates the render state of the session
  42412. * @param state state to set
  42413. * @returns a promise that resolves once the render state has been updated
  42414. */
  42415. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42416. /**
  42417. * Starts rendering to the xr layer
  42418. * @returns a promise that will resolve once rendering has started
  42419. */
  42420. startRenderingToXRAsync(): Promise<void>;
  42421. /**
  42422. * Gets the correct render target texture to be rendered this frame for this eye
  42423. * @param eye the eye for which to get the render target
  42424. * @returns the render target for the specified eye
  42425. */
  42426. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42427. /**
  42428. * Stops the xrSession and restores the renderloop
  42429. * @returns Promise which resolves after it exits XR
  42430. */
  42431. exitXRAsync(): Promise<void>;
  42432. /**
  42433. * Checks if a session would be supported for the creation options specified
  42434. * @param sessionMode session mode to check if supported eg. immersive-vr
  42435. * @returns true if supported
  42436. */
  42437. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42438. /**
  42439. * Creates a WebXRRenderTarget object for the XR session
  42440. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42441. * @param options optional options to provide when creating a new render target
  42442. * @returns a WebXR render target to which the session can render
  42443. */
  42444. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42445. /**
  42446. * @hidden
  42447. * Converts the render layer of xrSession to a render target
  42448. * @param session session to create render target for
  42449. * @param scene scene the new render target should be created for
  42450. * @param baseLayer the webgl layer to create the render target for
  42451. */
  42452. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42453. /**
  42454. * Disposes of the session manager
  42455. */
  42456. dispose(): void;
  42457. /**
  42458. * Gets a promise returning true when fullfiled if the given session mode is supported
  42459. * @param sessionMode defines the session to test
  42460. * @returns a promise
  42461. */
  42462. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * WebXR Camera which holds the views for the xrSession
  42468. * @see https://doc.babylonjs.com/how_to/webxr
  42469. */
  42470. export class WebXRCamera extends FreeCamera {
  42471. private _xrSessionManager;
  42472. /**
  42473. * Is the camera in debug mode. Used when using an emulator
  42474. */
  42475. debugMode: boolean;
  42476. private _firstFrame;
  42477. private _referencedPosition;
  42478. private _referenceQuaternion;
  42479. private _xrInvPositionCache;
  42480. private _xrInvQuaternionCache;
  42481. /**
  42482. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42483. * @param name the name of the camera
  42484. * @param scene the scene to add the camera to
  42485. */
  42486. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42487. private _updateNumberOfRigCameras;
  42488. /** @hidden */
  42489. _updateForDualEyeDebugging(): void;
  42490. /**
  42491. * Updates the cameras position from the current pose information of the XR session
  42492. * @param xrSessionManager the session containing pose information
  42493. */
  42494. update(): void;
  42495. private _updateReferenceSpace;
  42496. private _updateReferenceSpaceOffset;
  42497. private _updateFromXRSession;
  42498. }
  42499. }
  42500. declare module BABYLON {
  42501. /**
  42502. * Defining the interface required for a (webxr) feature
  42503. */
  42504. export interface IWebXRFeature extends IDisposable {
  42505. /**
  42506. * Attach the feature to the session
  42507. * Will usually be called by the features manager
  42508. *
  42509. * @returns true if successful.
  42510. */
  42511. attach(): boolean;
  42512. /**
  42513. * Detach the feature from the session
  42514. * Will usually be called by the features manager
  42515. *
  42516. * @returns true if successful.
  42517. */
  42518. detach(): boolean;
  42519. }
  42520. /**
  42521. * Defining the constructor of a feature. Used to register the modules.
  42522. */
  42523. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42524. /**
  42525. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42526. * It is mainly used in AR sessions.
  42527. *
  42528. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42529. */
  42530. export class WebXRFeaturesManager implements IDisposable {
  42531. private _xrSessionManager;
  42532. private static readonly _AvailableFeatures;
  42533. /**
  42534. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42535. * Mainly used internally.
  42536. *
  42537. * @param featureName the name of the feature to register
  42538. * @param constructorFunction the function used to construct the module
  42539. * @param version the (babylon) version of the module
  42540. * @param stable is that a stable version of this module
  42541. */
  42542. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42543. /**
  42544. * Returns a constructor of a specific feature.
  42545. *
  42546. * @param featureName the name of the feature to construct
  42547. * @param version the version of the feature to load
  42548. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42549. * @param options optional options provided to the module.
  42550. * @returns a function that, when called, will return a new instance of this feature
  42551. */
  42552. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42553. /**
  42554. * Return the latest unstable version of this feature
  42555. * @param featureName the name of the feature to search
  42556. * @returns the version number. if not found will return -1
  42557. */
  42558. static GetLatestVersionOfFeature(featureName: string): number;
  42559. /**
  42560. * Return the latest stable version of this feature
  42561. * @param featureName the name of the feature to search
  42562. * @returns the version number. if not found will return -1
  42563. */
  42564. static GetStableVersionOfFeature(featureName: string): number;
  42565. /**
  42566. * Can be used to return the list of features currently registered
  42567. *
  42568. * @returns an Array of available features
  42569. */
  42570. static GetAvailableFeatures(): string[];
  42571. /**
  42572. * Gets the versions available for a specific feature
  42573. * @param featureName the name of the feature
  42574. * @returns an array with the available versions
  42575. */
  42576. static GetAvailableVersions(featureName: string): string[];
  42577. private _features;
  42578. /**
  42579. * constructs a new features manages.
  42580. *
  42581. * @param _xrSessionManager an instance of WebXRSessionManager
  42582. */
  42583. constructor(_xrSessionManager: WebXRSessionManager);
  42584. /**
  42585. * 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.
  42586. *
  42587. * @param featureName the name of the feature to load or the class of the feature
  42588. * @param version optional version to load. if not provided the latest version will be enabled
  42589. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42590. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42591. * @returns a new constructed feature or throws an error if feature not found.
  42592. */
  42593. enableFeature(featureName: string | {
  42594. Name: string;
  42595. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42596. /**
  42597. * Used to disable an already-enabled feature
  42598. * @param featureName the feature to disable
  42599. * @returns true if disable was successful
  42600. */
  42601. disableFeature(featureName: string | {
  42602. Name: string;
  42603. }): boolean;
  42604. /**
  42605. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42606. * Can be used during a session to start a feature
  42607. * @param featureName the name of feature to attach
  42608. */
  42609. attachFeature(featureName: string): void;
  42610. /**
  42611. * Can be used inside a session or when the session ends to detach a specific feature
  42612. * @param featureName the name of the feature to detach
  42613. */
  42614. detachFeature(featureName: string): void;
  42615. /**
  42616. * Get the list of enabled features
  42617. * @returns an array of enabled features
  42618. */
  42619. getEnabledFeatures(): string[];
  42620. /**
  42621. * get the implementation of an enabled feature.
  42622. * @param featureName the name of the feature to load
  42623. * @returns the feature class, if found
  42624. */
  42625. getEnabledFeature(featureName: string): IWebXRFeature;
  42626. /**
  42627. * dispose this features manager
  42628. */
  42629. dispose(): void;
  42630. }
  42631. }
  42632. declare module BABYLON {
  42633. /**
  42634. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42635. * @see https://doc.babylonjs.com/how_to/webxr
  42636. */
  42637. export class WebXRExperienceHelper implements IDisposable {
  42638. private scene;
  42639. /**
  42640. * Camera used to render xr content
  42641. */
  42642. camera: WebXRCamera;
  42643. /**
  42644. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42645. */
  42646. state: WebXRState;
  42647. private _setState;
  42648. /**
  42649. * Fires when the state of the experience helper has changed
  42650. */
  42651. onStateChangedObservable: Observable<WebXRState>;
  42652. /**
  42653. * Observers registered here will be triggered after the camera's initial transformation is set
  42654. * This can be used to set a different ground level or an extra rotation.
  42655. *
  42656. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42657. * to the position set after this observable is done executing.
  42658. */
  42659. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42660. /** Session manager used to keep track of xr session */
  42661. sessionManager: WebXRSessionManager;
  42662. /** A features manager for this xr session */
  42663. featuresManager: WebXRFeaturesManager;
  42664. private _nonVRCamera;
  42665. private _originalSceneAutoClear;
  42666. private _supported;
  42667. /**
  42668. * Creates the experience helper
  42669. * @param scene the scene to attach the experience helper to
  42670. * @returns a promise for the experience helper
  42671. */
  42672. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42673. /**
  42674. * Creates a WebXRExperienceHelper
  42675. * @param scene The scene the helper should be created in
  42676. */
  42677. private constructor();
  42678. /**
  42679. * Exits XR mode and returns the scene to its original state
  42680. * @returns promise that resolves after xr mode has exited
  42681. */
  42682. exitXRAsync(): Promise<void>;
  42683. /**
  42684. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42685. * @param sessionMode options for the XR session
  42686. * @param referenceSpaceType frame of reference of the XR session
  42687. * @param renderTarget the output canvas that will be used to enter XR mode
  42688. * @returns promise that resolves after xr mode has entered
  42689. */
  42690. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42691. /**
  42692. * Disposes of the experience helper
  42693. */
  42694. dispose(): void;
  42695. private _nonXRToXRCamera;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /**
  42700. * Represents an XR input
  42701. */
  42702. export class WebXRController {
  42703. private scene;
  42704. /** The underlying input source for the controller */
  42705. inputSource: XRInputSource;
  42706. private parentContainer;
  42707. /**
  42708. * 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
  42709. */
  42710. grip?: AbstractMesh;
  42711. /**
  42712. * Pointer which can be used to select objects or attach a visible laser to
  42713. */
  42714. pointer: AbstractMesh;
  42715. private _gamepadMode;
  42716. /**
  42717. * If available, this is the gamepad object related to this controller.
  42718. * Using this object it is possible to get click events and trackpad changes of the
  42719. * webxr controller that is currently being used.
  42720. */
  42721. gamepadController?: WebVRController;
  42722. /**
  42723. * Event that fires when the controller is removed/disposed
  42724. */
  42725. onDisposeObservable: Observable<{}>;
  42726. private _tmpQuaternion;
  42727. private _tmpVector;
  42728. /**
  42729. * Creates the controller
  42730. * @see https://doc.babylonjs.com/how_to/webxr
  42731. * @param scene the scene which the controller should be associated to
  42732. * @param inputSource the underlying input source for the controller
  42733. * @param parentContainer parent that the controller meshes should be children of
  42734. */
  42735. constructor(scene: Scene,
  42736. /** The underlying input source for the controller */
  42737. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42738. /**
  42739. * Updates the controller pose based on the given XRFrame
  42740. * @param xrFrame xr frame to update the pose with
  42741. * @param referenceSpace reference space to use
  42742. */
  42743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42744. /**
  42745. * Gets a world space ray coming from the controller
  42746. * @param result the resulting ray
  42747. */
  42748. getWorldPointerRayToRef(result: Ray): void;
  42749. /**
  42750. * Get the scene associated with this controller
  42751. * @returns the scene object
  42752. */
  42753. getScene(): Scene;
  42754. /**
  42755. * Disposes of the object
  42756. */
  42757. dispose(): void;
  42758. }
  42759. }
  42760. declare module BABYLON {
  42761. /**
  42762. * XR input used to track XR inputs such as controllers/rays
  42763. */
  42764. export class WebXRInput implements IDisposable {
  42765. /**
  42766. * Base experience the input listens to
  42767. */
  42768. baseExperience: WebXRExperienceHelper;
  42769. /**
  42770. * XR controllers being tracked
  42771. */
  42772. controllers: Array<WebXRController>;
  42773. private _frameObserver;
  42774. private _stateObserver;
  42775. /**
  42776. * Event when a controller has been connected/added
  42777. */
  42778. onControllerAddedObservable: Observable<WebXRController>;
  42779. /**
  42780. * Event when a controller has been removed/disconnected
  42781. */
  42782. onControllerRemovedObservable: Observable<WebXRController>;
  42783. /**
  42784. * Initializes the WebXRInput
  42785. * @param baseExperience experience helper which the input should be created for
  42786. */
  42787. constructor(
  42788. /**
  42789. * Base experience the input listens to
  42790. */
  42791. baseExperience: WebXRExperienceHelper);
  42792. private _onInputSourcesChange;
  42793. private _addAndRemoveControllers;
  42794. /**
  42795. * Disposes of the object
  42796. */
  42797. dispose(): void;
  42798. }
  42799. }
  42800. declare module BABYLON {
  42801. /**
  42802. * Class used to represent data loading progression
  42803. */
  42804. export class SceneLoaderProgressEvent {
  42805. /** defines if data length to load can be evaluated */
  42806. readonly lengthComputable: boolean;
  42807. /** defines the loaded data length */
  42808. readonly loaded: number;
  42809. /** defines the data length to load */
  42810. readonly total: number;
  42811. /**
  42812. * Create a new progress event
  42813. * @param lengthComputable defines if data length to load can be evaluated
  42814. * @param loaded defines the loaded data length
  42815. * @param total defines the data length to load
  42816. */
  42817. constructor(
  42818. /** defines if data length to load can be evaluated */
  42819. lengthComputable: boolean,
  42820. /** defines the loaded data length */
  42821. loaded: number,
  42822. /** defines the data length to load */
  42823. total: number);
  42824. /**
  42825. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42826. * @param event defines the source event
  42827. * @returns a new SceneLoaderProgressEvent
  42828. */
  42829. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42830. }
  42831. /**
  42832. * Interface used by SceneLoader plugins to define supported file extensions
  42833. */
  42834. export interface ISceneLoaderPluginExtensions {
  42835. /**
  42836. * Defines the list of supported extensions
  42837. */
  42838. [extension: string]: {
  42839. isBinary: boolean;
  42840. };
  42841. }
  42842. /**
  42843. * Interface used by SceneLoader plugin factory
  42844. */
  42845. export interface ISceneLoaderPluginFactory {
  42846. /**
  42847. * Defines the name of the factory
  42848. */
  42849. name: string;
  42850. /**
  42851. * Function called to create a new plugin
  42852. * @return the new plugin
  42853. */
  42854. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42855. /**
  42856. * The callback that returns true if the data can be directly loaded.
  42857. * @param data string containing the file data
  42858. * @returns if the data can be loaded directly
  42859. */
  42860. canDirectLoad?(data: string): boolean;
  42861. }
  42862. /**
  42863. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42864. */
  42865. export interface ISceneLoaderPluginBase {
  42866. /**
  42867. * The friendly name of this plugin.
  42868. */
  42869. name: string;
  42870. /**
  42871. * The file extensions supported by this plugin.
  42872. */
  42873. extensions: string | ISceneLoaderPluginExtensions;
  42874. /**
  42875. * The callback called when loading from a url.
  42876. * @param scene scene loading this url
  42877. * @param url url to load
  42878. * @param onSuccess callback called when the file successfully loads
  42879. * @param onProgress callback called while file is loading (if the server supports this mode)
  42880. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42881. * @param onError callback called when the file fails to load
  42882. * @returns a file request object
  42883. */
  42884. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42885. /**
  42886. * The callback called when loading from a file object.
  42887. * @param scene scene loading this file
  42888. * @param file defines the file to load
  42889. * @param onSuccess defines the callback to call when data is loaded
  42890. * @param onProgress defines the callback to call during loading process
  42891. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42892. * @param onError defines the callback to call when an error occurs
  42893. * @returns a file request object
  42894. */
  42895. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42896. /**
  42897. * The callback that returns true if the data can be directly loaded.
  42898. * @param data string containing the file data
  42899. * @returns if the data can be loaded directly
  42900. */
  42901. canDirectLoad?(data: string): boolean;
  42902. /**
  42903. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42904. * @param scene scene loading this data
  42905. * @param data string containing the data
  42906. * @returns data to pass to the plugin
  42907. */
  42908. directLoad?(scene: Scene, data: string): any;
  42909. /**
  42910. * The callback that allows custom handling of the root url based on the response url.
  42911. * @param rootUrl the original root url
  42912. * @param responseURL the response url if available
  42913. * @returns the new root url
  42914. */
  42915. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42916. }
  42917. /**
  42918. * Interface used to define a SceneLoader plugin
  42919. */
  42920. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42921. /**
  42922. * Import meshes into a scene.
  42923. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42924. * @param scene The scene to import into
  42925. * @param data The data to import
  42926. * @param rootUrl The root url for scene and resources
  42927. * @param meshes The meshes array to import into
  42928. * @param particleSystems The particle systems array to import into
  42929. * @param skeletons The skeletons array to import into
  42930. * @param onError The callback when import fails
  42931. * @returns True if successful or false otherwise
  42932. */
  42933. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42934. /**
  42935. * Load into a scene.
  42936. * @param scene The scene to load into
  42937. * @param data The data to import
  42938. * @param rootUrl The root url for scene and resources
  42939. * @param onError The callback when import fails
  42940. * @returns True if successful or false otherwise
  42941. */
  42942. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42943. /**
  42944. * Load into an asset container.
  42945. * @param scene The scene to load into
  42946. * @param data The data to import
  42947. * @param rootUrl The root url for scene and resources
  42948. * @param onError The callback when import fails
  42949. * @returns The loaded asset container
  42950. */
  42951. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42952. }
  42953. /**
  42954. * Interface used to define an async SceneLoader plugin
  42955. */
  42956. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42957. /**
  42958. * Import meshes into a scene.
  42959. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42960. * @param scene The scene to import into
  42961. * @param data The data to import
  42962. * @param rootUrl The root url for scene and resources
  42963. * @param onProgress The callback when the load progresses
  42964. * @param fileName Defines the name of the file to load
  42965. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42966. */
  42967. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42968. meshes: AbstractMesh[];
  42969. particleSystems: IParticleSystem[];
  42970. skeletons: Skeleton[];
  42971. animationGroups: AnimationGroup[];
  42972. }>;
  42973. /**
  42974. * Load into a scene.
  42975. * @param scene The scene to load into
  42976. * @param data The data to import
  42977. * @param rootUrl The root url for scene and resources
  42978. * @param onProgress The callback when the load progresses
  42979. * @param fileName Defines the name of the file to load
  42980. * @returns Nothing
  42981. */
  42982. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42983. /**
  42984. * Load into an asset container.
  42985. * @param scene The scene to load into
  42986. * @param data The data to import
  42987. * @param rootUrl The root url for scene and resources
  42988. * @param onProgress The callback when the load progresses
  42989. * @param fileName Defines the name of the file to load
  42990. * @returns The loaded asset container
  42991. */
  42992. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42993. }
  42994. /**
  42995. * Mode that determines how to handle old animation groups before loading new ones.
  42996. */
  42997. export enum SceneLoaderAnimationGroupLoadingMode {
  42998. /**
  42999. * Reset all old animations to initial state then dispose them.
  43000. */
  43001. Clean = 0,
  43002. /**
  43003. * Stop all old animations.
  43004. */
  43005. Stop = 1,
  43006. /**
  43007. * Restart old animations from first frame.
  43008. */
  43009. Sync = 2,
  43010. /**
  43011. * Old animations remains untouched.
  43012. */
  43013. NoSync = 3
  43014. }
  43015. /**
  43016. * Class used to load scene from various file formats using registered plugins
  43017. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43018. */
  43019. export class SceneLoader {
  43020. /**
  43021. * No logging while loading
  43022. */
  43023. static readonly NO_LOGGING: number;
  43024. /**
  43025. * Minimal logging while loading
  43026. */
  43027. static readonly MINIMAL_LOGGING: number;
  43028. /**
  43029. * Summary logging while loading
  43030. */
  43031. static readonly SUMMARY_LOGGING: number;
  43032. /**
  43033. * Detailled logging while loading
  43034. */
  43035. static readonly DETAILED_LOGGING: number;
  43036. /**
  43037. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43038. */
  43039. static get ForceFullSceneLoadingForIncremental(): boolean;
  43040. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43041. /**
  43042. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43043. */
  43044. static get ShowLoadingScreen(): boolean;
  43045. static set ShowLoadingScreen(value: boolean);
  43046. /**
  43047. * Defines the current logging level (while loading the scene)
  43048. * @ignorenaming
  43049. */
  43050. static get loggingLevel(): number;
  43051. static set loggingLevel(value: number);
  43052. /**
  43053. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43054. */
  43055. static get CleanBoneMatrixWeights(): boolean;
  43056. static set CleanBoneMatrixWeights(value: boolean);
  43057. /**
  43058. * Event raised when a plugin is used to load a scene
  43059. */
  43060. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43061. private static _registeredPlugins;
  43062. private static _getDefaultPlugin;
  43063. private static _getPluginForExtension;
  43064. private static _getPluginForDirectLoad;
  43065. private static _getPluginForFilename;
  43066. private static _getDirectLoad;
  43067. private static _loadData;
  43068. private static _getFileInfo;
  43069. /**
  43070. * Gets a plugin that can load the given extension
  43071. * @param extension defines the extension to load
  43072. * @returns a plugin or null if none works
  43073. */
  43074. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43075. /**
  43076. * Gets a boolean indicating that the given extension can be loaded
  43077. * @param extension defines the extension to load
  43078. * @returns true if the extension is supported
  43079. */
  43080. static IsPluginForExtensionAvailable(extension: string): boolean;
  43081. /**
  43082. * Adds a new plugin to the list of registered plugins
  43083. * @param plugin defines the plugin to add
  43084. */
  43085. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43086. /**
  43087. * Import meshes into a scene
  43088. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43089. * @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)
  43090. * @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)
  43091. * @param scene the instance of BABYLON.Scene to append to
  43092. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43093. * @param onProgress a callback with a progress event for each file being loaded
  43094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43095. * @param pluginExtension the extension used to determine the plugin
  43096. * @returns The loaded plugin
  43097. */
  43098. 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>;
  43099. /**
  43100. * Import meshes into a scene
  43101. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43102. * @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)
  43103. * @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)
  43104. * @param scene the instance of BABYLON.Scene to append to
  43105. * @param onProgress a callback with a progress event for each file being loaded
  43106. * @param pluginExtension the extension used to determine the plugin
  43107. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43108. */
  43109. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43110. meshes: AbstractMesh[];
  43111. particleSystems: IParticleSystem[];
  43112. skeletons: Skeleton[];
  43113. animationGroups: AnimationGroup[];
  43114. }>;
  43115. /**
  43116. * Load a scene
  43117. * @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)
  43118. * @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)
  43119. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43120. * @param onSuccess a callback with the scene when import succeeds
  43121. * @param onProgress a callback with a progress event for each file being loaded
  43122. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43123. * @param pluginExtension the extension used to determine the plugin
  43124. * @returns The loaded plugin
  43125. */
  43126. 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>;
  43127. /**
  43128. * Load a scene
  43129. * @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)
  43130. * @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)
  43131. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43132. * @param onProgress a callback with a progress event for each file being loaded
  43133. * @param pluginExtension the extension used to determine the plugin
  43134. * @returns The loaded scene
  43135. */
  43136. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43137. /**
  43138. * Append a scene
  43139. * @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)
  43140. * @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)
  43141. * @param scene is the instance of BABYLON.Scene to append to
  43142. * @param onSuccess a callback with the scene when import succeeds
  43143. * @param onProgress a callback with a progress event for each file being loaded
  43144. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43145. * @param pluginExtension the extension used to determine the plugin
  43146. * @returns The loaded plugin
  43147. */
  43148. 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>;
  43149. /**
  43150. * Append a scene
  43151. * @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)
  43152. * @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)
  43153. * @param scene is the instance of BABYLON.Scene to append to
  43154. * @param onProgress a callback with a progress event for each file being loaded
  43155. * @param pluginExtension the extension used to determine the plugin
  43156. * @returns The given scene
  43157. */
  43158. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43159. /**
  43160. * Load a scene into an asset container
  43161. * @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)
  43162. * @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)
  43163. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43164. * @param onSuccess a callback with the scene when import succeeds
  43165. * @param onProgress a callback with a progress event for each file being loaded
  43166. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43167. * @param pluginExtension the extension used to determine the plugin
  43168. * @returns The loaded plugin
  43169. */
  43170. 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>;
  43171. /**
  43172. * Load a scene into an asset container
  43173. * @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)
  43174. * @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)
  43175. * @param scene is the instance of Scene to append to
  43176. * @param onProgress a callback with a progress event for each file being loaded
  43177. * @param pluginExtension the extension used to determine the plugin
  43178. * @returns The loaded asset container
  43179. */
  43180. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43181. /**
  43182. * Import animations from a file into a scene
  43183. * @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)
  43184. * @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)
  43185. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43186. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43187. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43188. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43189. * @param onSuccess a callback with the scene when import succeeds
  43190. * @param onProgress a callback with a progress event for each file being loaded
  43191. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43192. */
  43193. 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;
  43194. /**
  43195. * Import animations from a file into a scene
  43196. * @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)
  43197. * @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)
  43198. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43199. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43200. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43201. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43202. * @param onSuccess a callback with the scene when import succeeds
  43203. * @param onProgress a callback with a progress event for each file being loaded
  43204. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43205. * @returns the updated scene with imported animations
  43206. */
  43207. 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>;
  43208. }
  43209. }
  43210. declare module BABYLON {
  43211. /**
  43212. * Generic Controller
  43213. */
  43214. export class GenericController extends WebVRController {
  43215. /**
  43216. * Base Url for the controller model.
  43217. */
  43218. static readonly MODEL_BASE_URL: string;
  43219. /**
  43220. * File name for the controller model.
  43221. */
  43222. static readonly MODEL_FILENAME: string;
  43223. /**
  43224. * Creates a new GenericController from a gamepad
  43225. * @param vrGamepad the gamepad that the controller should be created from
  43226. */
  43227. constructor(vrGamepad: any);
  43228. /**
  43229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43230. * @param scene scene in which to add meshes
  43231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43232. */
  43233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43234. /**
  43235. * Called once for each button that changed state since the last frame
  43236. * @param buttonIdx Which button index changed
  43237. * @param state New state of the button
  43238. * @param changes Which properties on the state changed since last frame
  43239. */
  43240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43241. }
  43242. }
  43243. declare module BABYLON {
  43244. /**
  43245. * Defines the WindowsMotionController object that the state of the windows motion controller
  43246. */
  43247. export class WindowsMotionController extends WebVRController {
  43248. /**
  43249. * The base url used to load the left and right controller models
  43250. */
  43251. static MODEL_BASE_URL: string;
  43252. /**
  43253. * The name of the left controller model file
  43254. */
  43255. static MODEL_LEFT_FILENAME: string;
  43256. /**
  43257. * The name of the right controller model file
  43258. */
  43259. static MODEL_RIGHT_FILENAME: string;
  43260. /**
  43261. * The controller name prefix for this controller type
  43262. */
  43263. static readonly GAMEPAD_ID_PREFIX: string;
  43264. /**
  43265. * The controller id pattern for this controller type
  43266. */
  43267. private static readonly GAMEPAD_ID_PATTERN;
  43268. private _loadedMeshInfo;
  43269. protected readonly _mapping: {
  43270. buttons: string[];
  43271. buttonMeshNames: {
  43272. 'trigger': string;
  43273. 'menu': string;
  43274. 'grip': string;
  43275. 'thumbstick': string;
  43276. 'trackpad': string;
  43277. };
  43278. buttonObservableNames: {
  43279. 'trigger': string;
  43280. 'menu': string;
  43281. 'grip': string;
  43282. 'thumbstick': string;
  43283. 'trackpad': string;
  43284. };
  43285. axisMeshNames: string[];
  43286. pointingPoseMeshName: string;
  43287. };
  43288. /**
  43289. * Fired when the trackpad on this controller is clicked
  43290. */
  43291. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43292. /**
  43293. * Fired when the trackpad on this controller is modified
  43294. */
  43295. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43296. /**
  43297. * The current x and y values of this controller's trackpad
  43298. */
  43299. trackpad: StickValues;
  43300. /**
  43301. * Creates a new WindowsMotionController from a gamepad
  43302. * @param vrGamepad the gamepad that the controller should be created from
  43303. */
  43304. constructor(vrGamepad: any);
  43305. /**
  43306. * Fired when the trigger on this controller is modified
  43307. */
  43308. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43309. /**
  43310. * Fired when the menu button on this controller is modified
  43311. */
  43312. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43313. /**
  43314. * Fired when the grip button on this controller is modified
  43315. */
  43316. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43317. /**
  43318. * Fired when the thumbstick button on this controller is modified
  43319. */
  43320. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43321. /**
  43322. * Fired when the touchpad button on this controller is modified
  43323. */
  43324. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43325. /**
  43326. * Fired when the touchpad values on this controller are modified
  43327. */
  43328. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43329. protected _updateTrackpad(): void;
  43330. /**
  43331. * Called once per frame by the engine.
  43332. */
  43333. update(): void;
  43334. /**
  43335. * Called once for each button that changed state since the last frame
  43336. * @param buttonIdx Which button index changed
  43337. * @param state New state of the button
  43338. * @param changes Which properties on the state changed since last frame
  43339. */
  43340. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43341. /**
  43342. * Moves the buttons on the controller mesh based on their current state
  43343. * @param buttonName the name of the button to move
  43344. * @param buttonValue the value of the button which determines the buttons new position
  43345. */
  43346. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43347. /**
  43348. * Moves the axis on the controller mesh based on its current state
  43349. * @param axis the index of the axis
  43350. * @param axisValue the value of the axis which determines the meshes new position
  43351. * @hidden
  43352. */
  43353. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43354. /**
  43355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43356. * @param scene scene in which to add meshes
  43357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43358. */
  43359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43360. /**
  43361. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43362. * can be transformed by button presses and axes values, based on this._mapping.
  43363. *
  43364. * @param scene scene in which the meshes exist
  43365. * @param meshes list of meshes that make up the controller model to process
  43366. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43367. */
  43368. private processModel;
  43369. private createMeshInfo;
  43370. /**
  43371. * Gets the ray of the controller in the direction the controller is pointing
  43372. * @param length the length the resulting ray should be
  43373. * @returns a ray in the direction the controller is pointing
  43374. */
  43375. getForwardRay(length?: number): Ray;
  43376. /**
  43377. * Disposes of the controller
  43378. */
  43379. dispose(): void;
  43380. }
  43381. /**
  43382. * This class represents a new windows motion controller in XR.
  43383. */
  43384. export class XRWindowsMotionController extends WindowsMotionController {
  43385. /**
  43386. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43387. */
  43388. protected readonly _mapping: {
  43389. buttons: string[];
  43390. buttonMeshNames: {
  43391. 'trigger': string;
  43392. 'menu': string;
  43393. 'grip': string;
  43394. 'thumbstick': string;
  43395. 'trackpad': string;
  43396. };
  43397. buttonObservableNames: {
  43398. 'trigger': string;
  43399. 'menu': string;
  43400. 'grip': string;
  43401. 'thumbstick': string;
  43402. 'trackpad': string;
  43403. };
  43404. axisMeshNames: string[];
  43405. pointingPoseMeshName: string;
  43406. };
  43407. /**
  43408. * Construct a new XR-Based windows motion controller
  43409. *
  43410. * @param gamepadInfo the gamepad object from the browser
  43411. */
  43412. constructor(gamepadInfo: any);
  43413. /**
  43414. * holds the thumbstick values (X,Y)
  43415. */
  43416. thumbstickValues: StickValues;
  43417. /**
  43418. * Fired when the thumbstick on this controller is clicked
  43419. */
  43420. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43421. /**
  43422. * Fired when the thumbstick on this controller is modified
  43423. */
  43424. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43425. /**
  43426. * Fired when the touchpad button on this controller is modified
  43427. */
  43428. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43429. /**
  43430. * Fired when the touchpad values on this controller are modified
  43431. */
  43432. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43433. /**
  43434. * Fired when the thumbstick button on this controller is modified
  43435. * here to prevent breaking changes
  43436. */
  43437. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43438. /**
  43439. * updating the thumbstick(!) and not the trackpad.
  43440. * This is named this way due to the difference between WebVR and XR and to avoid
  43441. * changing the parent class.
  43442. */
  43443. protected _updateTrackpad(): void;
  43444. /**
  43445. * Disposes the class with joy
  43446. */
  43447. dispose(): void;
  43448. }
  43449. }
  43450. declare module BABYLON {
  43451. /**
  43452. * Oculus Touch Controller
  43453. */
  43454. export class OculusTouchController extends WebVRController {
  43455. /**
  43456. * Base Url for the controller model.
  43457. */
  43458. static MODEL_BASE_URL: string;
  43459. /**
  43460. * File name for the left controller model.
  43461. */
  43462. static MODEL_LEFT_FILENAME: string;
  43463. /**
  43464. * File name for the right controller model.
  43465. */
  43466. static MODEL_RIGHT_FILENAME: string;
  43467. /**
  43468. * Base Url for the Quest controller model.
  43469. */
  43470. static QUEST_MODEL_BASE_URL: string;
  43471. /**
  43472. * @hidden
  43473. * If the controllers are running on a device that needs the updated Quest controller models
  43474. */
  43475. static _IsQuest: boolean;
  43476. /**
  43477. * Fired when the secondary trigger on this controller is modified
  43478. */
  43479. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43480. /**
  43481. * Fired when the thumb rest on this controller is modified
  43482. */
  43483. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43484. /**
  43485. * Creates a new OculusTouchController from a gamepad
  43486. * @param vrGamepad the gamepad that the controller should be created from
  43487. */
  43488. constructor(vrGamepad: any);
  43489. /**
  43490. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43491. * @param scene scene in which to add meshes
  43492. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43493. */
  43494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43495. /**
  43496. * Fired when the A button on this controller is modified
  43497. */
  43498. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43499. /**
  43500. * Fired when the B button on this controller is modified
  43501. */
  43502. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43503. /**
  43504. * Fired when the X button on this controller is modified
  43505. */
  43506. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43507. /**
  43508. * Fired when the Y button on this controller is modified
  43509. */
  43510. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43511. /**
  43512. * Called once for each button that changed state since the last frame
  43513. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43514. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43515. * 2) secondary trigger (same)
  43516. * 3) A (right) X (left), touch, pressed = value
  43517. * 4) B / Y
  43518. * 5) thumb rest
  43519. * @param buttonIdx Which button index changed
  43520. * @param state New state of the button
  43521. * @param changes Which properties on the state changed since last frame
  43522. */
  43523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43524. }
  43525. }
  43526. declare module BABYLON {
  43527. /**
  43528. * Vive Controller
  43529. */
  43530. export class ViveController extends WebVRController {
  43531. /**
  43532. * Base Url for the controller model.
  43533. */
  43534. static MODEL_BASE_URL: string;
  43535. /**
  43536. * File name for the controller model.
  43537. */
  43538. static MODEL_FILENAME: string;
  43539. /**
  43540. * Creates a new ViveController from a gamepad
  43541. * @param vrGamepad the gamepad that the controller should be created from
  43542. */
  43543. constructor(vrGamepad: any);
  43544. /**
  43545. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43546. * @param scene scene in which to add meshes
  43547. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43548. */
  43549. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43550. /**
  43551. * Fired when the left button on this controller is modified
  43552. */
  43553. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43554. /**
  43555. * Fired when the right button on this controller is modified
  43556. */
  43557. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43558. /**
  43559. * Fired when the menu button on this controller is modified
  43560. */
  43561. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43562. /**
  43563. * Called once for each button that changed state since the last frame
  43564. * Vive mapping:
  43565. * 0: touchpad
  43566. * 1: trigger
  43567. * 2: left AND right buttons
  43568. * 3: menu button
  43569. * @param buttonIdx Which button index changed
  43570. * @param state New state of the button
  43571. * @param changes Which properties on the state changed since last frame
  43572. */
  43573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43574. }
  43575. }
  43576. declare module BABYLON {
  43577. /**
  43578. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43579. */
  43580. export class WebXRControllerModelLoader {
  43581. /**
  43582. * an observable that triggers when a new model (the mesh itself) was initialized.
  43583. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43584. */
  43585. onControllerModelLoaded: Observable<WebXRController>;
  43586. /**
  43587. * Creates the WebXRControllerModelLoader
  43588. * @param input xr input that creates the controllers
  43589. */
  43590. constructor(input: WebXRInput);
  43591. }
  43592. }
  43593. declare module BABYLON {
  43594. /**
  43595. * Handles pointer input automatically for the pointer of XR controllers
  43596. */
  43597. export class WebXRControllerPointerSelection {
  43598. private static _idCounter;
  43599. private _tmpRay;
  43600. /**
  43601. * Creates a WebXRControllerPointerSelection
  43602. * @param input input manager to setup pointer selection
  43603. */
  43604. constructor(input: WebXRInput);
  43605. private _convertNormalToDirectionOfRay;
  43606. private _updatePointerDistance;
  43607. }
  43608. }
  43609. declare module BABYLON {
  43610. /**
  43611. * Enables teleportation
  43612. */
  43613. export class WebXRControllerTeleportation {
  43614. private _teleportationFillColor;
  43615. private _teleportationBorderColor;
  43616. private _tmpRay;
  43617. private _tmpVector;
  43618. /**
  43619. * when set to true (default) teleportation will wait for thumbstick changes.
  43620. * When set to false teleportation will be disabled.
  43621. *
  43622. * If set to false while teleporting results can be unexpected.
  43623. */
  43624. enabled: boolean;
  43625. /**
  43626. * Creates a WebXRControllerTeleportation
  43627. * @param input input manager to add teleportation to
  43628. * @param floorMeshes floormeshes which can be teleported to
  43629. */
  43630. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. /**
  43635. * Button which can be used to enter a different mode of XR
  43636. */
  43637. export class WebXREnterExitUIButton {
  43638. /** button element */
  43639. element: HTMLElement;
  43640. /** XR initialization options for the button */
  43641. sessionMode: XRSessionMode;
  43642. /** Reference space type */
  43643. referenceSpaceType: XRReferenceSpaceType;
  43644. /**
  43645. * Creates a WebXREnterExitUIButton
  43646. * @param element button element
  43647. * @param sessionMode XR initialization session mode
  43648. * @param referenceSpaceType the type of reference space to be used
  43649. */
  43650. constructor(
  43651. /** button element */
  43652. element: HTMLElement,
  43653. /** XR initialization options for the button */
  43654. sessionMode: XRSessionMode,
  43655. /** Reference space type */
  43656. referenceSpaceType: XRReferenceSpaceType);
  43657. /**
  43658. * Overwritable function which can be used to update the button's visuals when the state changes
  43659. * @param activeButton the current active button in the UI
  43660. */
  43661. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43662. }
  43663. /**
  43664. * Options to create the webXR UI
  43665. */
  43666. export class WebXREnterExitUIOptions {
  43667. /**
  43668. * Context to enter xr with
  43669. */
  43670. renderTarget?: Nullable<WebXRRenderTarget>;
  43671. /**
  43672. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43673. */
  43674. customButtons?: Array<WebXREnterExitUIButton>;
  43675. /**
  43676. * A session mode to use when creating the default button.
  43677. * Default is immersive-vr
  43678. */
  43679. sessionMode?: XRSessionMode;
  43680. /**
  43681. * A reference space type to use when creating the default button.
  43682. * Default is local-floor
  43683. */
  43684. referenceSpaceType?: XRReferenceSpaceType;
  43685. }
  43686. /**
  43687. * UI to allow the user to enter/exit XR mode
  43688. */
  43689. export class WebXREnterExitUI implements IDisposable {
  43690. private scene;
  43691. /** version of the options passed to this UI */
  43692. options: WebXREnterExitUIOptions;
  43693. private _overlay;
  43694. private _buttons;
  43695. private _activeButton;
  43696. /**
  43697. * Fired every time the active button is changed.
  43698. *
  43699. * When xr is entered via a button that launches xr that button will be the callback parameter
  43700. *
  43701. * When exiting xr the callback parameter will be null)
  43702. */
  43703. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43704. /**
  43705. * Creates UI to allow the user to enter/exit XR mode
  43706. * @param scene the scene to add the ui to
  43707. * @param helper the xr experience helper to enter/exit xr with
  43708. * @param options options to configure the UI
  43709. * @returns the created ui
  43710. */
  43711. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43712. /**
  43713. *
  43714. * @param scene babylon scene object to use
  43715. * @param options (read-only) version of the options passed to this UI
  43716. */
  43717. private constructor();
  43718. private _updateButtons;
  43719. /**
  43720. * Disposes of the object
  43721. */
  43722. dispose(): void;
  43723. }
  43724. }
  43725. declare module BABYLON {
  43726. /**
  43727. * Options for the default xr helper
  43728. */
  43729. export class WebXRDefaultExperienceOptions {
  43730. /**
  43731. * Floor meshes that should be used for teleporting
  43732. */
  43733. floorMeshes: Array<AbstractMesh>;
  43734. /**
  43735. * Enable or disable default UI to enter XR
  43736. */
  43737. disableDefaultUI?: boolean;
  43738. /**
  43739. * optional configuration for the output canvas
  43740. */
  43741. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43742. /**
  43743. * optional UI options. This can be used among other to change session mode and reference space type
  43744. */
  43745. uiOptions?: WebXREnterExitUIOptions;
  43746. }
  43747. /**
  43748. * Default experience which provides a similar setup to the previous webVRExperience
  43749. */
  43750. export class WebXRDefaultExperience {
  43751. /**
  43752. * Base experience
  43753. */
  43754. baseExperience: WebXRExperienceHelper;
  43755. /**
  43756. * Input experience extension
  43757. */
  43758. input: WebXRInput;
  43759. /**
  43760. * Loads the controller models
  43761. */
  43762. controllerModelLoader: WebXRControllerModelLoader;
  43763. /**
  43764. * Enables laser pointer and selection
  43765. */
  43766. pointerSelection: WebXRControllerPointerSelection;
  43767. /**
  43768. * Enables teleportation
  43769. */
  43770. teleportation: WebXRControllerTeleportation;
  43771. /**
  43772. * Enables ui for entering/exiting xr
  43773. */
  43774. enterExitUI: WebXREnterExitUI;
  43775. /**
  43776. * Default target xr should render to
  43777. */
  43778. renderTarget: WebXRRenderTarget;
  43779. /**
  43780. * Creates the default xr experience
  43781. * @param scene scene
  43782. * @param options options for basic configuration
  43783. * @returns resulting WebXRDefaultExperience
  43784. */
  43785. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43786. private constructor();
  43787. /**
  43788. * DIsposes of the experience helper
  43789. */
  43790. dispose(): void;
  43791. }
  43792. }
  43793. declare module BABYLON {
  43794. /**
  43795. * Options to modify the vr teleportation behavior.
  43796. */
  43797. export interface VRTeleportationOptions {
  43798. /**
  43799. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43800. */
  43801. floorMeshName?: string;
  43802. /**
  43803. * A list of meshes to be used as the teleportation floor. (default: empty)
  43804. */
  43805. floorMeshes?: Mesh[];
  43806. /**
  43807. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43808. */
  43809. teleportationMode?: number;
  43810. /**
  43811. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43812. */
  43813. teleportationTime?: number;
  43814. /**
  43815. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43816. */
  43817. teleportationSpeed?: number;
  43818. /**
  43819. * The easing function used in the animation or null for Linear. (default CircleEase)
  43820. */
  43821. easingFunction?: EasingFunction;
  43822. }
  43823. /**
  43824. * Options to modify the vr experience helper's behavior.
  43825. */
  43826. export interface VRExperienceHelperOptions extends WebVROptions {
  43827. /**
  43828. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43829. */
  43830. createDeviceOrientationCamera?: boolean;
  43831. /**
  43832. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43833. */
  43834. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43835. /**
  43836. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43837. */
  43838. laserToggle?: boolean;
  43839. /**
  43840. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43841. */
  43842. floorMeshes?: Mesh[];
  43843. /**
  43844. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43845. */
  43846. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43847. /**
  43848. * Defines if WebXR should be used instead of WebVR (if available)
  43849. */
  43850. useXR?: boolean;
  43851. }
  43852. /**
  43853. * Event containing information after VR has been entered
  43854. */
  43855. export class OnAfterEnteringVRObservableEvent {
  43856. /**
  43857. * If entering vr was successful
  43858. */
  43859. success: boolean;
  43860. }
  43861. /**
  43862. * Helps to quickly add VR support to an existing scene.
  43863. * See http://doc.babylonjs.com/how_to/webvr_helper
  43864. */
  43865. export class VRExperienceHelper {
  43866. /** Options to modify the vr experience helper's behavior. */
  43867. webVROptions: VRExperienceHelperOptions;
  43868. private _scene;
  43869. private _position;
  43870. private _btnVR;
  43871. private _btnVRDisplayed;
  43872. private _webVRsupported;
  43873. private _webVRready;
  43874. private _webVRrequesting;
  43875. private _webVRpresenting;
  43876. private _hasEnteredVR;
  43877. private _fullscreenVRpresenting;
  43878. private _inputElement;
  43879. private _webVRCamera;
  43880. private _vrDeviceOrientationCamera;
  43881. private _deviceOrientationCamera;
  43882. private _existingCamera;
  43883. private _onKeyDown;
  43884. private _onVrDisplayPresentChange;
  43885. private _onVRDisplayChanged;
  43886. private _onVRRequestPresentStart;
  43887. private _onVRRequestPresentComplete;
  43888. /**
  43889. * 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)
  43890. */
  43891. enableGazeEvenWhenNoPointerLock: boolean;
  43892. /**
  43893. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43894. */
  43895. exitVROnDoubleTap: boolean;
  43896. /**
  43897. * Observable raised right before entering VR.
  43898. */
  43899. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43900. /**
  43901. * Observable raised when entering VR has completed.
  43902. */
  43903. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43904. /**
  43905. * Observable raised when exiting VR.
  43906. */
  43907. onExitingVRObservable: Observable<VRExperienceHelper>;
  43908. /**
  43909. * Observable raised when controller mesh is loaded.
  43910. */
  43911. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43912. /** Return this.onEnteringVRObservable
  43913. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43914. */
  43915. get onEnteringVR(): Observable<VRExperienceHelper>;
  43916. /** Return this.onExitingVRObservable
  43917. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43918. */
  43919. get onExitingVR(): Observable<VRExperienceHelper>;
  43920. /** Return this.onControllerMeshLoadedObservable
  43921. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43922. */
  43923. get onControllerMeshLoaded(): Observable<WebVRController>;
  43924. private _rayLength;
  43925. private _useCustomVRButton;
  43926. private _teleportationRequested;
  43927. private _teleportActive;
  43928. private _floorMeshName;
  43929. private _floorMeshesCollection;
  43930. private _teleportationMode;
  43931. private _teleportationTime;
  43932. private _teleportationSpeed;
  43933. private _teleportationEasing;
  43934. private _rotationAllowed;
  43935. private _teleportBackwardsVector;
  43936. private _teleportationTarget;
  43937. private _isDefaultTeleportationTarget;
  43938. private _postProcessMove;
  43939. private _teleportationFillColor;
  43940. private _teleportationBorderColor;
  43941. private _rotationAngle;
  43942. private _haloCenter;
  43943. private _cameraGazer;
  43944. private _padSensibilityUp;
  43945. private _padSensibilityDown;
  43946. private _leftController;
  43947. private _rightController;
  43948. private _gazeColor;
  43949. private _laserColor;
  43950. private _pickedLaserColor;
  43951. private _pickedGazeColor;
  43952. /**
  43953. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43954. */
  43955. onNewMeshSelected: Observable<AbstractMesh>;
  43956. /**
  43957. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43958. * This observable will provide the mesh and the controller used to select the mesh
  43959. */
  43960. onMeshSelectedWithController: Observable<{
  43961. mesh: AbstractMesh;
  43962. controller: WebVRController;
  43963. }>;
  43964. /**
  43965. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43966. */
  43967. onNewMeshPicked: Observable<PickingInfo>;
  43968. private _circleEase;
  43969. /**
  43970. * Observable raised before camera teleportation
  43971. */
  43972. onBeforeCameraTeleport: Observable<Vector3>;
  43973. /**
  43974. * Observable raised after camera teleportation
  43975. */
  43976. onAfterCameraTeleport: Observable<Vector3>;
  43977. /**
  43978. * Observable raised when current selected mesh gets unselected
  43979. */
  43980. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43981. private _raySelectionPredicate;
  43982. /**
  43983. * To be optionaly changed by user to define custom ray selection
  43984. */
  43985. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43986. /**
  43987. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43988. */
  43989. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43990. /**
  43991. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43992. */
  43993. teleportationEnabled: boolean;
  43994. private _defaultHeight;
  43995. private _teleportationInitialized;
  43996. private _interactionsEnabled;
  43997. private _interactionsRequested;
  43998. private _displayGaze;
  43999. private _displayLaserPointer;
  44000. /**
  44001. * The mesh used to display where the user is going to teleport.
  44002. */
  44003. get teleportationTarget(): Mesh;
  44004. /**
  44005. * Sets the mesh to be used to display where the user is going to teleport.
  44006. */
  44007. set teleportationTarget(value: Mesh);
  44008. /**
  44009. * 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
  44010. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44011. * See http://doc.babylonjs.com/resources/baking_transformations
  44012. */
  44013. get gazeTrackerMesh(): Mesh;
  44014. set gazeTrackerMesh(value: Mesh);
  44015. /**
  44016. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44017. */
  44018. updateGazeTrackerScale: boolean;
  44019. /**
  44020. * If the gaze trackers color should be updated when selecting meshes
  44021. */
  44022. updateGazeTrackerColor: boolean;
  44023. /**
  44024. * If the controller laser color should be updated when selecting meshes
  44025. */
  44026. updateControllerLaserColor: boolean;
  44027. /**
  44028. * The gaze tracking mesh corresponding to the left controller
  44029. */
  44030. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44031. /**
  44032. * The gaze tracking mesh corresponding to the right controller
  44033. */
  44034. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44035. /**
  44036. * If the ray of the gaze should be displayed.
  44037. */
  44038. get displayGaze(): boolean;
  44039. /**
  44040. * Sets if the ray of the gaze should be displayed.
  44041. */
  44042. set displayGaze(value: boolean);
  44043. /**
  44044. * If the ray of the LaserPointer should be displayed.
  44045. */
  44046. get displayLaserPointer(): boolean;
  44047. /**
  44048. * Sets if the ray of the LaserPointer should be displayed.
  44049. */
  44050. set displayLaserPointer(value: boolean);
  44051. /**
  44052. * The deviceOrientationCamera used as the camera when not in VR.
  44053. */
  44054. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44055. /**
  44056. * Based on the current WebVR support, returns the current VR camera used.
  44057. */
  44058. get currentVRCamera(): Nullable<Camera>;
  44059. /**
  44060. * The webVRCamera which is used when in VR.
  44061. */
  44062. get webVRCamera(): WebVRFreeCamera;
  44063. /**
  44064. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44065. */
  44066. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44067. /**
  44068. * The html button that is used to trigger entering into VR.
  44069. */
  44070. get vrButton(): Nullable<HTMLButtonElement>;
  44071. private get _teleportationRequestInitiated();
  44072. /**
  44073. * Defines wether or not Pointer lock should be requested when switching to
  44074. * full screen.
  44075. */
  44076. requestPointerLockOnFullScreen: boolean;
  44077. /**
  44078. * If asking to force XR, this will be populated with the default xr experience
  44079. */
  44080. xr: WebXRDefaultExperience;
  44081. /**
  44082. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44083. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44084. */
  44085. xrTestDone: boolean;
  44086. /**
  44087. * Instantiates a VRExperienceHelper.
  44088. * Helps to quickly add VR support to an existing scene.
  44089. * @param scene The scene the VRExperienceHelper belongs to.
  44090. * @param webVROptions Options to modify the vr experience helper's behavior.
  44091. */
  44092. constructor(scene: Scene,
  44093. /** Options to modify the vr experience helper's behavior. */
  44094. webVROptions?: VRExperienceHelperOptions);
  44095. private completeVRInit;
  44096. private _onDefaultMeshLoaded;
  44097. private _onResize;
  44098. private _onFullscreenChange;
  44099. /**
  44100. * Gets a value indicating if we are currently in VR mode.
  44101. */
  44102. get isInVRMode(): boolean;
  44103. private onVrDisplayPresentChange;
  44104. private onVRDisplayChanged;
  44105. private moveButtonToBottomRight;
  44106. private displayVRButton;
  44107. private updateButtonVisibility;
  44108. private _cachedAngularSensibility;
  44109. /**
  44110. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44111. * Otherwise, will use the fullscreen API.
  44112. */
  44113. enterVR(): void;
  44114. /**
  44115. * Attempt to exit VR, or fullscreen.
  44116. */
  44117. exitVR(): void;
  44118. /**
  44119. * The position of the vr experience helper.
  44120. */
  44121. get position(): Vector3;
  44122. /**
  44123. * Sets the position of the vr experience helper.
  44124. */
  44125. set position(value: Vector3);
  44126. /**
  44127. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44128. */
  44129. enableInteractions(): void;
  44130. private get _noControllerIsActive();
  44131. private beforeRender;
  44132. private _isTeleportationFloor;
  44133. /**
  44134. * Adds a floor mesh to be used for teleportation.
  44135. * @param floorMesh the mesh to be used for teleportation.
  44136. */
  44137. addFloorMesh(floorMesh: Mesh): void;
  44138. /**
  44139. * Removes a floor mesh from being used for teleportation.
  44140. * @param floorMesh the mesh to be removed.
  44141. */
  44142. removeFloorMesh(floorMesh: Mesh): void;
  44143. /**
  44144. * Enables interactions and teleportation using the VR controllers and gaze.
  44145. * @param vrTeleportationOptions options to modify teleportation behavior.
  44146. */
  44147. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44148. private _onNewGamepadConnected;
  44149. private _tryEnableInteractionOnController;
  44150. private _onNewGamepadDisconnected;
  44151. private _enableInteractionOnController;
  44152. private _checkTeleportWithRay;
  44153. private _checkRotate;
  44154. private _checkTeleportBackwards;
  44155. private _enableTeleportationOnController;
  44156. private _createTeleportationCircles;
  44157. private _displayTeleportationTarget;
  44158. private _hideTeleportationTarget;
  44159. private _rotateCamera;
  44160. private _moveTeleportationSelectorTo;
  44161. private _workingVector;
  44162. private _workingQuaternion;
  44163. private _workingMatrix;
  44164. /**
  44165. * Time Constant Teleportation Mode
  44166. */
  44167. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44168. /**
  44169. * Speed Constant Teleportation Mode
  44170. */
  44171. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44172. /**
  44173. * Teleports the users feet to the desired location
  44174. * @param location The location where the user's feet should be placed
  44175. */
  44176. teleportCamera(location: Vector3): void;
  44177. private _convertNormalToDirectionOfRay;
  44178. private _castRayAndSelectObject;
  44179. private _notifySelectedMeshUnselected;
  44180. /**
  44181. * Permanently set new colors for the laser pointer
  44182. * @param color the new laser color
  44183. * @param pickedColor the new laser color when picked mesh detected
  44184. */
  44185. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44186. /**
  44187. * Permanently set new colors for the gaze pointer
  44188. * @param color the new gaze color
  44189. * @param pickedColor the new gaze color when picked mesh detected
  44190. */
  44191. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44192. /**
  44193. * Sets the color of the laser ray from the vr controllers.
  44194. * @param color new color for the ray.
  44195. */
  44196. changeLaserColor(color: Color3): void;
  44197. /**
  44198. * Sets the color of the ray from the vr headsets gaze.
  44199. * @param color new color for the ray.
  44200. */
  44201. changeGazeColor(color: Color3): void;
  44202. /**
  44203. * Exits VR and disposes of the vr experience helper
  44204. */
  44205. dispose(): void;
  44206. /**
  44207. * Gets the name of the VRExperienceHelper class
  44208. * @returns "VRExperienceHelper"
  44209. */
  44210. getClassName(): string;
  44211. }
  44212. }
  44213. declare module BABYLON {
  44214. /**
  44215. * Options used for hit testing
  44216. */
  44217. export interface IWebXRHitTestOptions {
  44218. /**
  44219. * Only test when user interacted with the scene. Default - hit test every frame
  44220. */
  44221. testOnPointerDownOnly?: boolean;
  44222. /**
  44223. * The node to use to transform the local results to world coordinates
  44224. */
  44225. worldParentNode?: TransformNode;
  44226. }
  44227. /**
  44228. * Interface defining the babylon result of raycasting/hit-test
  44229. */
  44230. export interface IWebXRHitResult {
  44231. /**
  44232. * The native hit test result
  44233. */
  44234. xrHitResult: XRHitResult;
  44235. /**
  44236. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44237. */
  44238. transformationMatrix: Matrix;
  44239. }
  44240. /**
  44241. * The currently-working hit-test module.
  44242. * Hit test (or raycasting) is used to interact with the real world.
  44243. * For further information read here - https://github.com/immersive-web/hit-test
  44244. */
  44245. export class WebXRHitTestLegacy implements IWebXRFeature {
  44246. private _xrSessionManager;
  44247. /**
  44248. * options to use when constructing this feature
  44249. */
  44250. readonly options: IWebXRHitTestOptions;
  44251. /**
  44252. * The module's name
  44253. */
  44254. static readonly Name: string;
  44255. /**
  44256. * The (Babylon) version of this module.
  44257. * This is an integer representing the implementation version.
  44258. * This number does not correspond to the webxr specs version
  44259. */
  44260. static readonly Version: number;
  44261. /**
  44262. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44263. * @param event the (select) event to use to select with
  44264. * @param referenceSpace the reference space to use for this hit test
  44265. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44266. */
  44267. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44268. /**
  44269. * execute a hit test with an XR Ray
  44270. *
  44271. * @param xrSession a native xrSession that will execute this hit test
  44272. * @param xrRay the ray (position and direction) to use for raycasting
  44273. * @param referenceSpace native XR reference space to use for the hit-test
  44274. * @param filter filter function that will filter the results
  44275. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44276. */
  44277. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44278. /**
  44279. * Triggered when new babylon (transformed) hit test results are available
  44280. */
  44281. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44282. /**
  44283. * Creates a new instance of the (legacy version) hit test feature
  44284. * @param _xrSessionManager an instance of WebXRSessionManager
  44285. * @param options options to use when constructing this feature
  44286. */
  44287. constructor(_xrSessionManager: WebXRSessionManager,
  44288. /**
  44289. * options to use when constructing this feature
  44290. */
  44291. options?: IWebXRHitTestOptions);
  44292. private _onSelectEnabled;
  44293. private _xrFrameObserver;
  44294. private _attached;
  44295. /**
  44296. * Populated with the last native XR Hit Results
  44297. */
  44298. lastNativeXRHitResults: XRHitResult[];
  44299. /**
  44300. * attach this feature
  44301. * Will usually be called by the features manager
  44302. *
  44303. * @returns true if successful.
  44304. */
  44305. attach(): boolean;
  44306. /**
  44307. * detach this feature.
  44308. * Will usually be called by the features manager
  44309. *
  44310. * @returns true if successful.
  44311. */
  44312. detach(): boolean;
  44313. private _onHitTestResults;
  44314. private _onSelect;
  44315. /**
  44316. * Dispose this feature and all of the resources attached
  44317. */
  44318. dispose(): void;
  44319. }
  44320. }
  44321. declare module BABYLON {
  44322. /**
  44323. * Options used in the plane detector module
  44324. */
  44325. export interface IWebXRPlaneDetectorOptions {
  44326. /**
  44327. * The node to use to transform the local results to world coordinates
  44328. */
  44329. worldParentNode?: TransformNode;
  44330. }
  44331. /**
  44332. * A babylon interface for a webxr plane.
  44333. * A Plane is actually a polygon, built from N points in space
  44334. */
  44335. export interface IWebXRPlane {
  44336. /**
  44337. * a babylon-assigned ID for this polygon
  44338. */
  44339. id: number;
  44340. /**
  44341. * the native xr-plane object
  44342. */
  44343. xrPlane: XRPlane;
  44344. /**
  44345. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44346. */
  44347. polygonDefinition: Array<Vector3>;
  44348. /**
  44349. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44350. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44351. */
  44352. transformationMatrix: Matrix;
  44353. }
  44354. /**
  44355. * The plane detector is used to detect planes in the real world when in AR
  44356. * For more information see https://github.com/immersive-web/real-world-geometry/
  44357. */
  44358. export class WebXRPlaneDetector implements IWebXRFeature {
  44359. private _xrSessionManager;
  44360. private _options;
  44361. /**
  44362. * The module's name
  44363. */
  44364. static readonly Name: string;
  44365. /**
  44366. * The (Babylon) version of this module.
  44367. * This is an integer representing the implementation version.
  44368. * This number does not correspond to the webxr specs version
  44369. */
  44370. static readonly Version: number;
  44371. /**
  44372. * Observers registered here will be executed when a new plane was added to the session
  44373. */
  44374. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44375. /**
  44376. * Observers registered here will be executed when a plane is no longer detected in the session
  44377. */
  44378. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44379. /**
  44380. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44381. * This can execute N times every frame
  44382. */
  44383. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44384. private _enabled;
  44385. private _attached;
  44386. private _detectedPlanes;
  44387. private _lastFrameDetected;
  44388. private _observerTracked;
  44389. /**
  44390. * construct a new Plane Detector
  44391. * @param _xrSessionManager an instance of xr Session manager
  44392. * @param _options configuration to use when constructing this feature
  44393. */
  44394. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44395. /**
  44396. * attach this feature
  44397. * Will usually be called by the features manager
  44398. *
  44399. * @returns true if successful.
  44400. */
  44401. attach(): boolean;
  44402. /**
  44403. * detach this feature.
  44404. * Will usually be called by the features manager
  44405. *
  44406. * @returns true if successful.
  44407. */
  44408. detach(): boolean;
  44409. /**
  44410. * Dispose this feature and all of the resources attached
  44411. */
  44412. dispose(): void;
  44413. private _updatePlaneWithXRPlane;
  44414. /**
  44415. * avoiding using Array.find for global support.
  44416. * @param xrPlane the plane to find in the array
  44417. */
  44418. private findIndexInPlaneArray;
  44419. }
  44420. }
  44421. declare module BABYLON {
  44422. /**
  44423. * Configuration options of the anchor system
  44424. */
  44425. export interface IWebXRAnchorSystemOptions {
  44426. /**
  44427. * a node that will be used to convert local to world coordinates
  44428. */
  44429. worldParentNode?: TransformNode;
  44430. /**
  44431. * should the anchor system use plane detection.
  44432. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44433. */
  44434. usePlaneDetection?: boolean;
  44435. /**
  44436. * Should a new anchor be added every time a select event is triggered
  44437. */
  44438. addAnchorOnSelect?: boolean;
  44439. }
  44440. /**
  44441. * A babylon container for an XR Anchor
  44442. */
  44443. export interface IWebXRAnchor {
  44444. /**
  44445. * A babylon-assigned ID for this anchor
  44446. */
  44447. id: number;
  44448. /**
  44449. * The native anchor object
  44450. */
  44451. xrAnchor: XRAnchor;
  44452. /**
  44453. * Transformation matrix to apply to an object attached to this anchor
  44454. */
  44455. transformationMatrix: Matrix;
  44456. }
  44457. /**
  44458. * An implementation of the anchor system of WebXR.
  44459. * Note that the current documented implementation is not available in any browser. Future implementations
  44460. * will use the frame to create an anchor and not the session or a detected plane
  44461. * For further information see https://github.com/immersive-web/anchors/
  44462. */
  44463. export class WebXRAnchorSystem implements IWebXRFeature {
  44464. private _xrSessionManager;
  44465. private _options;
  44466. /**
  44467. * The module's name
  44468. */
  44469. static readonly Name: string;
  44470. /**
  44471. * The (Babylon) version of this module.
  44472. * This is an integer representing the implementation version.
  44473. * This number does not correspond to the webxr specs version
  44474. */
  44475. static readonly Version: number;
  44476. /**
  44477. * Observers registered here will be executed when a new anchor was added to the session
  44478. */
  44479. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44480. /**
  44481. * Observers registered here will be executed when an existing anchor updates
  44482. * This can execute N times every frame
  44483. */
  44484. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44485. /**
  44486. * Observers registered here will be executed when an anchor was removed from the session
  44487. */
  44488. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44489. private _planeDetector;
  44490. private _hitTestModule;
  44491. private _enabled;
  44492. private _attached;
  44493. private _trackedAnchors;
  44494. private _lastFrameDetected;
  44495. private _observerTracked;
  44496. /**
  44497. * constructs a new anchor system
  44498. * @param _xrSessionManager an instance of WebXRSessionManager
  44499. * @param _options configuration object for this feature
  44500. */
  44501. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44502. /**
  44503. * set the plane detector to use in order to create anchors from frames
  44504. * @param planeDetector the plane-detector module to use
  44505. * @param enable enable plane-anchors. default is true
  44506. */
  44507. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44508. /**
  44509. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44510. * @param hitTestModule the hit-test module to use.
  44511. */
  44512. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44513. /**
  44514. * attach this feature
  44515. * Will usually be called by the features manager
  44516. *
  44517. * @returns true if successful.
  44518. */
  44519. attach(): boolean;
  44520. /**
  44521. * detach this feature.
  44522. * Will usually be called by the features manager
  44523. *
  44524. * @returns true if successful.
  44525. */
  44526. detach(): boolean;
  44527. /**
  44528. * Dispose this feature and all of the resources attached
  44529. */
  44530. dispose(): void;
  44531. private _onSelect;
  44532. /**
  44533. * Add anchor at a specific XR point.
  44534. *
  44535. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44536. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44537. * @returns a promise the fulfills when the anchor was created
  44538. */
  44539. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44540. private _updateAnchorWithXRFrame;
  44541. /**
  44542. * avoiding using Array.find for global support.
  44543. * @param xrAnchor the plane to find in the array
  44544. */
  44545. private _findIndexInAnchorArray;
  44546. }
  44547. }
  44548. declare module BABYLON {
  44549. /**
  44550. * Options interface for the background remover plugin
  44551. */
  44552. export interface IWebXRBackgroundRemoverOptions {
  44553. /**
  44554. * don't disable the environment helper
  44555. */
  44556. ignoreEnvironmentHelper?: boolean;
  44557. /**
  44558. * flags to configure the removal of the environment helper.
  44559. * If not set, the entire background will be removed. If set, flags should be set as well.
  44560. */
  44561. environmentHelperRemovalFlags?: {
  44562. /**
  44563. * Should the skybox be removed (default false)
  44564. */
  44565. skyBox?: boolean;
  44566. /**
  44567. * Should the ground be removed (default false)
  44568. */
  44569. ground?: boolean;
  44570. };
  44571. /**
  44572. * Further background meshes to disable when entering AR
  44573. */
  44574. backgroundMeshes?: AbstractMesh[];
  44575. }
  44576. /**
  44577. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44578. */
  44579. export class WebXRBackgroundRemover implements IWebXRFeature {
  44580. private _xrSessionManager;
  44581. /**
  44582. * read-only options to be used in this module
  44583. */
  44584. readonly options: IWebXRBackgroundRemoverOptions;
  44585. /**
  44586. * The module's name
  44587. */
  44588. static readonly Name: string;
  44589. /**
  44590. * The (Babylon) version of this module.
  44591. * This is an integer representing the implementation version.
  44592. * This number does not correspond to the webxr specs version
  44593. */
  44594. static readonly Version: number;
  44595. /**
  44596. * registered observers will be triggered when the background state changes
  44597. */
  44598. onBackgroundStateChangedObservable: Observable<boolean>;
  44599. /**
  44600. * constructs a new background remover module
  44601. * @param _xrSessionManager the session manager for this module
  44602. * @param options read-only options to be used in this module
  44603. */
  44604. constructor(_xrSessionManager: WebXRSessionManager,
  44605. /**
  44606. * read-only options to be used in this module
  44607. */
  44608. options?: IWebXRBackgroundRemoverOptions);
  44609. /**
  44610. * attach this feature
  44611. * Will usually be called by the features manager
  44612. *
  44613. * @returns true if successful.
  44614. */
  44615. attach(): boolean;
  44616. /**
  44617. * detach this feature.
  44618. * Will usually be called by the features manager
  44619. *
  44620. * @returns true if successful.
  44621. */
  44622. detach(): boolean;
  44623. private _setBackgroundState;
  44624. /**
  44625. * Dispose this feature and all of the resources attached
  44626. */
  44627. dispose(): void;
  44628. }
  44629. }
  44630. declare module BABYLON {
  44631. /**
  44632. * Contains an array of blocks representing the octree
  44633. */
  44634. export interface IOctreeContainer<T> {
  44635. /**
  44636. * Blocks within the octree
  44637. */
  44638. blocks: Array<OctreeBlock<T>>;
  44639. }
  44640. /**
  44641. * Class used to store a cell in an octree
  44642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44643. */
  44644. export class OctreeBlock<T> {
  44645. /**
  44646. * Gets the content of the current block
  44647. */
  44648. entries: T[];
  44649. /**
  44650. * Gets the list of block children
  44651. */
  44652. blocks: Array<OctreeBlock<T>>;
  44653. private _depth;
  44654. private _maxDepth;
  44655. private _capacity;
  44656. private _minPoint;
  44657. private _maxPoint;
  44658. private _boundingVectors;
  44659. private _creationFunc;
  44660. /**
  44661. * Creates a new block
  44662. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44663. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44664. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44665. * @param depth defines the current depth of this block in the octree
  44666. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44667. * @param creationFunc defines a callback to call when an element is added to the block
  44668. */
  44669. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44670. /**
  44671. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44672. */
  44673. get capacity(): number;
  44674. /**
  44675. * Gets the minimum vector (in world space) of the block's bounding box
  44676. */
  44677. get minPoint(): Vector3;
  44678. /**
  44679. * Gets the maximum vector (in world space) of the block's bounding box
  44680. */
  44681. get maxPoint(): Vector3;
  44682. /**
  44683. * Add a new element to this block
  44684. * @param entry defines the element to add
  44685. */
  44686. addEntry(entry: T): void;
  44687. /**
  44688. * Remove an element from this block
  44689. * @param entry defines the element to remove
  44690. */
  44691. removeEntry(entry: T): void;
  44692. /**
  44693. * Add an array of elements to this block
  44694. * @param entries defines the array of elements to add
  44695. */
  44696. addEntries(entries: T[]): void;
  44697. /**
  44698. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44699. * @param frustumPlanes defines the frustum planes to test
  44700. * @param selection defines the array to store current content if selection is positive
  44701. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44702. */
  44703. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44704. /**
  44705. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44706. * @param sphereCenter defines the bounding sphere center
  44707. * @param sphereRadius defines the bounding sphere radius
  44708. * @param selection defines the array to store current content if selection is positive
  44709. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44710. */
  44711. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44712. /**
  44713. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44714. * @param ray defines the ray to test with
  44715. * @param selection defines the array to store current content if selection is positive
  44716. */
  44717. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44718. /**
  44719. * Subdivide the content into child blocks (this block will then be empty)
  44720. */
  44721. createInnerBlocks(): void;
  44722. /**
  44723. * @hidden
  44724. */
  44725. 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;
  44726. }
  44727. }
  44728. declare module BABYLON {
  44729. /**
  44730. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44731. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44732. */
  44733. export class Octree<T> {
  44734. /** 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.) */
  44735. maxDepth: number;
  44736. /**
  44737. * Blocks within the octree containing objects
  44738. */
  44739. blocks: Array<OctreeBlock<T>>;
  44740. /**
  44741. * Content stored in the octree
  44742. */
  44743. dynamicContent: T[];
  44744. private _maxBlockCapacity;
  44745. private _selectionContent;
  44746. private _creationFunc;
  44747. /**
  44748. * Creates a octree
  44749. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44750. * @param creationFunc function to be used to instatiate the octree
  44751. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44752. * @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.)
  44753. */
  44754. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44755. /** 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.) */
  44756. maxDepth?: number);
  44757. /**
  44758. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44759. * @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);
  44760. * @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);
  44761. * @param entries meshes to be added to the octree blocks
  44762. */
  44763. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44764. /**
  44765. * Adds a mesh to the octree
  44766. * @param entry Mesh to add to the octree
  44767. */
  44768. addMesh(entry: T): void;
  44769. /**
  44770. * Remove an element from the octree
  44771. * @param entry defines the element to remove
  44772. */
  44773. removeMesh(entry: T): void;
  44774. /**
  44775. * Selects an array of meshes within the frustum
  44776. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44777. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44778. * @returns array of meshes within the frustum
  44779. */
  44780. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44781. /**
  44782. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44783. * @param sphereCenter defines the bounding sphere center
  44784. * @param sphereRadius defines the bounding sphere radius
  44785. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44786. * @returns an array of objects that intersect the sphere
  44787. */
  44788. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44789. /**
  44790. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44791. * @param ray defines the ray to test with
  44792. * @returns array of intersected objects
  44793. */
  44794. intersectsRay(ray: Ray): SmartArray<T>;
  44795. /**
  44796. * Adds a mesh into the octree block if it intersects the block
  44797. */
  44798. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44799. /**
  44800. * Adds a submesh into the octree block if it intersects the block
  44801. */
  44802. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44803. }
  44804. }
  44805. declare module BABYLON {
  44806. interface Scene {
  44807. /**
  44808. * @hidden
  44809. * Backing Filed
  44810. */
  44811. _selectionOctree: Octree<AbstractMesh>;
  44812. /**
  44813. * Gets the octree used to boost mesh selection (picking)
  44814. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44815. */
  44816. selectionOctree: Octree<AbstractMesh>;
  44817. /**
  44818. * Creates or updates the octree used to boost selection (picking)
  44819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44820. * @param maxCapacity defines the maximum capacity per leaf
  44821. * @param maxDepth defines the maximum depth of the octree
  44822. * @returns an octree of AbstractMesh
  44823. */
  44824. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44825. }
  44826. interface AbstractMesh {
  44827. /**
  44828. * @hidden
  44829. * Backing Field
  44830. */
  44831. _submeshesOctree: Octree<SubMesh>;
  44832. /**
  44833. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44834. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44835. * @param maxCapacity defines the maximum size of each block (64 by default)
  44836. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44837. * @returns the new octree
  44838. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44840. */
  44841. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44842. }
  44843. /**
  44844. * Defines the octree scene component responsible to manage any octrees
  44845. * in a given scene.
  44846. */
  44847. export class OctreeSceneComponent {
  44848. /**
  44849. * The component name help to identify the component in the list of scene components.
  44850. */
  44851. readonly name: string;
  44852. /**
  44853. * The scene the component belongs to.
  44854. */
  44855. scene: Scene;
  44856. /**
  44857. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44858. */
  44859. readonly checksIsEnabled: boolean;
  44860. /**
  44861. * Creates a new instance of the component for the given scene
  44862. * @param scene Defines the scene to register the component in
  44863. */
  44864. constructor(scene: Scene);
  44865. /**
  44866. * Registers the component in a given scene
  44867. */
  44868. register(): void;
  44869. /**
  44870. * Return the list of active meshes
  44871. * @returns the list of active meshes
  44872. */
  44873. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44874. /**
  44875. * Return the list of active sub meshes
  44876. * @param mesh The mesh to get the candidates sub meshes from
  44877. * @returns the list of active sub meshes
  44878. */
  44879. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44880. private _tempRay;
  44881. /**
  44882. * Return the list of sub meshes intersecting with a given local ray
  44883. * @param mesh defines the mesh to find the submesh for
  44884. * @param localRay defines the ray in local space
  44885. * @returns the list of intersecting sub meshes
  44886. */
  44887. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44888. /**
  44889. * Return the list of sub meshes colliding with a collider
  44890. * @param mesh defines the mesh to find the submesh for
  44891. * @param collider defines the collider to evaluate the collision against
  44892. * @returns the list of colliding sub meshes
  44893. */
  44894. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44895. /**
  44896. * Rebuilds the elements related to this component in case of
  44897. * context lost for instance.
  44898. */
  44899. rebuild(): void;
  44900. /**
  44901. * Disposes the component and the associated ressources.
  44902. */
  44903. dispose(): void;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /**
  44908. * Renders a layer on top of an existing scene
  44909. */
  44910. export class UtilityLayerRenderer implements IDisposable {
  44911. /** the original scene that will be rendered on top of */
  44912. originalScene: Scene;
  44913. private _pointerCaptures;
  44914. private _lastPointerEvents;
  44915. private static _DefaultUtilityLayer;
  44916. private static _DefaultKeepDepthUtilityLayer;
  44917. private _sharedGizmoLight;
  44918. private _renderCamera;
  44919. /**
  44920. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44921. * @returns the camera that is used when rendering the utility layer
  44922. */
  44923. getRenderCamera(): Nullable<Camera>;
  44924. /**
  44925. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44926. * @param cam the camera that should be used when rendering the utility layer
  44927. */
  44928. setRenderCamera(cam: Nullable<Camera>): void;
  44929. /**
  44930. * @hidden
  44931. * Light which used by gizmos to get light shading
  44932. */
  44933. _getSharedGizmoLight(): HemisphericLight;
  44934. /**
  44935. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44936. */
  44937. pickUtilitySceneFirst: boolean;
  44938. /**
  44939. * 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)
  44940. */
  44941. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44942. /**
  44943. * 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)
  44944. */
  44945. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44946. /**
  44947. * The scene that is rendered on top of the original scene
  44948. */
  44949. utilityLayerScene: Scene;
  44950. /**
  44951. * If the utility layer should automatically be rendered on top of existing scene
  44952. */
  44953. shouldRender: boolean;
  44954. /**
  44955. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44956. */
  44957. onlyCheckPointerDownEvents: boolean;
  44958. /**
  44959. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44960. */
  44961. processAllEvents: boolean;
  44962. /**
  44963. * Observable raised when the pointer move from the utility layer scene to the main scene
  44964. */
  44965. onPointerOutObservable: Observable<number>;
  44966. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44967. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44968. private _afterRenderObserver;
  44969. private _sceneDisposeObserver;
  44970. private _originalPointerObserver;
  44971. /**
  44972. * Instantiates a UtilityLayerRenderer
  44973. * @param originalScene the original scene that will be rendered on top of
  44974. * @param handleEvents boolean indicating if the utility layer should handle events
  44975. */
  44976. constructor(
  44977. /** the original scene that will be rendered on top of */
  44978. originalScene: Scene, handleEvents?: boolean);
  44979. private _notifyObservers;
  44980. /**
  44981. * Renders the utility layers scene on top of the original scene
  44982. */
  44983. render(): void;
  44984. /**
  44985. * Disposes of the renderer
  44986. */
  44987. dispose(): void;
  44988. private _updateCamera;
  44989. }
  44990. }
  44991. declare module BABYLON {
  44992. /**
  44993. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44994. */
  44995. export class Gizmo implements IDisposable {
  44996. /** The utility layer the gizmo will be added to */
  44997. gizmoLayer: UtilityLayerRenderer;
  44998. /**
  44999. * The root mesh of the gizmo
  45000. */
  45001. _rootMesh: Mesh;
  45002. private _attachedMesh;
  45003. /**
  45004. * Ratio for the scale of the gizmo (Default: 1)
  45005. */
  45006. scaleRatio: number;
  45007. /**
  45008. * If a custom mesh has been set (Default: false)
  45009. */
  45010. protected _customMeshSet: boolean;
  45011. /**
  45012. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45013. * * When set, interactions will be enabled
  45014. */
  45015. get attachedMesh(): Nullable<AbstractMesh>;
  45016. set attachedMesh(value: Nullable<AbstractMesh>);
  45017. /**
  45018. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45019. * @param mesh The mesh to replace the default mesh of the gizmo
  45020. */
  45021. setCustomMesh(mesh: Mesh): void;
  45022. /**
  45023. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45024. */
  45025. updateGizmoRotationToMatchAttachedMesh: boolean;
  45026. /**
  45027. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45028. */
  45029. updateGizmoPositionToMatchAttachedMesh: boolean;
  45030. /**
  45031. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45032. */
  45033. updateScale: boolean;
  45034. protected _interactionsEnabled: boolean;
  45035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45036. private _beforeRenderObserver;
  45037. private _tempVector;
  45038. /**
  45039. * Creates a gizmo
  45040. * @param gizmoLayer The utility layer the gizmo will be added to
  45041. */
  45042. constructor(
  45043. /** The utility layer the gizmo will be added to */
  45044. gizmoLayer?: UtilityLayerRenderer);
  45045. /**
  45046. * Updates the gizmo to match the attached mesh's position/rotation
  45047. */
  45048. protected _update(): void;
  45049. /**
  45050. * Disposes of the gizmo
  45051. */
  45052. dispose(): void;
  45053. }
  45054. }
  45055. declare module BABYLON {
  45056. /**
  45057. * Single plane drag gizmo
  45058. */
  45059. export class PlaneDragGizmo extends Gizmo {
  45060. /**
  45061. * Drag behavior responsible for the gizmos dragging interactions
  45062. */
  45063. dragBehavior: PointerDragBehavior;
  45064. private _pointerObserver;
  45065. /**
  45066. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45067. */
  45068. snapDistance: number;
  45069. /**
  45070. * Event that fires each time the gizmo snaps to a new location.
  45071. * * snapDistance is the the change in distance
  45072. */
  45073. onSnapObservable: Observable<{
  45074. snapDistance: number;
  45075. }>;
  45076. private _plane;
  45077. private _coloredMaterial;
  45078. private _hoverMaterial;
  45079. private _isEnabled;
  45080. private _parent;
  45081. /** @hidden */
  45082. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45083. /** @hidden */
  45084. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45085. /**
  45086. * Creates a PlaneDragGizmo
  45087. * @param gizmoLayer The utility layer the gizmo will be added to
  45088. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45089. * @param color The color of the gizmo
  45090. */
  45091. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45093. /**
  45094. * If the gizmo is enabled
  45095. */
  45096. set isEnabled(value: boolean);
  45097. get isEnabled(): boolean;
  45098. /**
  45099. * Disposes of the gizmo
  45100. */
  45101. dispose(): void;
  45102. }
  45103. }
  45104. declare module BABYLON {
  45105. /**
  45106. * Gizmo that enables dragging a mesh along 3 axis
  45107. */
  45108. export class PositionGizmo extends Gizmo {
  45109. /**
  45110. * Internal gizmo used for interactions on the x axis
  45111. */
  45112. xGizmo: AxisDragGizmo;
  45113. /**
  45114. * Internal gizmo used for interactions on the y axis
  45115. */
  45116. yGizmo: AxisDragGizmo;
  45117. /**
  45118. * Internal gizmo used for interactions on the z axis
  45119. */
  45120. zGizmo: AxisDragGizmo;
  45121. /**
  45122. * Internal gizmo used for interactions on the yz plane
  45123. */
  45124. xPlaneGizmo: PlaneDragGizmo;
  45125. /**
  45126. * Internal gizmo used for interactions on the xz plane
  45127. */
  45128. yPlaneGizmo: PlaneDragGizmo;
  45129. /**
  45130. * Internal gizmo used for interactions on the xy plane
  45131. */
  45132. zPlaneGizmo: PlaneDragGizmo;
  45133. /**
  45134. * private variables
  45135. */
  45136. private _meshAttached;
  45137. private _updateGizmoRotationToMatchAttachedMesh;
  45138. private _snapDistance;
  45139. private _scaleRatio;
  45140. /** Fires an event when any of it's sub gizmos are dragged */
  45141. onDragStartObservable: Observable<unknown>;
  45142. /** Fires an event when any of it's sub gizmos are released from dragging */
  45143. onDragEndObservable: Observable<unknown>;
  45144. /**
  45145. * If set to true, planar drag is enabled
  45146. */
  45147. private _planarGizmoEnabled;
  45148. get attachedMesh(): Nullable<AbstractMesh>;
  45149. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45150. /**
  45151. * Creates a PositionGizmo
  45152. * @param gizmoLayer The utility layer the gizmo will be added to
  45153. */
  45154. constructor(gizmoLayer?: UtilityLayerRenderer);
  45155. /**
  45156. * If the planar drag gizmo is enabled
  45157. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45158. */
  45159. set planarGizmoEnabled(value: boolean);
  45160. get planarGizmoEnabled(): boolean;
  45161. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45162. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45163. /**
  45164. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45165. */
  45166. set snapDistance(value: number);
  45167. get snapDistance(): number;
  45168. /**
  45169. * Ratio for the scale of the gizmo (Default: 1)
  45170. */
  45171. set scaleRatio(value: number);
  45172. get scaleRatio(): number;
  45173. /**
  45174. * Disposes of the gizmo
  45175. */
  45176. dispose(): void;
  45177. /**
  45178. * CustomMeshes are not supported by this gizmo
  45179. * @param mesh The mesh to replace the default mesh of the gizmo
  45180. */
  45181. setCustomMesh(mesh: Mesh): void;
  45182. }
  45183. }
  45184. declare module BABYLON {
  45185. /**
  45186. * Single axis drag gizmo
  45187. */
  45188. export class AxisDragGizmo extends Gizmo {
  45189. /**
  45190. * Drag behavior responsible for the gizmos dragging interactions
  45191. */
  45192. dragBehavior: PointerDragBehavior;
  45193. private _pointerObserver;
  45194. /**
  45195. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45196. */
  45197. snapDistance: number;
  45198. /**
  45199. * Event that fires each time the gizmo snaps to a new location.
  45200. * * snapDistance is the the change in distance
  45201. */
  45202. onSnapObservable: Observable<{
  45203. snapDistance: number;
  45204. }>;
  45205. private _isEnabled;
  45206. private _parent;
  45207. private _arrow;
  45208. private _coloredMaterial;
  45209. private _hoverMaterial;
  45210. /** @hidden */
  45211. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45212. /** @hidden */
  45213. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45214. /**
  45215. * Creates an AxisDragGizmo
  45216. * @param gizmoLayer The utility layer the gizmo will be added to
  45217. * @param dragAxis The axis which the gizmo will be able to drag on
  45218. * @param color The color of the gizmo
  45219. */
  45220. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45222. /**
  45223. * If the gizmo is enabled
  45224. */
  45225. set isEnabled(value: boolean);
  45226. get isEnabled(): boolean;
  45227. /**
  45228. * Disposes of the gizmo
  45229. */
  45230. dispose(): void;
  45231. }
  45232. }
  45233. declare module BABYLON.Debug {
  45234. /**
  45235. * The Axes viewer will show 3 axes in a specific point in space
  45236. */
  45237. export class AxesViewer {
  45238. private _xAxis;
  45239. private _yAxis;
  45240. private _zAxis;
  45241. private _scaleLinesFactor;
  45242. private _instanced;
  45243. /**
  45244. * Gets the hosting scene
  45245. */
  45246. scene: Scene;
  45247. /**
  45248. * Gets or sets a number used to scale line length
  45249. */
  45250. scaleLines: number;
  45251. /** Gets the node hierarchy used to render x-axis */
  45252. get xAxis(): TransformNode;
  45253. /** Gets the node hierarchy used to render y-axis */
  45254. get yAxis(): TransformNode;
  45255. /** Gets the node hierarchy used to render z-axis */
  45256. get zAxis(): TransformNode;
  45257. /**
  45258. * Creates a new AxesViewer
  45259. * @param scene defines the hosting scene
  45260. * @param scaleLines defines a number used to scale line length (1 by default)
  45261. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45262. * @param xAxis defines the node hierarchy used to render the x-axis
  45263. * @param yAxis defines the node hierarchy used to render the y-axis
  45264. * @param zAxis defines the node hierarchy used to render the z-axis
  45265. */
  45266. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45267. /**
  45268. * Force the viewer to update
  45269. * @param position defines the position of the viewer
  45270. * @param xaxis defines the x axis of the viewer
  45271. * @param yaxis defines the y axis of the viewer
  45272. * @param zaxis defines the z axis of the viewer
  45273. */
  45274. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45275. /**
  45276. * Creates an instance of this axes viewer.
  45277. * @returns a new axes viewer with instanced meshes
  45278. */
  45279. createInstance(): AxesViewer;
  45280. /** Releases resources */
  45281. dispose(): void;
  45282. private static _SetRenderingGroupId;
  45283. }
  45284. }
  45285. declare module BABYLON.Debug {
  45286. /**
  45287. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45288. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45289. */
  45290. export class BoneAxesViewer extends AxesViewer {
  45291. /**
  45292. * Gets or sets the target mesh where to display the axes viewer
  45293. */
  45294. mesh: Nullable<Mesh>;
  45295. /**
  45296. * Gets or sets the target bone where to display the axes viewer
  45297. */
  45298. bone: Nullable<Bone>;
  45299. /** Gets current position */
  45300. pos: Vector3;
  45301. /** Gets direction of X axis */
  45302. xaxis: Vector3;
  45303. /** Gets direction of Y axis */
  45304. yaxis: Vector3;
  45305. /** Gets direction of Z axis */
  45306. zaxis: Vector3;
  45307. /**
  45308. * Creates a new BoneAxesViewer
  45309. * @param scene defines the hosting scene
  45310. * @param bone defines the target bone
  45311. * @param mesh defines the target mesh
  45312. * @param scaleLines defines a scaling factor for line length (1 by default)
  45313. */
  45314. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45315. /**
  45316. * Force the viewer to update
  45317. */
  45318. update(): void;
  45319. /** Releases resources */
  45320. dispose(): void;
  45321. }
  45322. }
  45323. declare module BABYLON {
  45324. /**
  45325. * Interface used to define scene explorer extensibility option
  45326. */
  45327. export interface IExplorerExtensibilityOption {
  45328. /**
  45329. * Define the option label
  45330. */
  45331. label: string;
  45332. /**
  45333. * Defines the action to execute on click
  45334. */
  45335. action: (entity: any) => void;
  45336. }
  45337. /**
  45338. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45339. */
  45340. export interface IExplorerExtensibilityGroup {
  45341. /**
  45342. * Defines a predicate to test if a given type mut be extended
  45343. */
  45344. predicate: (entity: any) => boolean;
  45345. /**
  45346. * Gets the list of options added to a type
  45347. */
  45348. entries: IExplorerExtensibilityOption[];
  45349. }
  45350. /**
  45351. * Interface used to define the options to use to create the Inspector
  45352. */
  45353. export interface IInspectorOptions {
  45354. /**
  45355. * Display in overlay mode (default: false)
  45356. */
  45357. overlay?: boolean;
  45358. /**
  45359. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45360. */
  45361. globalRoot?: HTMLElement;
  45362. /**
  45363. * Display the Scene explorer
  45364. */
  45365. showExplorer?: boolean;
  45366. /**
  45367. * Display the property inspector
  45368. */
  45369. showInspector?: boolean;
  45370. /**
  45371. * Display in embed mode (both panes on the right)
  45372. */
  45373. embedMode?: boolean;
  45374. /**
  45375. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45376. */
  45377. handleResize?: boolean;
  45378. /**
  45379. * Allow the panes to popup (default: true)
  45380. */
  45381. enablePopup?: boolean;
  45382. /**
  45383. * Allow the panes to be closed by users (default: true)
  45384. */
  45385. enableClose?: boolean;
  45386. /**
  45387. * Optional list of extensibility entries
  45388. */
  45389. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45390. /**
  45391. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45392. */
  45393. inspectorURL?: string;
  45394. /**
  45395. * Optional initial tab (default to DebugLayerTab.Properties)
  45396. */
  45397. initialTab?: DebugLayerTab;
  45398. }
  45399. interface Scene {
  45400. /**
  45401. * @hidden
  45402. * Backing field
  45403. */
  45404. _debugLayer: DebugLayer;
  45405. /**
  45406. * Gets the debug layer (aka Inspector) associated with the scene
  45407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45408. */
  45409. debugLayer: DebugLayer;
  45410. }
  45411. /**
  45412. * Enum of inspector action tab
  45413. */
  45414. export enum DebugLayerTab {
  45415. /**
  45416. * Properties tag (default)
  45417. */
  45418. Properties = 0,
  45419. /**
  45420. * Debug tab
  45421. */
  45422. Debug = 1,
  45423. /**
  45424. * Statistics tab
  45425. */
  45426. Statistics = 2,
  45427. /**
  45428. * Tools tab
  45429. */
  45430. Tools = 3,
  45431. /**
  45432. * Settings tab
  45433. */
  45434. Settings = 4
  45435. }
  45436. /**
  45437. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45438. * what is happening in your scene
  45439. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45440. */
  45441. export class DebugLayer {
  45442. /**
  45443. * Define the url to get the inspector script from.
  45444. * By default it uses the babylonjs CDN.
  45445. * @ignoreNaming
  45446. */
  45447. static InspectorURL: string;
  45448. private _scene;
  45449. private BJSINSPECTOR;
  45450. private _onPropertyChangedObservable?;
  45451. /**
  45452. * Observable triggered when a property is changed through the inspector.
  45453. */
  45454. get onPropertyChangedObservable(): any;
  45455. /**
  45456. * Instantiates a new debug layer.
  45457. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45458. * what is happening in your scene
  45459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45460. * @param scene Defines the scene to inspect
  45461. */
  45462. constructor(scene: Scene);
  45463. /** Creates the inspector window. */
  45464. private _createInspector;
  45465. /**
  45466. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45467. * @param entity defines the entity to select
  45468. * @param lineContainerTitle defines the specific block to highlight
  45469. */
  45470. select(entity: any, lineContainerTitle?: string): void;
  45471. /** Get the inspector from bundle or global */
  45472. private _getGlobalInspector;
  45473. /**
  45474. * Get if the inspector is visible or not.
  45475. * @returns true if visible otherwise, false
  45476. */
  45477. isVisible(): boolean;
  45478. /**
  45479. * Hide the inspector and close its window.
  45480. */
  45481. hide(): void;
  45482. /**
  45483. * Launch the debugLayer.
  45484. * @param config Define the configuration of the inspector
  45485. * @return a promise fulfilled when the debug layer is visible
  45486. */
  45487. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45488. }
  45489. }
  45490. declare module BABYLON {
  45491. /**
  45492. * Class containing static functions to help procedurally build meshes
  45493. */
  45494. export class BoxBuilder {
  45495. /**
  45496. * Creates a box mesh
  45497. * * The parameter `size` sets the size (float) of each box side (default 1)
  45498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45499. * * 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)
  45500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45502. * * 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
  45503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45505. * @param name defines the name of the mesh
  45506. * @param options defines the options used to create the mesh
  45507. * @param scene defines the hosting scene
  45508. * @returns the box mesh
  45509. */
  45510. static CreateBox(name: string, options: {
  45511. size?: number;
  45512. width?: number;
  45513. height?: number;
  45514. depth?: number;
  45515. faceUV?: Vector4[];
  45516. faceColors?: Color4[];
  45517. sideOrientation?: number;
  45518. frontUVs?: Vector4;
  45519. backUVs?: Vector4;
  45520. wrap?: boolean;
  45521. topBaseAt?: number;
  45522. bottomBaseAt?: number;
  45523. updatable?: boolean;
  45524. }, scene?: Nullable<Scene>): Mesh;
  45525. }
  45526. }
  45527. declare module BABYLON {
  45528. /**
  45529. * Class containing static functions to help procedurally build meshes
  45530. */
  45531. export class SphereBuilder {
  45532. /**
  45533. * Creates a sphere mesh
  45534. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45535. * * 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`)
  45536. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45537. * * 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
  45538. * * 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)
  45539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45540. * * 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
  45541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45542. * @param name defines the name of the mesh
  45543. * @param options defines the options used to create the mesh
  45544. * @param scene defines the hosting scene
  45545. * @returns the sphere mesh
  45546. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45547. */
  45548. static CreateSphere(name: string, options: {
  45549. segments?: number;
  45550. diameter?: number;
  45551. diameterX?: number;
  45552. diameterY?: number;
  45553. diameterZ?: number;
  45554. arc?: number;
  45555. slice?: number;
  45556. sideOrientation?: number;
  45557. frontUVs?: Vector4;
  45558. backUVs?: Vector4;
  45559. updatable?: boolean;
  45560. }, scene?: Nullable<Scene>): Mesh;
  45561. }
  45562. }
  45563. declare module BABYLON.Debug {
  45564. /**
  45565. * Used to show the physics impostor around the specific mesh
  45566. */
  45567. export class PhysicsViewer {
  45568. /** @hidden */
  45569. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45570. /** @hidden */
  45571. protected _meshes: Array<Nullable<AbstractMesh>>;
  45572. /** @hidden */
  45573. protected _scene: Nullable<Scene>;
  45574. /** @hidden */
  45575. protected _numMeshes: number;
  45576. /** @hidden */
  45577. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45578. private _renderFunction;
  45579. private _utilityLayer;
  45580. private _debugBoxMesh;
  45581. private _debugSphereMesh;
  45582. private _debugCylinderMesh;
  45583. private _debugMaterial;
  45584. private _debugMeshMeshes;
  45585. /**
  45586. * Creates a new PhysicsViewer
  45587. * @param scene defines the hosting scene
  45588. */
  45589. constructor(scene: Scene);
  45590. /** @hidden */
  45591. protected _updateDebugMeshes(): void;
  45592. /**
  45593. * Renders a specified physic impostor
  45594. * @param impostor defines the impostor to render
  45595. * @param targetMesh defines the mesh represented by the impostor
  45596. * @returns the new debug mesh used to render the impostor
  45597. */
  45598. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45599. /**
  45600. * Hides a specified physic impostor
  45601. * @param impostor defines the impostor to hide
  45602. */
  45603. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45604. private _getDebugMaterial;
  45605. private _getDebugBoxMesh;
  45606. private _getDebugSphereMesh;
  45607. private _getDebugCylinderMesh;
  45608. private _getDebugMeshMesh;
  45609. private _getDebugMesh;
  45610. /** Releases all resources */
  45611. dispose(): void;
  45612. }
  45613. }
  45614. declare module BABYLON {
  45615. /**
  45616. * Class containing static functions to help procedurally build meshes
  45617. */
  45618. export class LinesBuilder {
  45619. /**
  45620. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45621. * * 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
  45622. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45623. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45624. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45625. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45626. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45627. * * 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
  45628. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45631. * @param name defines the name of the new line system
  45632. * @param options defines the options used to create the line system
  45633. * @param scene defines the hosting scene
  45634. * @returns a new line system mesh
  45635. */
  45636. static CreateLineSystem(name: string, options: {
  45637. lines: Vector3[][];
  45638. updatable?: boolean;
  45639. instance?: Nullable<LinesMesh>;
  45640. colors?: Nullable<Color4[][]>;
  45641. useVertexAlpha?: boolean;
  45642. }, scene: Nullable<Scene>): LinesMesh;
  45643. /**
  45644. * Creates a line mesh
  45645. * 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
  45646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45647. * * The parameter `points` is an array successive Vector3
  45648. * * 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
  45649. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45650. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45651. * * When updating an instance, remember that only point positions can change, not the number of points
  45652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45654. * @param name defines the name of the new line system
  45655. * @param options defines the options used to create the line system
  45656. * @param scene defines the hosting scene
  45657. * @returns a new line mesh
  45658. */
  45659. static CreateLines(name: string, options: {
  45660. points: Vector3[];
  45661. updatable?: boolean;
  45662. instance?: Nullable<LinesMesh>;
  45663. colors?: Color4[];
  45664. useVertexAlpha?: boolean;
  45665. }, scene?: Nullable<Scene>): LinesMesh;
  45666. /**
  45667. * Creates a dashed line mesh
  45668. * * 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
  45669. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45670. * * The parameter `points` is an array successive Vector3
  45671. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45672. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45673. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45674. * * 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
  45675. * * When updating an instance, remember that only point positions can change, not the number of points
  45676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45677. * @param name defines the name of the mesh
  45678. * @param options defines the options used to create the mesh
  45679. * @param scene defines the hosting scene
  45680. * @returns the dashed line mesh
  45681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45682. */
  45683. static CreateDashedLines(name: string, options: {
  45684. points: Vector3[];
  45685. dashSize?: number;
  45686. gapSize?: number;
  45687. dashNb?: number;
  45688. updatable?: boolean;
  45689. instance?: LinesMesh;
  45690. }, scene?: Nullable<Scene>): LinesMesh;
  45691. }
  45692. }
  45693. declare module BABYLON {
  45694. /**
  45695. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45696. * in order to better appreciate the issue one might have.
  45697. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45698. */
  45699. export class RayHelper {
  45700. /**
  45701. * Defines the ray we are currently tryin to visualize.
  45702. */
  45703. ray: Nullable<Ray>;
  45704. private _renderPoints;
  45705. private _renderLine;
  45706. private _renderFunction;
  45707. private _scene;
  45708. private _updateToMeshFunction;
  45709. private _attachedToMesh;
  45710. private _meshSpaceDirection;
  45711. private _meshSpaceOrigin;
  45712. /**
  45713. * Helper function to create a colored helper in a scene in one line.
  45714. * @param ray Defines the ray we are currently tryin to visualize
  45715. * @param scene Defines the scene the ray is used in
  45716. * @param color Defines the color we want to see the ray in
  45717. * @returns The newly created ray helper.
  45718. */
  45719. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45720. /**
  45721. * Instantiate a new ray helper.
  45722. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45723. * in order to better appreciate the issue one might have.
  45724. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45725. * @param ray Defines the ray we are currently tryin to visualize
  45726. */
  45727. constructor(ray: Ray);
  45728. /**
  45729. * Shows the ray we are willing to debug.
  45730. * @param scene Defines the scene the ray needs to be rendered in
  45731. * @param color Defines the color the ray needs to be rendered in
  45732. */
  45733. show(scene: Scene, color?: Color3): void;
  45734. /**
  45735. * Hides the ray we are debugging.
  45736. */
  45737. hide(): void;
  45738. private _render;
  45739. /**
  45740. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45741. * @param mesh Defines the mesh we want the helper attached to
  45742. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45743. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45744. * @param length Defines the length of the ray
  45745. */
  45746. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45747. /**
  45748. * Detach the ray helper from the mesh it has previously been attached to.
  45749. */
  45750. detachFromMesh(): void;
  45751. private _updateToMesh;
  45752. /**
  45753. * Dispose the helper and release its associated resources.
  45754. */
  45755. dispose(): void;
  45756. }
  45757. }
  45758. declare module BABYLON.Debug {
  45759. /**
  45760. * Class used to render a debug view of a given skeleton
  45761. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45762. */
  45763. export class SkeletonViewer {
  45764. /** defines the skeleton to render */
  45765. skeleton: Skeleton;
  45766. /** defines the mesh attached to the skeleton */
  45767. mesh: AbstractMesh;
  45768. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45769. autoUpdateBonesMatrices: boolean;
  45770. /** defines the rendering group id to use with the viewer */
  45771. renderingGroupId: number;
  45772. /** Gets or sets the color used to render the skeleton */
  45773. color: Color3;
  45774. private _scene;
  45775. private _debugLines;
  45776. private _debugMesh;
  45777. private _isEnabled;
  45778. private _renderFunction;
  45779. private _utilityLayer;
  45780. /**
  45781. * Returns the mesh used to render the bones
  45782. */
  45783. get debugMesh(): Nullable<LinesMesh>;
  45784. /**
  45785. * Creates a new SkeletonViewer
  45786. * @param skeleton defines the skeleton to render
  45787. * @param mesh defines the mesh attached to the skeleton
  45788. * @param scene defines the hosting scene
  45789. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45790. * @param renderingGroupId defines the rendering group id to use with the viewer
  45791. */
  45792. constructor(
  45793. /** defines the skeleton to render */
  45794. skeleton: Skeleton,
  45795. /** defines the mesh attached to the skeleton */
  45796. mesh: AbstractMesh, scene: Scene,
  45797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45798. autoUpdateBonesMatrices?: boolean,
  45799. /** defines the rendering group id to use with the viewer */
  45800. renderingGroupId?: number);
  45801. /** Gets or sets a boolean indicating if the viewer is enabled */
  45802. set isEnabled(value: boolean);
  45803. get isEnabled(): boolean;
  45804. private _getBonePosition;
  45805. private _getLinesForBonesWithLength;
  45806. private _getLinesForBonesNoLength;
  45807. /** Update the viewer to sync with current skeleton state */
  45808. update(): void;
  45809. /** Release associated resources */
  45810. dispose(): void;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * Options to create the null engine
  45816. */
  45817. export class NullEngineOptions {
  45818. /**
  45819. * Render width (Default: 512)
  45820. */
  45821. renderWidth: number;
  45822. /**
  45823. * Render height (Default: 256)
  45824. */
  45825. renderHeight: number;
  45826. /**
  45827. * Texture size (Default: 512)
  45828. */
  45829. textureSize: number;
  45830. /**
  45831. * If delta time between frames should be constant
  45832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45833. */
  45834. deterministicLockstep: boolean;
  45835. /**
  45836. * Maximum about of steps between frames (Default: 4)
  45837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45838. */
  45839. lockstepMaxSteps: number;
  45840. }
  45841. /**
  45842. * The null engine class provides support for headless version of babylon.js.
  45843. * This can be used in server side scenario or for testing purposes
  45844. */
  45845. export class NullEngine extends Engine {
  45846. private _options;
  45847. /**
  45848. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45849. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45850. * @returns true if engine is in deterministic lock step mode
  45851. */
  45852. isDeterministicLockStep(): boolean;
  45853. /**
  45854. * Gets the max steps when engine is running in deterministic lock step
  45855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45856. * @returns the max steps
  45857. */
  45858. getLockstepMaxSteps(): number;
  45859. /**
  45860. * Gets the current hardware scaling level.
  45861. * By default the hardware scaling level is computed from the window device ratio.
  45862. * 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.
  45863. * @returns a number indicating the current hardware scaling level
  45864. */
  45865. getHardwareScalingLevel(): number;
  45866. constructor(options?: NullEngineOptions);
  45867. /**
  45868. * Creates a vertex buffer
  45869. * @param vertices the data for the vertex buffer
  45870. * @returns the new WebGL static buffer
  45871. */
  45872. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45873. /**
  45874. * Creates a new index buffer
  45875. * @param indices defines the content of the index buffer
  45876. * @param updatable defines if the index buffer must be updatable
  45877. * @returns a new webGL buffer
  45878. */
  45879. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45880. /**
  45881. * Clear the current render buffer or the current render target (if any is set up)
  45882. * @param color defines the color to use
  45883. * @param backBuffer defines if the back buffer must be cleared
  45884. * @param depth defines if the depth buffer must be cleared
  45885. * @param stencil defines if the stencil buffer must be cleared
  45886. */
  45887. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45888. /**
  45889. * Gets the current render width
  45890. * @param useScreen defines if screen size must be used (or the current render target if any)
  45891. * @returns a number defining the current render width
  45892. */
  45893. getRenderWidth(useScreen?: boolean): number;
  45894. /**
  45895. * Gets the current render height
  45896. * @param useScreen defines if screen size must be used (or the current render target if any)
  45897. * @returns a number defining the current render height
  45898. */
  45899. getRenderHeight(useScreen?: boolean): number;
  45900. /**
  45901. * Set the WebGL's viewport
  45902. * @param viewport defines the viewport element to be used
  45903. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45904. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45905. */
  45906. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45907. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45908. /**
  45909. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45910. * @param pipelineContext defines the pipeline context to use
  45911. * @param uniformsNames defines the list of uniform names
  45912. * @returns an array of webGL uniform locations
  45913. */
  45914. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45915. /**
  45916. * Gets the lsit of active attributes for a given webGL program
  45917. * @param pipelineContext defines the pipeline context to use
  45918. * @param attributesNames defines the list of attribute names to get
  45919. * @returns an array of indices indicating the offset of each attribute
  45920. */
  45921. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45922. /**
  45923. * Binds an effect to the webGL context
  45924. * @param effect defines the effect to bind
  45925. */
  45926. bindSamplers(effect: Effect): void;
  45927. /**
  45928. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45929. * @param effect defines the effect to activate
  45930. */
  45931. enableEffect(effect: Effect): void;
  45932. /**
  45933. * Set various states to the webGL context
  45934. * @param culling defines backface culling state
  45935. * @param zOffset defines the value to apply to zOffset (0 by default)
  45936. * @param force defines if states must be applied even if cache is up to date
  45937. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45938. */
  45939. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45940. /**
  45941. * Set the value of an uniform to an array of int32
  45942. * @param uniform defines the webGL uniform location where to store the value
  45943. * @param array defines the array of int32 to store
  45944. */
  45945. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45946. /**
  45947. * Set the value of an uniform to an array of int32 (stored as vec2)
  45948. * @param uniform defines the webGL uniform location where to store the value
  45949. * @param array defines the array of int32 to store
  45950. */
  45951. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45952. /**
  45953. * Set the value of an uniform to an array of int32 (stored as vec3)
  45954. * @param uniform defines the webGL uniform location where to store the value
  45955. * @param array defines the array of int32 to store
  45956. */
  45957. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45958. /**
  45959. * Set the value of an uniform to an array of int32 (stored as vec4)
  45960. * @param uniform defines the webGL uniform location where to store the value
  45961. * @param array defines the array of int32 to store
  45962. */
  45963. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45964. /**
  45965. * Set the value of an uniform to an array of float32
  45966. * @param uniform defines the webGL uniform location where to store the value
  45967. * @param array defines the array of float32 to store
  45968. */
  45969. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45970. /**
  45971. * Set the value of an uniform to an array of float32 (stored as vec2)
  45972. * @param uniform defines the webGL uniform location where to store the value
  45973. * @param array defines the array of float32 to store
  45974. */
  45975. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45976. /**
  45977. * Set the value of an uniform to an array of float32 (stored as vec3)
  45978. * @param uniform defines the webGL uniform location where to store the value
  45979. * @param array defines the array of float32 to store
  45980. */
  45981. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45982. /**
  45983. * Set the value of an uniform to an array of float32 (stored as vec4)
  45984. * @param uniform defines the webGL uniform location where to store the value
  45985. * @param array defines the array of float32 to store
  45986. */
  45987. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45988. /**
  45989. * Set the value of an uniform to an array of number
  45990. * @param uniform defines the webGL uniform location where to store the value
  45991. * @param array defines the array of number to store
  45992. */
  45993. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45994. /**
  45995. * Set the value of an uniform to an array of number (stored as vec2)
  45996. * @param uniform defines the webGL uniform location where to store the value
  45997. * @param array defines the array of number to store
  45998. */
  45999. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46000. /**
  46001. * Set the value of an uniform to an array of number (stored as vec3)
  46002. * @param uniform defines the webGL uniform location where to store the value
  46003. * @param array defines the array of number to store
  46004. */
  46005. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46006. /**
  46007. * Set the value of an uniform to an array of number (stored as vec4)
  46008. * @param uniform defines the webGL uniform location where to store the value
  46009. * @param array defines the array of number to store
  46010. */
  46011. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46012. /**
  46013. * Set the value of an uniform to an array of float32 (stored as matrices)
  46014. * @param uniform defines the webGL uniform location where to store the value
  46015. * @param matrices defines the array of float32 to store
  46016. */
  46017. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46018. /**
  46019. * Set the value of an uniform to a matrix (3x3)
  46020. * @param uniform defines the webGL uniform location where to store the value
  46021. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46022. */
  46023. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46024. /**
  46025. * Set the value of an uniform to a matrix (2x2)
  46026. * @param uniform defines the webGL uniform location where to store the value
  46027. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46028. */
  46029. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46030. /**
  46031. * Set the value of an uniform to a number (float)
  46032. * @param uniform defines the webGL uniform location where to store the value
  46033. * @param value defines the float number to store
  46034. */
  46035. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46036. /**
  46037. * Set the value of an uniform to a vec2
  46038. * @param uniform defines the webGL uniform location where to store the value
  46039. * @param x defines the 1st component of the value
  46040. * @param y defines the 2nd component of the value
  46041. */
  46042. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46043. /**
  46044. * Set the value of an uniform to a vec3
  46045. * @param uniform defines the webGL uniform location where to store the value
  46046. * @param x defines the 1st component of the value
  46047. * @param y defines the 2nd component of the value
  46048. * @param z defines the 3rd component of the value
  46049. */
  46050. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46051. /**
  46052. * Set the value of an uniform to a boolean
  46053. * @param uniform defines the webGL uniform location where to store the value
  46054. * @param bool defines the boolean to store
  46055. */
  46056. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46057. /**
  46058. * Set the value of an uniform to a vec4
  46059. * @param uniform defines the webGL uniform location where to store the value
  46060. * @param x defines the 1st component of the value
  46061. * @param y defines the 2nd component of the value
  46062. * @param z defines the 3rd component of the value
  46063. * @param w defines the 4th component of the value
  46064. */
  46065. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46066. /**
  46067. * Sets the current alpha mode
  46068. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46069. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46071. */
  46072. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46073. /**
  46074. * Bind webGl buffers directly to the webGL context
  46075. * @param vertexBuffers defines the vertex buffer to bind
  46076. * @param indexBuffer defines the index buffer to bind
  46077. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46078. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46079. * @param effect defines the effect associated with the vertex buffer
  46080. */
  46081. bindBuffers(vertexBuffers: {
  46082. [key: string]: VertexBuffer;
  46083. }, indexBuffer: DataBuffer, effect: Effect): void;
  46084. /**
  46085. * Force the entire cache to be cleared
  46086. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46087. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46088. */
  46089. wipeCaches(bruteForce?: boolean): void;
  46090. /**
  46091. * Send a draw order
  46092. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46093. * @param indexStart defines the starting index
  46094. * @param indexCount defines the number of index to draw
  46095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46096. */
  46097. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46098. /**
  46099. * Draw a list of indexed primitives
  46100. * @param fillMode defines the primitive to use
  46101. * @param indexStart defines the starting index
  46102. * @param indexCount defines the number of index to draw
  46103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46104. */
  46105. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46106. /**
  46107. * Draw a list of unindexed primitives
  46108. * @param fillMode defines the primitive to use
  46109. * @param verticesStart defines the index of first vertex to draw
  46110. * @param verticesCount defines the count of vertices to draw
  46111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46112. */
  46113. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46114. /** @hidden */
  46115. _createTexture(): WebGLTexture;
  46116. /** @hidden */
  46117. _releaseTexture(texture: InternalTexture): void;
  46118. /**
  46119. * Usually called from Texture.ts.
  46120. * Passed information to create a WebGLTexture
  46121. * @param urlArg defines a value which contains one of the following:
  46122. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46123. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46124. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46125. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46126. * @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)
  46127. * @param scene needed for loading to the correct scene
  46128. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46129. * @param onLoad optional callback to be called upon successful completion
  46130. * @param onError optional callback to be called upon failure
  46131. * @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
  46132. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46133. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46134. * @param forcedExtension defines the extension to use to pick the right loader
  46135. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46136. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46137. */
  46138. 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;
  46139. /**
  46140. * Creates a new render target texture
  46141. * @param size defines the size of the texture
  46142. * @param options defines the options used to create the texture
  46143. * @returns a new render target texture stored in an InternalTexture
  46144. */
  46145. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46146. /**
  46147. * Update the sampling mode of a given texture
  46148. * @param samplingMode defines the required sampling mode
  46149. * @param texture defines the texture to update
  46150. */
  46151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46152. /**
  46153. * Binds the frame buffer to the specified texture.
  46154. * @param texture The texture to render to or null for the default canvas
  46155. * @param faceIndex The face of the texture to render to in case of cube texture
  46156. * @param requiredWidth The width of the target to render to
  46157. * @param requiredHeight The height of the target to render to
  46158. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46159. * @param depthStencilTexture The depth stencil texture to use to render
  46160. * @param lodLevel defines le lod level to bind to the frame buffer
  46161. */
  46162. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46163. /**
  46164. * Unbind the current render target texture from the webGL context
  46165. * @param texture defines the render target texture to unbind
  46166. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46167. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46168. */
  46169. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46170. /**
  46171. * Creates a dynamic vertex buffer
  46172. * @param vertices the data for the dynamic vertex buffer
  46173. * @returns the new WebGL dynamic buffer
  46174. */
  46175. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46176. /**
  46177. * Update the content of a dynamic texture
  46178. * @param texture defines the texture to update
  46179. * @param canvas defines the canvas containing the source
  46180. * @param invertY defines if data must be stored with Y axis inverted
  46181. * @param premulAlpha defines if alpha is stored as premultiplied
  46182. * @param format defines the format of the data
  46183. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46184. */
  46185. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46186. /**
  46187. * Gets a boolean indicating if all created effects are ready
  46188. * @returns true if all effects are ready
  46189. */
  46190. areAllEffectsReady(): boolean;
  46191. /**
  46192. * @hidden
  46193. * Get the current error code of the webGL context
  46194. * @returns the error code
  46195. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46196. */
  46197. getError(): number;
  46198. /** @hidden */
  46199. _getUnpackAlignement(): number;
  46200. /** @hidden */
  46201. _unpackFlipY(value: boolean): void;
  46202. /**
  46203. * Update a dynamic index buffer
  46204. * @param indexBuffer defines the target index buffer
  46205. * @param indices defines the data to update
  46206. * @param offset defines the offset in the target index buffer where update should start
  46207. */
  46208. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46209. /**
  46210. * Updates a dynamic vertex buffer.
  46211. * @param vertexBuffer the vertex buffer to update
  46212. * @param vertices the data used to update the vertex buffer
  46213. * @param byteOffset the byte offset of the data (optional)
  46214. * @param byteLength the byte length of the data (optional)
  46215. */
  46216. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46217. /** @hidden */
  46218. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46219. /** @hidden */
  46220. _bindTexture(channel: number, texture: InternalTexture): void;
  46221. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46222. /**
  46223. * 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
  46224. */
  46225. releaseEffects(): void;
  46226. displayLoadingUI(): void;
  46227. hideLoadingUI(): void;
  46228. /** @hidden */
  46229. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46230. /** @hidden */
  46231. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46232. /** @hidden */
  46233. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46234. /** @hidden */
  46235. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46236. }
  46237. }
  46238. declare module BABYLON {
  46239. /** @hidden */
  46240. export class _OcclusionDataStorage {
  46241. /** @hidden */
  46242. occlusionInternalRetryCounter: number;
  46243. /** @hidden */
  46244. isOcclusionQueryInProgress: boolean;
  46245. /** @hidden */
  46246. isOccluded: boolean;
  46247. /** @hidden */
  46248. occlusionRetryCount: number;
  46249. /** @hidden */
  46250. occlusionType: number;
  46251. /** @hidden */
  46252. occlusionQueryAlgorithmType: number;
  46253. }
  46254. interface Engine {
  46255. /**
  46256. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46257. * @return the new query
  46258. */
  46259. createQuery(): WebGLQuery;
  46260. /**
  46261. * Delete and release a webGL query
  46262. * @param query defines the query to delete
  46263. * @return the current engine
  46264. */
  46265. deleteQuery(query: WebGLQuery): Engine;
  46266. /**
  46267. * Check if a given query has resolved and got its value
  46268. * @param query defines the query to check
  46269. * @returns true if the query got its value
  46270. */
  46271. isQueryResultAvailable(query: WebGLQuery): boolean;
  46272. /**
  46273. * Gets the value of a given query
  46274. * @param query defines the query to check
  46275. * @returns the value of the query
  46276. */
  46277. getQueryResult(query: WebGLQuery): number;
  46278. /**
  46279. * Initiates an occlusion query
  46280. * @param algorithmType defines the algorithm to use
  46281. * @param query defines the query to use
  46282. * @returns the current engine
  46283. * @see http://doc.babylonjs.com/features/occlusionquery
  46284. */
  46285. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46286. /**
  46287. * Ends an occlusion query
  46288. * @see http://doc.babylonjs.com/features/occlusionquery
  46289. * @param algorithmType defines the algorithm to use
  46290. * @returns the current engine
  46291. */
  46292. endOcclusionQuery(algorithmType: number): Engine;
  46293. /**
  46294. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46295. * Please note that only one query can be issued at a time
  46296. * @returns a time token used to track the time span
  46297. */
  46298. startTimeQuery(): Nullable<_TimeToken>;
  46299. /**
  46300. * Ends a time query
  46301. * @param token defines the token used to measure the time span
  46302. * @returns the time spent (in ns)
  46303. */
  46304. endTimeQuery(token: _TimeToken): int;
  46305. /** @hidden */
  46306. _currentNonTimestampToken: Nullable<_TimeToken>;
  46307. /** @hidden */
  46308. _createTimeQuery(): WebGLQuery;
  46309. /** @hidden */
  46310. _deleteTimeQuery(query: WebGLQuery): void;
  46311. /** @hidden */
  46312. _getGlAlgorithmType(algorithmType: number): number;
  46313. /** @hidden */
  46314. _getTimeQueryResult(query: WebGLQuery): any;
  46315. /** @hidden */
  46316. _getTimeQueryAvailability(query: WebGLQuery): any;
  46317. }
  46318. interface AbstractMesh {
  46319. /**
  46320. * Backing filed
  46321. * @hidden
  46322. */
  46323. __occlusionDataStorage: _OcclusionDataStorage;
  46324. /**
  46325. * Access property
  46326. * @hidden
  46327. */
  46328. _occlusionDataStorage: _OcclusionDataStorage;
  46329. /**
  46330. * 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.
  46331. * The default value is -1 which means don't break the query and wait till the result
  46332. * @see http://doc.babylonjs.com/features/occlusionquery
  46333. */
  46334. occlusionRetryCount: number;
  46335. /**
  46336. * 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:
  46337. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46338. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46339. * * 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.
  46340. * @see http://doc.babylonjs.com/features/occlusionquery
  46341. */
  46342. occlusionType: number;
  46343. /**
  46344. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46345. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46346. * * 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.
  46347. * @see http://doc.babylonjs.com/features/occlusionquery
  46348. */
  46349. occlusionQueryAlgorithmType: number;
  46350. /**
  46351. * 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
  46352. * @see http://doc.babylonjs.com/features/occlusionquery
  46353. */
  46354. isOccluded: boolean;
  46355. /**
  46356. * Flag to check the progress status of the query
  46357. * @see http://doc.babylonjs.com/features/occlusionquery
  46358. */
  46359. isOcclusionQueryInProgress: boolean;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /** @hidden */
  46364. export var _forceTransformFeedbackToBundle: boolean;
  46365. interface Engine {
  46366. /**
  46367. * Creates a webGL transform feedback object
  46368. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46369. * @returns the webGL transform feedback object
  46370. */
  46371. createTransformFeedback(): WebGLTransformFeedback;
  46372. /**
  46373. * Delete a webGL transform feedback object
  46374. * @param value defines the webGL transform feedback object to delete
  46375. */
  46376. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46377. /**
  46378. * Bind a webGL transform feedback object to the webgl context
  46379. * @param value defines the webGL transform feedback object to bind
  46380. */
  46381. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46382. /**
  46383. * Begins a transform feedback operation
  46384. * @param usePoints defines if points or triangles must be used
  46385. */
  46386. beginTransformFeedback(usePoints: boolean): void;
  46387. /**
  46388. * Ends a transform feedback operation
  46389. */
  46390. endTransformFeedback(): void;
  46391. /**
  46392. * Specify the varyings to use with transform feedback
  46393. * @param program defines the associated webGL program
  46394. * @param value defines the list of strings representing the varying names
  46395. */
  46396. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46397. /**
  46398. * Bind a webGL buffer for a transform feedback operation
  46399. * @param value defines the webGL buffer to bind
  46400. */
  46401. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46402. }
  46403. }
  46404. declare module BABYLON {
  46405. /**
  46406. * Creation options of the multi render target texture.
  46407. */
  46408. export interface IMultiRenderTargetOptions {
  46409. /**
  46410. * Define if the texture needs to create mip maps after render.
  46411. */
  46412. generateMipMaps?: boolean;
  46413. /**
  46414. * Define the types of all the draw buffers we want to create
  46415. */
  46416. types?: number[];
  46417. /**
  46418. * Define the sampling modes of all the draw buffers we want to create
  46419. */
  46420. samplingModes?: number[];
  46421. /**
  46422. * Define if a depth buffer is required
  46423. */
  46424. generateDepthBuffer?: boolean;
  46425. /**
  46426. * Define if a stencil buffer is required
  46427. */
  46428. generateStencilBuffer?: boolean;
  46429. /**
  46430. * Define if a depth texture is required instead of a depth buffer
  46431. */
  46432. generateDepthTexture?: boolean;
  46433. /**
  46434. * Define the number of desired draw buffers
  46435. */
  46436. textureCount?: number;
  46437. /**
  46438. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46439. */
  46440. doNotChangeAspectRatio?: boolean;
  46441. /**
  46442. * Define the default type of the buffers we are creating
  46443. */
  46444. defaultType?: number;
  46445. }
  46446. /**
  46447. * A multi render target, like a render target provides the ability to render to a texture.
  46448. * Unlike the render target, it can render to several draw buffers in one draw.
  46449. * This is specially interesting in deferred rendering or for any effects requiring more than
  46450. * just one color from a single pass.
  46451. */
  46452. export class MultiRenderTarget extends RenderTargetTexture {
  46453. private _internalTextures;
  46454. private _textures;
  46455. private _multiRenderTargetOptions;
  46456. /**
  46457. * Get if draw buffers are currently supported by the used hardware and browser.
  46458. */
  46459. get isSupported(): boolean;
  46460. /**
  46461. * Get the list of textures generated by the multi render target.
  46462. */
  46463. get textures(): Texture[];
  46464. /**
  46465. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46466. */
  46467. get depthTexture(): Texture;
  46468. /**
  46469. * Set the wrapping mode on U 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 wrapU(wrap: number);
  46473. /**
  46474. * Set the wrapping mode on V of all the textures we are rendering to.
  46475. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46476. */
  46477. set wrapV(wrap: number);
  46478. /**
  46479. * Instantiate a new multi render target texture.
  46480. * A multi render target, like a render target provides the ability to render to a texture.
  46481. * Unlike the render target, it can render to several draw buffers in one draw.
  46482. * This is specially interesting in deferred rendering or for any effects requiring more than
  46483. * just one color from a single pass.
  46484. * @param name Define the name of the texture
  46485. * @param size Define the size of the buffers to render to
  46486. * @param count Define the number of target we are rendering into
  46487. * @param scene Define the scene the texture belongs to
  46488. * @param options Define the options used to create the multi render target
  46489. */
  46490. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46491. /** @hidden */
  46492. _rebuild(): void;
  46493. private _createInternalTextures;
  46494. private _createTextures;
  46495. /**
  46496. * Define the number of samples used if MSAA is enabled.
  46497. */
  46498. get samples(): number;
  46499. set samples(value: number);
  46500. /**
  46501. * Resize all the textures in the multi render target.
  46502. * Be carrefull as it will recreate all the data in the new texture.
  46503. * @param size Define the new size
  46504. */
  46505. resize(size: any): void;
  46506. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46507. /**
  46508. * Dispose the render targets and their associated resources
  46509. */
  46510. dispose(): void;
  46511. /**
  46512. * Release all the underlying texture used as draw buffers.
  46513. */
  46514. releaseInternalTextures(): void;
  46515. }
  46516. }
  46517. declare module BABYLON {
  46518. interface ThinEngine {
  46519. /**
  46520. * Unbind a list of render target textures from the webGL context
  46521. * This is used only when drawBuffer extension or webGL2 are active
  46522. * @param textures defines the render target textures to unbind
  46523. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46524. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46525. */
  46526. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46527. /**
  46528. * Create a multi render target texture
  46529. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46530. * @param size defines the size of the texture
  46531. * @param options defines the creation options
  46532. * @returns the cube texture as an InternalTexture
  46533. */
  46534. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46535. /**
  46536. * Update the sample count for a given multiple render target texture
  46537. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46538. * @param textures defines the textures to update
  46539. * @param samples defines the sample count to set
  46540. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46541. */
  46542. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46543. }
  46544. }
  46545. declare module BABYLON {
  46546. /**
  46547. * Class used to define an additional view for the engine
  46548. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46549. */
  46550. export class EngineView {
  46551. /** Defines the canvas where to render the view */
  46552. target: HTMLCanvasElement;
  46553. /** Defines an optional camera used to render the view (will use active camera else) */
  46554. camera?: Camera;
  46555. }
  46556. interface Engine {
  46557. /**
  46558. * Gets or sets the HTML element to use for attaching events
  46559. */
  46560. inputElement: Nullable<HTMLElement>;
  46561. /**
  46562. * Gets the current engine view
  46563. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46564. */
  46565. activeView: Nullable<EngineView>;
  46566. /** Gets or sets the list of views */
  46567. views: EngineView[];
  46568. /**
  46569. * Register a new child canvas
  46570. * @param canvas defines the canvas to register
  46571. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46572. * @returns the associated view
  46573. */
  46574. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46575. /**
  46576. * Remove a registered child canvas
  46577. * @param canvas defines the canvas to remove
  46578. * @returns the current engine
  46579. */
  46580. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46581. }
  46582. }
  46583. declare module BABYLON {
  46584. /**
  46585. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46586. */
  46587. export interface CubeMapInfo {
  46588. /**
  46589. * The pixel array for the front face.
  46590. * This is stored in format, left to right, up to down format.
  46591. */
  46592. front: Nullable<ArrayBufferView>;
  46593. /**
  46594. * The pixel array for the back face.
  46595. * This is stored in format, left to right, up to down format.
  46596. */
  46597. back: Nullable<ArrayBufferView>;
  46598. /**
  46599. * The pixel array for the left face.
  46600. * This is stored in format, left to right, up to down format.
  46601. */
  46602. left: Nullable<ArrayBufferView>;
  46603. /**
  46604. * The pixel array for the right face.
  46605. * This is stored in format, left to right, up to down format.
  46606. */
  46607. right: Nullable<ArrayBufferView>;
  46608. /**
  46609. * The pixel array for the up face.
  46610. * This is stored in format, left to right, up to down format.
  46611. */
  46612. up: Nullable<ArrayBufferView>;
  46613. /**
  46614. * The pixel array for the down face.
  46615. * This is stored in format, left to right, up to down format.
  46616. */
  46617. down: Nullable<ArrayBufferView>;
  46618. /**
  46619. * The size of the cubemap stored.
  46620. *
  46621. * Each faces will be size * size pixels.
  46622. */
  46623. size: number;
  46624. /**
  46625. * The format of the texture.
  46626. *
  46627. * RGBA, RGB.
  46628. */
  46629. format: number;
  46630. /**
  46631. * The type of the texture data.
  46632. *
  46633. * UNSIGNED_INT, FLOAT.
  46634. */
  46635. type: number;
  46636. /**
  46637. * Specifies whether the texture is in gamma space.
  46638. */
  46639. gammaSpace: boolean;
  46640. }
  46641. /**
  46642. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46643. */
  46644. export class PanoramaToCubeMapTools {
  46645. private static FACE_FRONT;
  46646. private static FACE_BACK;
  46647. private static FACE_RIGHT;
  46648. private static FACE_LEFT;
  46649. private static FACE_DOWN;
  46650. private static FACE_UP;
  46651. /**
  46652. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46653. *
  46654. * @param float32Array The source data.
  46655. * @param inputWidth The width of the input panorama.
  46656. * @param inputHeight The height of the input panorama.
  46657. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46658. * @return The cubemap data
  46659. */
  46660. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46661. private static CreateCubemapTexture;
  46662. private static CalcProjectionSpherical;
  46663. }
  46664. }
  46665. declare module BABYLON {
  46666. /**
  46667. * Helper class dealing with the extraction of spherical polynomial dataArray
  46668. * from a cube map.
  46669. */
  46670. export class CubeMapToSphericalPolynomialTools {
  46671. private static FileFaces;
  46672. /**
  46673. * Converts a texture to the according Spherical Polynomial data.
  46674. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46675. *
  46676. * @param texture The texture to extract the information from.
  46677. * @return The Spherical Polynomial data.
  46678. */
  46679. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46680. /**
  46681. * Converts a cubemap to the according Spherical Polynomial data.
  46682. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46683. *
  46684. * @param cubeInfo The Cube map to extract the information from.
  46685. * @return The Spherical Polynomial data.
  46686. */
  46687. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46688. }
  46689. }
  46690. declare module BABYLON {
  46691. interface BaseTexture {
  46692. /**
  46693. * Get the polynomial representation of the texture data.
  46694. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46695. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46696. */
  46697. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46698. }
  46699. }
  46700. declare module BABYLON {
  46701. /** @hidden */
  46702. export var rgbdEncodePixelShader: {
  46703. name: string;
  46704. shader: string;
  46705. };
  46706. }
  46707. declare module BABYLON {
  46708. /** @hidden */
  46709. export var rgbdDecodePixelShader: {
  46710. name: string;
  46711. shader: string;
  46712. };
  46713. }
  46714. declare module BABYLON {
  46715. /**
  46716. * Raw texture data and descriptor sufficient for WebGL texture upload
  46717. */
  46718. export interface EnvironmentTextureInfo {
  46719. /**
  46720. * Version of the environment map
  46721. */
  46722. version: number;
  46723. /**
  46724. * Width of image
  46725. */
  46726. width: number;
  46727. /**
  46728. * Irradiance information stored in the file.
  46729. */
  46730. irradiance: any;
  46731. /**
  46732. * Specular information stored in the file.
  46733. */
  46734. specular: any;
  46735. }
  46736. /**
  46737. * Defines One Image in the file. It requires only the position in the file
  46738. * as well as the length.
  46739. */
  46740. interface BufferImageData {
  46741. /**
  46742. * Length of the image data.
  46743. */
  46744. length: number;
  46745. /**
  46746. * Position of the data from the null terminator delimiting the end of the JSON.
  46747. */
  46748. position: number;
  46749. }
  46750. /**
  46751. * Defines the specular data enclosed in the file.
  46752. * This corresponds to the version 1 of the data.
  46753. */
  46754. export interface EnvironmentTextureSpecularInfoV1 {
  46755. /**
  46756. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46757. */
  46758. specularDataPosition?: number;
  46759. /**
  46760. * This contains all the images data needed to reconstruct the cubemap.
  46761. */
  46762. mipmaps: Array<BufferImageData>;
  46763. /**
  46764. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46765. */
  46766. lodGenerationScale: number;
  46767. }
  46768. /**
  46769. * Sets of helpers addressing the serialization and deserialization of environment texture
  46770. * stored in a BabylonJS env file.
  46771. * Those files are usually stored as .env files.
  46772. */
  46773. export class EnvironmentTextureTools {
  46774. /**
  46775. * Magic number identifying the env file.
  46776. */
  46777. private static _MagicBytes;
  46778. /**
  46779. * Gets the environment info from an env file.
  46780. * @param data The array buffer containing the .env bytes.
  46781. * @returns the environment file info (the json header) if successfully parsed.
  46782. */
  46783. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46784. /**
  46785. * Creates an environment texture from a loaded cube texture.
  46786. * @param texture defines the cube texture to convert in env file
  46787. * @return a promise containing the environment data if succesfull.
  46788. */
  46789. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46790. /**
  46791. * Creates a JSON representation of the spherical data.
  46792. * @param texture defines the texture containing the polynomials
  46793. * @return the JSON representation of the spherical info
  46794. */
  46795. private static _CreateEnvTextureIrradiance;
  46796. /**
  46797. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46798. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46799. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46800. * @return the views described by info providing access to the underlying buffer
  46801. */
  46802. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46803. /**
  46804. * Uploads the texture info contained in the env file to the GPU.
  46805. * @param texture defines the internal texture to upload to
  46806. * @param arrayBuffer defines the buffer cotaining the data to load
  46807. * @param info defines the texture info retrieved through the GetEnvInfo method
  46808. * @returns a promise
  46809. */
  46810. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46811. private static _OnImageReadyAsync;
  46812. /**
  46813. * Uploads the levels of image data to the GPU.
  46814. * @param texture defines the internal texture to upload to
  46815. * @param imageData defines the array buffer views of image data [mipmap][face]
  46816. * @returns a promise
  46817. */
  46818. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46819. /**
  46820. * Uploads spherical polynomials information to the texture.
  46821. * @param texture defines the texture we are trying to upload the information to
  46822. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46823. */
  46824. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46825. /** @hidden */
  46826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46827. }
  46828. }
  46829. declare module BABYLON {
  46830. /**
  46831. * Contains position and normal vectors for a vertex
  46832. */
  46833. export class PositionNormalVertex {
  46834. /** the position of the vertex (defaut: 0,0,0) */
  46835. position: Vector3;
  46836. /** the normal of the vertex (defaut: 0,1,0) */
  46837. normal: Vector3;
  46838. /**
  46839. * Creates a PositionNormalVertex
  46840. * @param position the position of the vertex (defaut: 0,0,0)
  46841. * @param normal the normal of the vertex (defaut: 0,1,0)
  46842. */
  46843. constructor(
  46844. /** the position of the vertex (defaut: 0,0,0) */
  46845. position?: Vector3,
  46846. /** the normal of the vertex (defaut: 0,1,0) */
  46847. normal?: Vector3);
  46848. /**
  46849. * Clones the PositionNormalVertex
  46850. * @returns the cloned PositionNormalVertex
  46851. */
  46852. clone(): PositionNormalVertex;
  46853. }
  46854. /**
  46855. * Contains position, normal and uv vectors for a vertex
  46856. */
  46857. export class PositionNormalTextureVertex {
  46858. /** the position of the vertex (defaut: 0,0,0) */
  46859. position: Vector3;
  46860. /** the normal of the vertex (defaut: 0,1,0) */
  46861. normal: Vector3;
  46862. /** the uv of the vertex (default: 0,0) */
  46863. uv: Vector2;
  46864. /**
  46865. * Creates a PositionNormalTextureVertex
  46866. * @param position the position of the vertex (defaut: 0,0,0)
  46867. * @param normal the normal of the vertex (defaut: 0,1,0)
  46868. * @param uv the uv of the vertex (default: 0,0)
  46869. */
  46870. constructor(
  46871. /** the position of the vertex (defaut: 0,0,0) */
  46872. position?: Vector3,
  46873. /** the normal of the vertex (defaut: 0,1,0) */
  46874. normal?: Vector3,
  46875. /** the uv of the vertex (default: 0,0) */
  46876. uv?: Vector2);
  46877. /**
  46878. * Clones the PositionNormalTextureVertex
  46879. * @returns the cloned PositionNormalTextureVertex
  46880. */
  46881. clone(): PositionNormalTextureVertex;
  46882. }
  46883. }
  46884. declare module BABYLON {
  46885. /** @hidden */
  46886. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46887. private _genericAttributeLocation;
  46888. private _varyingLocationCount;
  46889. private _varyingLocationMap;
  46890. private _replacements;
  46891. private _textureCount;
  46892. private _uniforms;
  46893. lineProcessor(line: string): string;
  46894. attributeProcessor(attribute: string): string;
  46895. varyingProcessor(varying: string, isFragment: boolean): string;
  46896. uniformProcessor(uniform: string): string;
  46897. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46898. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46899. }
  46900. }
  46901. declare module BABYLON {
  46902. /**
  46903. * Container for accessors for natively-stored mesh data buffers.
  46904. */
  46905. class NativeDataBuffer extends DataBuffer {
  46906. /**
  46907. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46908. */
  46909. nativeIndexBuffer?: any;
  46910. /**
  46911. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46912. */
  46913. nativeVertexBuffer?: any;
  46914. }
  46915. /** @hidden */
  46916. class NativeTexture extends InternalTexture {
  46917. getInternalTexture(): InternalTexture;
  46918. getViewCount(): number;
  46919. }
  46920. /** @hidden */
  46921. export class NativeEngine extends Engine {
  46922. private readonly _native;
  46923. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46924. private readonly INVALID_HANDLE;
  46925. getHardwareScalingLevel(): number;
  46926. constructor();
  46927. /**
  46928. * Can be used to override the current requestAnimationFrame requester.
  46929. * @hidden
  46930. */
  46931. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46932. /**
  46933. * Override default engine behavior.
  46934. * @param color
  46935. * @param backBuffer
  46936. * @param depth
  46937. * @param stencil
  46938. */
  46939. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46940. /**
  46941. * Gets host document
  46942. * @returns the host document object
  46943. */
  46944. getHostDocument(): Nullable<Document>;
  46945. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46946. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46947. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46948. recordVertexArrayObject(vertexBuffers: {
  46949. [key: string]: VertexBuffer;
  46950. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46951. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46952. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46953. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46954. /**
  46955. * Draw a list of indexed primitives
  46956. * @param fillMode defines the primitive to use
  46957. * @param indexStart defines the starting index
  46958. * @param indexCount defines the number of index to draw
  46959. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46960. */
  46961. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46962. /**
  46963. * Draw a list of unindexed primitives
  46964. * @param fillMode defines the primitive to use
  46965. * @param verticesStart defines the index of first vertex to draw
  46966. * @param verticesCount defines the count of vertices to draw
  46967. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46968. */
  46969. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46970. createPipelineContext(): IPipelineContext;
  46971. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46972. /** @hidden */
  46973. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46974. /** @hidden */
  46975. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46976. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46977. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46978. protected _setProgram(program: WebGLProgram): void;
  46979. _releaseEffect(effect: Effect): void;
  46980. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46981. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46982. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46983. bindSamplers(effect: Effect): void;
  46984. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46985. getRenderWidth(useScreen?: boolean): number;
  46986. getRenderHeight(useScreen?: boolean): number;
  46987. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46988. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46989. /**
  46990. * Set the z offset to apply to current rendering
  46991. * @param value defines the offset to apply
  46992. */
  46993. setZOffset(value: number): void;
  46994. /**
  46995. * Gets the current value of the zOffset
  46996. * @returns the current zOffset state
  46997. */
  46998. getZOffset(): number;
  46999. /**
  47000. * Enable or disable depth buffering
  47001. * @param enable defines the state to set
  47002. */
  47003. setDepthBuffer(enable: boolean): void;
  47004. /**
  47005. * Gets a boolean indicating if depth writing is enabled
  47006. * @returns the current depth writing state
  47007. */
  47008. getDepthWrite(): boolean;
  47009. /**
  47010. * Enable or disable depth writing
  47011. * @param enable defines the state to set
  47012. */
  47013. setDepthWrite(enable: boolean): void;
  47014. /**
  47015. * Enable or disable color writing
  47016. * @param enable defines the state to set
  47017. */
  47018. setColorWrite(enable: boolean): void;
  47019. /**
  47020. * Gets a boolean indicating if color writing is enabled
  47021. * @returns the current color writing state
  47022. */
  47023. getColorWrite(): boolean;
  47024. /**
  47025. * Sets alpha constants used by some alpha blending modes
  47026. * @param r defines the red component
  47027. * @param g defines the green component
  47028. * @param b defines the blue component
  47029. * @param a defines the alpha component
  47030. */
  47031. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47032. /**
  47033. * Sets the current alpha mode
  47034. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47035. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47036. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47037. */
  47038. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47039. /**
  47040. * Gets the current alpha mode
  47041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47042. * @returns the current alpha mode
  47043. */
  47044. getAlphaMode(): number;
  47045. setInt(uniform: WebGLUniformLocation, int: number): void;
  47046. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47047. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47048. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47049. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47050. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47051. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47052. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47053. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47054. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47055. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47056. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47057. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47058. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47059. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47060. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47061. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47062. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47063. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47064. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47065. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47066. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47067. wipeCaches(bruteForce?: boolean): void;
  47068. _createTexture(): WebGLTexture;
  47069. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47070. /**
  47071. * Usually called from BABYLON.Texture.ts.
  47072. * Passed information to create a WebGLTexture
  47073. * @param urlArg defines a value which contains one of the following:
  47074. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47075. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47076. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47078. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47079. * @param scene needed for loading to the correct scene
  47080. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47081. * @param onLoad optional callback to be called upon successful completion
  47082. * @param onError optional callback to be called upon failure
  47083. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47084. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47085. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47086. * @param forcedExtension defines the extension to use to pick the right loader
  47087. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47088. */
  47089. 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;
  47090. /**
  47091. * Creates a cube texture
  47092. * @param rootUrl defines the url where the files to load is located
  47093. * @param scene defines the current scene
  47094. * @param files defines the list of files to load (1 per face)
  47095. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47096. * @param onLoad defines an optional callback raised when the texture is loaded
  47097. * @param onError defines an optional callback raised if there is an issue to load the texture
  47098. * @param format defines the format of the data
  47099. * @param forcedExtension defines the extension to use to pick the right loader
  47100. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47101. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47102. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47103. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47104. * @returns the cube texture as an InternalTexture
  47105. */
  47106. 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;
  47107. private _getSamplingFilter;
  47108. private static _GetNativeTextureFormat;
  47109. createRenderTargetTexture(size: number | {
  47110. width: number;
  47111. height: number;
  47112. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47113. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47114. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47115. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47116. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47117. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47118. /**
  47119. * Updates a dynamic vertex buffer.
  47120. * @param vertexBuffer the vertex buffer to update
  47121. * @param data the data used to update the vertex buffer
  47122. * @param byteOffset the byte offset of the data (optional)
  47123. * @param byteLength the byte length of the data (optional)
  47124. */
  47125. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47126. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47127. private _updateAnisotropicLevel;
  47128. private _getAddressMode;
  47129. /** @hidden */
  47130. _bindTexture(channel: number, texture: InternalTexture): void;
  47131. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47132. releaseEffects(): void;
  47133. /** @hidden */
  47134. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47135. /** @hidden */
  47136. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47137. /** @hidden */
  47138. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47139. /** @hidden */
  47140. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47141. }
  47142. }
  47143. declare module BABYLON {
  47144. /**
  47145. * Gather the list of clipboard event types as constants.
  47146. */
  47147. export class ClipboardEventTypes {
  47148. /**
  47149. * The clipboard event is fired when a copy command is active (pressed).
  47150. */
  47151. static readonly COPY: number;
  47152. /**
  47153. * The clipboard event is fired when a cut command is active (pressed).
  47154. */
  47155. static readonly CUT: number;
  47156. /**
  47157. * The clipboard event is fired when a paste command is active (pressed).
  47158. */
  47159. static readonly PASTE: number;
  47160. }
  47161. /**
  47162. * This class is used to store clipboard related info for the onClipboardObservable event.
  47163. */
  47164. export class ClipboardInfo {
  47165. /**
  47166. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47167. */
  47168. type: number;
  47169. /**
  47170. * Defines the related dom event
  47171. */
  47172. event: ClipboardEvent;
  47173. /**
  47174. *Creates an instance of ClipboardInfo.
  47175. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47176. * @param event Defines the related dom event
  47177. */
  47178. constructor(
  47179. /**
  47180. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47181. */
  47182. type: number,
  47183. /**
  47184. * Defines the related dom event
  47185. */
  47186. event: ClipboardEvent);
  47187. /**
  47188. * Get the clipboard event's type from the keycode.
  47189. * @param keyCode Defines the keyCode for the current keyboard event.
  47190. * @return {number}
  47191. */
  47192. static GetTypeFromCharacter(keyCode: number): number;
  47193. }
  47194. }
  47195. declare module BABYLON {
  47196. /**
  47197. * Google Daydream controller
  47198. */
  47199. export class DaydreamController extends WebVRController {
  47200. /**
  47201. * Base Url for the controller model.
  47202. */
  47203. static MODEL_BASE_URL: string;
  47204. /**
  47205. * File name for the controller model.
  47206. */
  47207. static MODEL_FILENAME: string;
  47208. /**
  47209. * Gamepad Id prefix used to identify Daydream Controller.
  47210. */
  47211. static readonly GAMEPAD_ID_PREFIX: string;
  47212. /**
  47213. * Creates a new DaydreamController from a gamepad
  47214. * @param vrGamepad the gamepad that the controller should be created from
  47215. */
  47216. constructor(vrGamepad: any);
  47217. /**
  47218. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47219. * @param scene scene in which to add meshes
  47220. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47221. */
  47222. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47223. /**
  47224. * Called once for each button that changed state since the last frame
  47225. * @param buttonIdx Which button index changed
  47226. * @param state New state of the button
  47227. * @param changes Which properties on the state changed since last frame
  47228. */
  47229. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47230. }
  47231. }
  47232. declare module BABYLON {
  47233. /**
  47234. * Gear VR Controller
  47235. */
  47236. export class GearVRController extends WebVRController {
  47237. /**
  47238. * Base Url for the controller model.
  47239. */
  47240. static MODEL_BASE_URL: string;
  47241. /**
  47242. * File name for the controller model.
  47243. */
  47244. static MODEL_FILENAME: string;
  47245. /**
  47246. * Gamepad Id prefix used to identify this controller.
  47247. */
  47248. static readonly GAMEPAD_ID_PREFIX: string;
  47249. private readonly _buttonIndexToObservableNameMap;
  47250. /**
  47251. * Creates a new GearVRController from a gamepad
  47252. * @param vrGamepad the gamepad that the controller should be created from
  47253. */
  47254. constructor(vrGamepad: any);
  47255. /**
  47256. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47257. * @param scene scene in which to add meshes
  47258. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47259. */
  47260. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47261. /**
  47262. * Called once for each button that changed state since the last frame
  47263. * @param buttonIdx Which button index changed
  47264. * @param state New state of the button
  47265. * @param changes Which properties on the state changed since last frame
  47266. */
  47267. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47268. }
  47269. }
  47270. declare module BABYLON {
  47271. /**
  47272. * Class containing static functions to help procedurally build meshes
  47273. */
  47274. export class PolyhedronBuilder {
  47275. /**
  47276. * Creates a polyhedron mesh
  47277. * * 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
  47278. * * The parameter `size` (positive float, default 1) sets the polygon size
  47279. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47280. * * 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`
  47281. * * 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
  47282. * * 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)`)
  47283. * * 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
  47284. * * 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
  47285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47286. * * 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
  47287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47288. * @param name defines the name of the mesh
  47289. * @param options defines the options used to create the mesh
  47290. * @param scene defines the hosting scene
  47291. * @returns the polyhedron mesh
  47292. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47293. */
  47294. static CreatePolyhedron(name: string, options: {
  47295. type?: number;
  47296. size?: number;
  47297. sizeX?: number;
  47298. sizeY?: number;
  47299. sizeZ?: number;
  47300. custom?: any;
  47301. faceUV?: Vector4[];
  47302. faceColors?: Color4[];
  47303. flat?: boolean;
  47304. updatable?: boolean;
  47305. sideOrientation?: number;
  47306. frontUVs?: Vector4;
  47307. backUVs?: Vector4;
  47308. }, scene?: Nullable<Scene>): Mesh;
  47309. }
  47310. }
  47311. declare module BABYLON {
  47312. /**
  47313. * Gizmo that enables scaling a mesh along 3 axis
  47314. */
  47315. export class ScaleGizmo extends Gizmo {
  47316. /**
  47317. * Internal gizmo used for interactions on the x axis
  47318. */
  47319. xGizmo: AxisScaleGizmo;
  47320. /**
  47321. * Internal gizmo used for interactions on the y axis
  47322. */
  47323. yGizmo: AxisScaleGizmo;
  47324. /**
  47325. * Internal gizmo used for interactions on the z axis
  47326. */
  47327. zGizmo: AxisScaleGizmo;
  47328. /**
  47329. * Internal gizmo used to scale all axis equally
  47330. */
  47331. uniformScaleGizmo: AxisScaleGizmo;
  47332. private _meshAttached;
  47333. private _updateGizmoRotationToMatchAttachedMesh;
  47334. private _snapDistance;
  47335. private _scaleRatio;
  47336. private _uniformScalingMesh;
  47337. private _octahedron;
  47338. private _sensitivity;
  47339. /** Fires an event when any of it's sub gizmos are dragged */
  47340. onDragStartObservable: Observable<unknown>;
  47341. /** Fires an event when any of it's sub gizmos are released from dragging */
  47342. onDragEndObservable: Observable<unknown>;
  47343. get attachedMesh(): Nullable<AbstractMesh>;
  47344. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47345. /**
  47346. * Creates a ScaleGizmo
  47347. * @param gizmoLayer The utility layer the gizmo will be added to
  47348. */
  47349. constructor(gizmoLayer?: UtilityLayerRenderer);
  47350. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47351. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47352. /**
  47353. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47354. */
  47355. set snapDistance(value: number);
  47356. get snapDistance(): number;
  47357. /**
  47358. * Ratio for the scale of the gizmo (Default: 1)
  47359. */
  47360. set scaleRatio(value: number);
  47361. get scaleRatio(): number;
  47362. /**
  47363. * Sensitivity factor for dragging (Default: 1)
  47364. */
  47365. set sensitivity(value: number);
  47366. get sensitivity(): number;
  47367. /**
  47368. * Disposes of the gizmo
  47369. */
  47370. dispose(): void;
  47371. }
  47372. }
  47373. declare module BABYLON {
  47374. /**
  47375. * Single axis scale gizmo
  47376. */
  47377. export class AxisScaleGizmo extends Gizmo {
  47378. /**
  47379. * Drag behavior responsible for the gizmos dragging interactions
  47380. */
  47381. dragBehavior: PointerDragBehavior;
  47382. private _pointerObserver;
  47383. /**
  47384. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47385. */
  47386. snapDistance: number;
  47387. /**
  47388. * Event that fires each time the gizmo snaps to a new location.
  47389. * * snapDistance is the the change in distance
  47390. */
  47391. onSnapObservable: Observable<{
  47392. snapDistance: number;
  47393. }>;
  47394. /**
  47395. * If the scaling operation should be done on all axis (default: false)
  47396. */
  47397. uniformScaling: boolean;
  47398. /**
  47399. * Custom sensitivity value for the drag strength
  47400. */
  47401. sensitivity: number;
  47402. private _isEnabled;
  47403. private _parent;
  47404. private _arrow;
  47405. private _coloredMaterial;
  47406. private _hoverMaterial;
  47407. /**
  47408. * Creates an AxisScaleGizmo
  47409. * @param gizmoLayer The utility layer the gizmo will be added to
  47410. * @param dragAxis The axis which the gizmo will be able to scale on
  47411. * @param color The color of the gizmo
  47412. */
  47413. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47414. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47415. /**
  47416. * If the gizmo is enabled
  47417. */
  47418. set isEnabled(value: boolean);
  47419. get isEnabled(): boolean;
  47420. /**
  47421. * Disposes of the gizmo
  47422. */
  47423. dispose(): void;
  47424. /**
  47425. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47426. * @param mesh The mesh to replace the default mesh of the gizmo
  47427. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47428. */
  47429. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * Bounding box gizmo
  47435. */
  47436. export class BoundingBoxGizmo extends Gizmo {
  47437. private _lineBoundingBox;
  47438. private _rotateSpheresParent;
  47439. private _scaleBoxesParent;
  47440. private _boundingDimensions;
  47441. private _renderObserver;
  47442. private _pointerObserver;
  47443. private _scaleDragSpeed;
  47444. private _tmpQuaternion;
  47445. private _tmpVector;
  47446. private _tmpRotationMatrix;
  47447. /**
  47448. * 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)
  47449. */
  47450. ignoreChildren: boolean;
  47451. /**
  47452. * 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)
  47453. */
  47454. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47455. /**
  47456. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47457. */
  47458. rotationSphereSize: number;
  47459. /**
  47460. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47461. */
  47462. scaleBoxSize: number;
  47463. /**
  47464. * 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)
  47465. */
  47466. fixedDragMeshScreenSize: boolean;
  47467. /**
  47468. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47469. */
  47470. fixedDragMeshScreenSizeDistanceFactor: number;
  47471. /**
  47472. * Fired when a rotation sphere or scale box is dragged
  47473. */
  47474. onDragStartObservable: Observable<{}>;
  47475. /**
  47476. * Fired when a scale box is dragged
  47477. */
  47478. onScaleBoxDragObservable: Observable<{}>;
  47479. /**
  47480. * Fired when a scale box drag is ended
  47481. */
  47482. onScaleBoxDragEndObservable: Observable<{}>;
  47483. /**
  47484. * Fired when a rotation sphere is dragged
  47485. */
  47486. onRotationSphereDragObservable: Observable<{}>;
  47487. /**
  47488. * Fired when a rotation sphere drag is ended
  47489. */
  47490. onRotationSphereDragEndObservable: Observable<{}>;
  47491. /**
  47492. * 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)
  47493. */
  47494. scalePivot: Nullable<Vector3>;
  47495. /**
  47496. * Mesh used as a pivot to rotate the attached mesh
  47497. */
  47498. private _anchorMesh;
  47499. private _existingMeshScale;
  47500. private _dragMesh;
  47501. private pointerDragBehavior;
  47502. private coloredMaterial;
  47503. private hoverColoredMaterial;
  47504. /**
  47505. * Sets the color of the bounding box gizmo
  47506. * @param color the color to set
  47507. */
  47508. setColor(color: Color3): void;
  47509. /**
  47510. * Creates an BoundingBoxGizmo
  47511. * @param gizmoLayer The utility layer the gizmo will be added to
  47512. * @param color The color of the gizmo
  47513. */
  47514. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47515. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47516. private _selectNode;
  47517. /**
  47518. * Updates the bounding box information for the Gizmo
  47519. */
  47520. updateBoundingBox(): void;
  47521. private _updateRotationSpheres;
  47522. private _updateScaleBoxes;
  47523. /**
  47524. * Enables rotation on the specified axis and disables rotation on the others
  47525. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47526. */
  47527. setEnabledRotationAxis(axis: string): void;
  47528. /**
  47529. * Enables/disables scaling
  47530. * @param enable if scaling should be enabled
  47531. */
  47532. setEnabledScaling(enable: boolean): void;
  47533. private _updateDummy;
  47534. /**
  47535. * Enables a pointer drag behavior on the bounding box of the gizmo
  47536. */
  47537. enableDragBehavior(): void;
  47538. /**
  47539. * Disposes of the gizmo
  47540. */
  47541. dispose(): void;
  47542. /**
  47543. * 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)
  47544. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47545. * @returns the bounding box mesh with the passed in mesh as a child
  47546. */
  47547. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47548. /**
  47549. * CustomMeshes are not supported by this gizmo
  47550. * @param mesh The mesh to replace the default mesh of the gizmo
  47551. */
  47552. setCustomMesh(mesh: Mesh): void;
  47553. }
  47554. }
  47555. declare module BABYLON {
  47556. /**
  47557. * Single plane rotation gizmo
  47558. */
  47559. export class PlaneRotationGizmo extends Gizmo {
  47560. /**
  47561. * Drag behavior responsible for the gizmos dragging interactions
  47562. */
  47563. dragBehavior: PointerDragBehavior;
  47564. private _pointerObserver;
  47565. /**
  47566. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47567. */
  47568. snapDistance: number;
  47569. /**
  47570. * Event that fires each time the gizmo snaps to a new location.
  47571. * * snapDistance is the the change in distance
  47572. */
  47573. onSnapObservable: Observable<{
  47574. snapDistance: number;
  47575. }>;
  47576. private _isEnabled;
  47577. private _parent;
  47578. /**
  47579. * Creates a PlaneRotationGizmo
  47580. * @param gizmoLayer The utility layer the gizmo will be added to
  47581. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47582. * @param color The color of the gizmo
  47583. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47584. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47585. */
  47586. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47587. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47588. /**
  47589. * If the gizmo is enabled
  47590. */
  47591. set isEnabled(value: boolean);
  47592. get isEnabled(): boolean;
  47593. /**
  47594. * Disposes of the gizmo
  47595. */
  47596. dispose(): void;
  47597. }
  47598. }
  47599. declare module BABYLON {
  47600. /**
  47601. * Gizmo that enables rotating a mesh along 3 axis
  47602. */
  47603. export class RotationGizmo extends Gizmo {
  47604. /**
  47605. * Internal gizmo used for interactions on the x axis
  47606. */
  47607. xGizmo: PlaneRotationGizmo;
  47608. /**
  47609. * Internal gizmo used for interactions on the y axis
  47610. */
  47611. yGizmo: PlaneRotationGizmo;
  47612. /**
  47613. * Internal gizmo used for interactions on the z axis
  47614. */
  47615. zGizmo: PlaneRotationGizmo;
  47616. /** Fires an event when any of it's sub gizmos are dragged */
  47617. onDragStartObservable: Observable<unknown>;
  47618. /** Fires an event when any of it's sub gizmos are released from dragging */
  47619. onDragEndObservable: Observable<unknown>;
  47620. private _meshAttached;
  47621. get attachedMesh(): Nullable<AbstractMesh>;
  47622. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47623. /**
  47624. * Creates a RotationGizmo
  47625. * @param gizmoLayer The utility layer the gizmo will be added to
  47626. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47627. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47628. */
  47629. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47630. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47631. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47632. /**
  47633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47634. */
  47635. set snapDistance(value: number);
  47636. get snapDistance(): number;
  47637. /**
  47638. * Ratio for the scale of the gizmo (Default: 1)
  47639. */
  47640. set scaleRatio(value: number);
  47641. get scaleRatio(): number;
  47642. /**
  47643. * Disposes of the gizmo
  47644. */
  47645. dispose(): void;
  47646. /**
  47647. * CustomMeshes are not supported by this gizmo
  47648. * @param mesh The mesh to replace the default mesh of the gizmo
  47649. */
  47650. setCustomMesh(mesh: Mesh): void;
  47651. }
  47652. }
  47653. declare module BABYLON {
  47654. /**
  47655. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47656. */
  47657. export class GizmoManager implements IDisposable {
  47658. private scene;
  47659. /**
  47660. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47661. */
  47662. gizmos: {
  47663. positionGizmo: Nullable<PositionGizmo>;
  47664. rotationGizmo: Nullable<RotationGizmo>;
  47665. scaleGizmo: Nullable<ScaleGizmo>;
  47666. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47667. };
  47668. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47669. clearGizmoOnEmptyPointerEvent: boolean;
  47670. /** Fires an event when the manager is attached to a mesh */
  47671. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47672. private _gizmosEnabled;
  47673. private _pointerObserver;
  47674. private _attachedMesh;
  47675. private _boundingBoxColor;
  47676. private _defaultUtilityLayer;
  47677. private _defaultKeepDepthUtilityLayer;
  47678. /**
  47679. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47680. */
  47681. boundingBoxDragBehavior: SixDofDragBehavior;
  47682. /**
  47683. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47684. */
  47685. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47686. /**
  47687. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47688. */
  47689. usePointerToAttachGizmos: boolean;
  47690. /**
  47691. * Utility layer that the bounding box gizmo belongs to
  47692. */
  47693. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47694. /**
  47695. * Utility layer that all gizmos besides bounding box belong to
  47696. */
  47697. get utilityLayer(): UtilityLayerRenderer;
  47698. /**
  47699. * Instatiates a gizmo manager
  47700. * @param scene the scene to overlay the gizmos on top of
  47701. */
  47702. constructor(scene: Scene);
  47703. /**
  47704. * Attaches a set of gizmos to the specified mesh
  47705. * @param mesh The mesh the gizmo's should be attached to
  47706. */
  47707. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47708. /**
  47709. * If the position gizmo is enabled
  47710. */
  47711. set positionGizmoEnabled(value: boolean);
  47712. get positionGizmoEnabled(): boolean;
  47713. /**
  47714. * If the rotation gizmo is enabled
  47715. */
  47716. set rotationGizmoEnabled(value: boolean);
  47717. get rotationGizmoEnabled(): boolean;
  47718. /**
  47719. * If the scale gizmo is enabled
  47720. */
  47721. set scaleGizmoEnabled(value: boolean);
  47722. get scaleGizmoEnabled(): boolean;
  47723. /**
  47724. * If the boundingBox gizmo is enabled
  47725. */
  47726. set boundingBoxGizmoEnabled(value: boolean);
  47727. get boundingBoxGizmoEnabled(): boolean;
  47728. /**
  47729. * Disposes of the gizmo manager
  47730. */
  47731. dispose(): void;
  47732. }
  47733. }
  47734. declare module BABYLON {
  47735. /**
  47736. * A directional light is defined by a direction (what a surprise!).
  47737. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47738. * 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.
  47739. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47740. */
  47741. export class DirectionalLight extends ShadowLight {
  47742. private _shadowFrustumSize;
  47743. /**
  47744. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47745. */
  47746. get shadowFrustumSize(): number;
  47747. /**
  47748. * Specifies a fix frustum size for the shadow generation.
  47749. */
  47750. set shadowFrustumSize(value: number);
  47751. private _shadowOrthoScale;
  47752. /**
  47753. * Gets the shadow projection scale against the optimal computed one.
  47754. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47755. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47756. */
  47757. get shadowOrthoScale(): number;
  47758. /**
  47759. * Sets the shadow projection scale against the optimal computed one.
  47760. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47761. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47762. */
  47763. set shadowOrthoScale(value: number);
  47764. /**
  47765. * Automatically compute the projection matrix to best fit (including all the casters)
  47766. * on each frame.
  47767. */
  47768. autoUpdateExtends: boolean;
  47769. /**
  47770. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  47771. * on each frame. autoUpdateExtends must be set to true for this to work
  47772. */
  47773. autoCalcShadowZBounds: boolean;
  47774. private _orthoLeft;
  47775. private _orthoRight;
  47776. private _orthoTop;
  47777. private _orthoBottom;
  47778. /**
  47779. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47780. * The directional light is emitted from everywhere in the given direction.
  47781. * It can cast shadows.
  47782. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47783. * @param name The friendly name of the light
  47784. * @param direction The direction of the light
  47785. * @param scene The scene the light belongs to
  47786. */
  47787. constructor(name: string, direction: Vector3, scene: Scene);
  47788. /**
  47789. * Returns the string "DirectionalLight".
  47790. * @return The class name
  47791. */
  47792. getClassName(): string;
  47793. /**
  47794. * Returns the integer 1.
  47795. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47796. */
  47797. getTypeID(): number;
  47798. /**
  47799. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47803. /**
  47804. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47808. /**
  47809. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47810. * Returns the DirectionalLight Shadow projection matrix.
  47811. */
  47812. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47813. protected _buildUniformLayout(): void;
  47814. /**
  47815. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47816. * @param effect The effect to update
  47817. * @param lightIndex The index of the light in the effect to update
  47818. * @returns The directional light
  47819. */
  47820. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47821. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47822. /**
  47823. * Gets the minZ used for shadow according to both the scene and the light.
  47824. *
  47825. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47826. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47827. * @param activeCamera The camera we are returning the min for
  47828. * @returns the depth min z
  47829. */
  47830. getDepthMinZ(activeCamera: Camera): number;
  47831. /**
  47832. * Gets the maxZ used for shadow according to both the scene and the light.
  47833. *
  47834. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47835. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47836. * @param activeCamera The camera we are returning the max for
  47837. * @returns the depth max z
  47838. */
  47839. getDepthMaxZ(activeCamera: Camera): number;
  47840. /**
  47841. * Prepares the list of defines specific to the light type.
  47842. * @param defines the list of defines
  47843. * @param lightIndex defines the index of the light for the effect
  47844. */
  47845. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47846. }
  47847. }
  47848. declare module BABYLON {
  47849. /**
  47850. * Class containing static functions to help procedurally build meshes
  47851. */
  47852. export class HemisphereBuilder {
  47853. /**
  47854. * Creates a hemisphere mesh
  47855. * @param name defines the name of the mesh
  47856. * @param options defines the options used to create the mesh
  47857. * @param scene defines the hosting scene
  47858. * @returns the hemisphere mesh
  47859. */
  47860. static CreateHemisphere(name: string, options: {
  47861. segments?: number;
  47862. diameter?: number;
  47863. sideOrientation?: number;
  47864. }, scene: any): Mesh;
  47865. }
  47866. }
  47867. declare module BABYLON {
  47868. /**
  47869. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47870. * These values define a cone of light starting from the position, emitting toward the direction.
  47871. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47872. * and the exponent defines the speed of the decay of the light with distance (reach).
  47873. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47874. */
  47875. export class SpotLight extends ShadowLight {
  47876. private _angle;
  47877. private _innerAngle;
  47878. private _cosHalfAngle;
  47879. private _lightAngleScale;
  47880. private _lightAngleOffset;
  47881. /**
  47882. * Gets the cone angle of the spot light in Radians.
  47883. */
  47884. get angle(): number;
  47885. /**
  47886. * Sets the cone angle of the spot light in Radians.
  47887. */
  47888. set angle(value: number);
  47889. /**
  47890. * Only used in gltf falloff mode, this defines the angle where
  47891. * the directional falloff will start before cutting at angle which could be seen
  47892. * as outer angle.
  47893. */
  47894. get innerAngle(): number;
  47895. /**
  47896. * Only used in gltf falloff mode, this defines the angle where
  47897. * the directional falloff will start before cutting at angle which could be seen
  47898. * as outer angle.
  47899. */
  47900. set innerAngle(value: number);
  47901. private _shadowAngleScale;
  47902. /**
  47903. * Allows scaling the angle of the light for shadow generation only.
  47904. */
  47905. get shadowAngleScale(): number;
  47906. /**
  47907. * Allows scaling the angle of the light for shadow generation only.
  47908. */
  47909. set shadowAngleScale(value: number);
  47910. /**
  47911. * The light decay speed with the distance from the emission spot.
  47912. */
  47913. exponent: number;
  47914. private _projectionTextureMatrix;
  47915. /**
  47916. * Allows reading the projecton texture
  47917. */
  47918. get projectionTextureMatrix(): Matrix;
  47919. protected _projectionTextureLightNear: number;
  47920. /**
  47921. * Gets the near clip of the Spotlight for texture projection.
  47922. */
  47923. get projectionTextureLightNear(): number;
  47924. /**
  47925. * Sets the near clip of the Spotlight for texture projection.
  47926. */
  47927. set projectionTextureLightNear(value: number);
  47928. protected _projectionTextureLightFar: number;
  47929. /**
  47930. * Gets the far clip of the Spotlight for texture projection.
  47931. */
  47932. get projectionTextureLightFar(): number;
  47933. /**
  47934. * Sets the far clip of the Spotlight for texture projection.
  47935. */
  47936. set projectionTextureLightFar(value: number);
  47937. protected _projectionTextureUpDirection: Vector3;
  47938. /**
  47939. * Gets the Up vector of the Spotlight for texture projection.
  47940. */
  47941. get projectionTextureUpDirection(): Vector3;
  47942. /**
  47943. * Sets the Up vector of the Spotlight for texture projection.
  47944. */
  47945. set projectionTextureUpDirection(value: Vector3);
  47946. private _projectionTexture;
  47947. /**
  47948. * Gets the projection texture of the light.
  47949. */
  47950. get projectionTexture(): Nullable<BaseTexture>;
  47951. /**
  47952. * Sets the projection texture of the light.
  47953. */
  47954. set projectionTexture(value: Nullable<BaseTexture>);
  47955. private _projectionTextureViewLightDirty;
  47956. private _projectionTextureProjectionLightDirty;
  47957. private _projectionTextureDirty;
  47958. private _projectionTextureViewTargetVector;
  47959. private _projectionTextureViewLightMatrix;
  47960. private _projectionTextureProjectionLightMatrix;
  47961. private _projectionTextureScalingMatrix;
  47962. /**
  47963. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47964. * It can cast shadows.
  47965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47966. * @param name The light friendly name
  47967. * @param position The position of the spot light in the scene
  47968. * @param direction The direction of the light in the scene
  47969. * @param angle The cone angle of the light in Radians
  47970. * @param exponent The light decay speed with the distance from the emission spot
  47971. * @param scene The scene the lights belongs to
  47972. */
  47973. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47974. /**
  47975. * Returns the string "SpotLight".
  47976. * @returns the class name
  47977. */
  47978. getClassName(): string;
  47979. /**
  47980. * Returns the integer 2.
  47981. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47982. */
  47983. getTypeID(): number;
  47984. /**
  47985. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47986. */
  47987. protected _setDirection(value: Vector3): void;
  47988. /**
  47989. * Overrides the position setter to recompute the projection texture view light Matrix.
  47990. */
  47991. protected _setPosition(value: Vector3): void;
  47992. /**
  47993. * 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.
  47994. * Returns the SpotLight.
  47995. */
  47996. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47997. protected _computeProjectionTextureViewLightMatrix(): void;
  47998. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47999. /**
  48000. * Main function for light texture projection matrix computing.
  48001. */
  48002. protected _computeProjectionTextureMatrix(): void;
  48003. protected _buildUniformLayout(): void;
  48004. private _computeAngleValues;
  48005. /**
  48006. * Sets the passed Effect "effect" with the Light textures.
  48007. * @param effect The effect to update
  48008. * @param lightIndex The index of the light in the effect to update
  48009. * @returns The light
  48010. */
  48011. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48012. /**
  48013. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48014. * @param effect The effect to update
  48015. * @param lightIndex The index of the light in the effect to update
  48016. * @returns The spot light
  48017. */
  48018. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48019. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48020. /**
  48021. * Disposes the light and the associated resources.
  48022. */
  48023. dispose(): void;
  48024. /**
  48025. * Prepares the list of defines specific to the light type.
  48026. * @param defines the list of defines
  48027. * @param lightIndex defines the index of the light for the effect
  48028. */
  48029. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48030. }
  48031. }
  48032. declare module BABYLON {
  48033. /**
  48034. * Gizmo that enables viewing a light
  48035. */
  48036. export class LightGizmo extends Gizmo {
  48037. private _lightMesh;
  48038. private _material;
  48039. private _cachedPosition;
  48040. private _cachedForward;
  48041. private _attachedMeshParent;
  48042. /**
  48043. * Creates a LightGizmo
  48044. * @param gizmoLayer The utility layer the gizmo will be added to
  48045. */
  48046. constructor(gizmoLayer?: UtilityLayerRenderer);
  48047. private _light;
  48048. /**
  48049. * The light that the gizmo is attached to
  48050. */
  48051. set light(light: Nullable<Light>);
  48052. get light(): Nullable<Light>;
  48053. /**
  48054. * Gets the material used to render the light gizmo
  48055. */
  48056. get material(): StandardMaterial;
  48057. /**
  48058. * @hidden
  48059. * Updates the gizmo to match the attached mesh's position/rotation
  48060. */
  48061. protected _update(): void;
  48062. private static _Scale;
  48063. /**
  48064. * Creates the lines for a light mesh
  48065. */
  48066. private static _CreateLightLines;
  48067. /**
  48068. * Disposes of the light gizmo
  48069. */
  48070. dispose(): void;
  48071. private static _CreateHemisphericLightMesh;
  48072. private static _CreatePointLightMesh;
  48073. private static _CreateSpotLightMesh;
  48074. private static _CreateDirectionalLightMesh;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. /** @hidden */
  48079. export var backgroundFragmentDeclaration: {
  48080. name: string;
  48081. shader: string;
  48082. };
  48083. }
  48084. declare module BABYLON {
  48085. /** @hidden */
  48086. export var backgroundUboDeclaration: {
  48087. name: string;
  48088. shader: string;
  48089. };
  48090. }
  48091. declare module BABYLON {
  48092. /** @hidden */
  48093. export var backgroundPixelShader: {
  48094. name: string;
  48095. shader: string;
  48096. };
  48097. }
  48098. declare module BABYLON {
  48099. /** @hidden */
  48100. export var backgroundVertexDeclaration: {
  48101. name: string;
  48102. shader: string;
  48103. };
  48104. }
  48105. declare module BABYLON {
  48106. /** @hidden */
  48107. export var backgroundVertexShader: {
  48108. name: string;
  48109. shader: string;
  48110. };
  48111. }
  48112. declare module BABYLON {
  48113. /**
  48114. * Background material used to create an efficient environement around your scene.
  48115. */
  48116. export class BackgroundMaterial extends PushMaterial {
  48117. /**
  48118. * Standard reflectance value at parallel view angle.
  48119. */
  48120. static StandardReflectance0: number;
  48121. /**
  48122. * Standard reflectance value at grazing angle.
  48123. */
  48124. static StandardReflectance90: number;
  48125. protected _primaryColor: Color3;
  48126. /**
  48127. * Key light Color (multiply against the environement texture)
  48128. */
  48129. primaryColor: Color3;
  48130. protected __perceptualColor: Nullable<Color3>;
  48131. /**
  48132. * Experimental Internal Use Only.
  48133. *
  48134. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48135. * This acts as a helper to set the primary color to a more "human friendly" value.
  48136. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48137. * output color as close as possible from the chosen value.
  48138. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48139. * part of lighting setup.)
  48140. */
  48141. get _perceptualColor(): Nullable<Color3>;
  48142. set _perceptualColor(value: Nullable<Color3>);
  48143. protected _primaryColorShadowLevel: float;
  48144. /**
  48145. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48146. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48147. */
  48148. get primaryColorShadowLevel(): float;
  48149. set primaryColorShadowLevel(value: float);
  48150. protected _primaryColorHighlightLevel: float;
  48151. /**
  48152. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48153. * The primary color is used at the level chosen to define what the white area would look.
  48154. */
  48155. get primaryColorHighlightLevel(): float;
  48156. set primaryColorHighlightLevel(value: float);
  48157. protected _reflectionTexture: Nullable<BaseTexture>;
  48158. /**
  48159. * Reflection Texture used in the material.
  48160. * Should be author in a specific way for the best result (refer to the documentation).
  48161. */
  48162. reflectionTexture: Nullable<BaseTexture>;
  48163. protected _reflectionBlur: float;
  48164. /**
  48165. * Reflection Texture level of blur.
  48166. *
  48167. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48168. * texture twice.
  48169. */
  48170. reflectionBlur: float;
  48171. protected _diffuseTexture: Nullable<BaseTexture>;
  48172. /**
  48173. * Diffuse Texture used in the material.
  48174. * Should be author in a specific way for the best result (refer to the documentation).
  48175. */
  48176. diffuseTexture: Nullable<BaseTexture>;
  48177. protected _shadowLights: Nullable<IShadowLight[]>;
  48178. /**
  48179. * Specify the list of lights casting shadow on the material.
  48180. * All scene shadow lights will be included if null.
  48181. */
  48182. shadowLights: Nullable<IShadowLight[]>;
  48183. protected _shadowLevel: float;
  48184. /**
  48185. * Helps adjusting the shadow to a softer level if required.
  48186. * 0 means black shadows and 1 means no shadows.
  48187. */
  48188. shadowLevel: float;
  48189. protected _sceneCenter: Vector3;
  48190. /**
  48191. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48192. * It is usually zero but might be interesting to modify according to your setup.
  48193. */
  48194. sceneCenter: Vector3;
  48195. protected _opacityFresnel: boolean;
  48196. /**
  48197. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48198. * This helps ensuring a nice transition when the camera goes under the ground.
  48199. */
  48200. opacityFresnel: boolean;
  48201. protected _reflectionFresnel: boolean;
  48202. /**
  48203. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48204. * This helps adding a mirror texture on the ground.
  48205. */
  48206. reflectionFresnel: boolean;
  48207. protected _reflectionFalloffDistance: number;
  48208. /**
  48209. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48210. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48211. */
  48212. reflectionFalloffDistance: number;
  48213. protected _reflectionAmount: number;
  48214. /**
  48215. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48216. */
  48217. reflectionAmount: number;
  48218. protected _reflectionReflectance0: number;
  48219. /**
  48220. * This specifies the weight of the reflection at grazing angle.
  48221. */
  48222. reflectionReflectance0: number;
  48223. protected _reflectionReflectance90: number;
  48224. /**
  48225. * This specifies the weight of the reflection at a perpendicular point of view.
  48226. */
  48227. reflectionReflectance90: number;
  48228. /**
  48229. * Sets the reflection reflectance fresnel values according to the default standard
  48230. * empirically know to work well :-)
  48231. */
  48232. set reflectionStandardFresnelWeight(value: number);
  48233. protected _useRGBColor: boolean;
  48234. /**
  48235. * Helps to directly use the maps channels instead of their level.
  48236. */
  48237. useRGBColor: boolean;
  48238. protected _enableNoise: boolean;
  48239. /**
  48240. * This helps reducing the banding effect that could occur on the background.
  48241. */
  48242. enableNoise: boolean;
  48243. /**
  48244. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48245. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48246. * Recommended to be keep at 1.0 except for special cases.
  48247. */
  48248. get fovMultiplier(): number;
  48249. set fovMultiplier(value: number);
  48250. private _fovMultiplier;
  48251. /**
  48252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48253. */
  48254. useEquirectangularFOV: boolean;
  48255. private _maxSimultaneousLights;
  48256. /**
  48257. * Number of Simultaneous lights allowed on the material.
  48258. */
  48259. maxSimultaneousLights: int;
  48260. /**
  48261. * Default configuration related to image processing available in the Background Material.
  48262. */
  48263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48264. /**
  48265. * Keep track of the image processing observer to allow dispose and replace.
  48266. */
  48267. private _imageProcessingObserver;
  48268. /**
  48269. * Attaches a new image processing configuration to the PBR Material.
  48270. * @param configuration (if null the scene configuration will be use)
  48271. */
  48272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48273. /**
  48274. * Gets the image processing configuration used either in this material.
  48275. */
  48276. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48277. /**
  48278. * Sets the Default image processing configuration used either in the this material.
  48279. *
  48280. * If sets to null, the scene one is in use.
  48281. */
  48282. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48283. /**
  48284. * Gets wether the color curves effect is enabled.
  48285. */
  48286. get cameraColorCurvesEnabled(): boolean;
  48287. /**
  48288. * Sets wether the color curves effect is enabled.
  48289. */
  48290. set cameraColorCurvesEnabled(value: boolean);
  48291. /**
  48292. * Gets wether the color grading effect is enabled.
  48293. */
  48294. get cameraColorGradingEnabled(): boolean;
  48295. /**
  48296. * Gets wether the color grading effect is enabled.
  48297. */
  48298. set cameraColorGradingEnabled(value: boolean);
  48299. /**
  48300. * Gets wether tonemapping is enabled or not.
  48301. */
  48302. get cameraToneMappingEnabled(): boolean;
  48303. /**
  48304. * Sets wether tonemapping is enabled or not
  48305. */
  48306. set cameraToneMappingEnabled(value: boolean);
  48307. /**
  48308. * The camera exposure used on this material.
  48309. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48310. * This corresponds to a photographic exposure.
  48311. */
  48312. get cameraExposure(): float;
  48313. /**
  48314. * The camera exposure used on this material.
  48315. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48316. * This corresponds to a photographic exposure.
  48317. */
  48318. set cameraExposure(value: float);
  48319. /**
  48320. * Gets The camera contrast used on this material.
  48321. */
  48322. get cameraContrast(): float;
  48323. /**
  48324. * Sets The camera contrast used on this material.
  48325. */
  48326. set cameraContrast(value: float);
  48327. /**
  48328. * Gets the Color Grading 2D Lookup Texture.
  48329. */
  48330. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48331. /**
  48332. * Sets the Color Grading 2D Lookup Texture.
  48333. */
  48334. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48335. /**
  48336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48338. * 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;
  48339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48340. */
  48341. get cameraColorCurves(): Nullable<ColorCurves>;
  48342. /**
  48343. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48344. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48345. * 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;
  48346. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48347. */
  48348. set cameraColorCurves(value: Nullable<ColorCurves>);
  48349. /**
  48350. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48351. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48352. */
  48353. switchToBGR: boolean;
  48354. private _renderTargets;
  48355. private _reflectionControls;
  48356. private _white;
  48357. private _primaryShadowColor;
  48358. private _primaryHighlightColor;
  48359. /**
  48360. * Instantiates a Background Material in the given scene
  48361. * @param name The friendly name of the material
  48362. * @param scene The scene to add the material to
  48363. */
  48364. constructor(name: string, scene: Scene);
  48365. /**
  48366. * Gets a boolean indicating that current material needs to register RTT
  48367. */
  48368. get hasRenderTargetTextures(): boolean;
  48369. /**
  48370. * The entire material has been created in order to prevent overdraw.
  48371. * @returns false
  48372. */
  48373. needAlphaTesting(): boolean;
  48374. /**
  48375. * The entire material has been created in order to prevent overdraw.
  48376. * @returns true if blending is enable
  48377. */
  48378. needAlphaBlending(): boolean;
  48379. /**
  48380. * Checks wether the material is ready to be rendered for a given mesh.
  48381. * @param mesh The mesh to render
  48382. * @param subMesh The submesh to check against
  48383. * @param useInstances Specify wether or not the material is used with instances
  48384. * @returns true if all the dependencies are ready (Textures, Effects...)
  48385. */
  48386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48387. /**
  48388. * Compute the primary color according to the chosen perceptual color.
  48389. */
  48390. private _computePrimaryColorFromPerceptualColor;
  48391. /**
  48392. * Compute the highlights and shadow colors according to their chosen levels.
  48393. */
  48394. private _computePrimaryColors;
  48395. /**
  48396. * Build the uniform buffer used in the material.
  48397. */
  48398. buildUniformLayout(): void;
  48399. /**
  48400. * Unbind the material.
  48401. */
  48402. unbind(): void;
  48403. /**
  48404. * Bind only the world matrix to the material.
  48405. * @param world The world matrix to bind.
  48406. */
  48407. bindOnlyWorldMatrix(world: Matrix): void;
  48408. /**
  48409. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48410. * @param world The world matrix to bind.
  48411. * @param subMesh The submesh to bind for.
  48412. */
  48413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48414. /**
  48415. * Checks to see if a texture is used in the material.
  48416. * @param texture - Base texture to use.
  48417. * @returns - Boolean specifying if a texture is used in the material.
  48418. */
  48419. hasTexture(texture: BaseTexture): boolean;
  48420. /**
  48421. * Dispose the material.
  48422. * @param forceDisposeEffect Force disposal of the associated effect.
  48423. * @param forceDisposeTextures Force disposal of the associated textures.
  48424. */
  48425. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48426. /**
  48427. * Clones the material.
  48428. * @param name The cloned name.
  48429. * @returns The cloned material.
  48430. */
  48431. clone(name: string): BackgroundMaterial;
  48432. /**
  48433. * Serializes the current material to its JSON representation.
  48434. * @returns The JSON representation.
  48435. */
  48436. serialize(): any;
  48437. /**
  48438. * Gets the class name of the material
  48439. * @returns "BackgroundMaterial"
  48440. */
  48441. getClassName(): string;
  48442. /**
  48443. * Parse a JSON input to create back a background material.
  48444. * @param source The JSON data to parse
  48445. * @param scene The scene to create the parsed material in
  48446. * @param rootUrl The root url of the assets the material depends upon
  48447. * @returns the instantiated BackgroundMaterial.
  48448. */
  48449. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48450. }
  48451. }
  48452. declare module BABYLON {
  48453. /**
  48454. * Represents the different options available during the creation of
  48455. * a Environment helper.
  48456. *
  48457. * This can control the default ground, skybox and image processing setup of your scene.
  48458. */
  48459. export interface IEnvironmentHelperOptions {
  48460. /**
  48461. * Specifies wether or not to create a ground.
  48462. * True by default.
  48463. */
  48464. createGround: boolean;
  48465. /**
  48466. * Specifies the ground size.
  48467. * 15 by default.
  48468. */
  48469. groundSize: number;
  48470. /**
  48471. * The texture used on the ground for the main color.
  48472. * Comes from the BabylonJS CDN by default.
  48473. *
  48474. * Remarks: Can be either a texture or a url.
  48475. */
  48476. groundTexture: string | BaseTexture;
  48477. /**
  48478. * The color mixed in the ground texture by default.
  48479. * BabylonJS clearColor by default.
  48480. */
  48481. groundColor: Color3;
  48482. /**
  48483. * Specifies the ground opacity.
  48484. * 1 by default.
  48485. */
  48486. groundOpacity: number;
  48487. /**
  48488. * Enables the ground to receive shadows.
  48489. * True by default.
  48490. */
  48491. enableGroundShadow: boolean;
  48492. /**
  48493. * Helps preventing the shadow to be fully black on the ground.
  48494. * 0.5 by default.
  48495. */
  48496. groundShadowLevel: number;
  48497. /**
  48498. * Creates a mirror texture attach to the ground.
  48499. * false by default.
  48500. */
  48501. enableGroundMirror: boolean;
  48502. /**
  48503. * Specifies the ground mirror size ratio.
  48504. * 0.3 by default as the default kernel is 64.
  48505. */
  48506. groundMirrorSizeRatio: number;
  48507. /**
  48508. * Specifies the ground mirror blur kernel size.
  48509. * 64 by default.
  48510. */
  48511. groundMirrorBlurKernel: number;
  48512. /**
  48513. * Specifies the ground mirror visibility amount.
  48514. * 1 by default
  48515. */
  48516. groundMirrorAmount: number;
  48517. /**
  48518. * Specifies the ground mirror reflectance weight.
  48519. * This uses the standard weight of the background material to setup the fresnel effect
  48520. * of the mirror.
  48521. * 1 by default.
  48522. */
  48523. groundMirrorFresnelWeight: number;
  48524. /**
  48525. * Specifies the ground mirror Falloff distance.
  48526. * This can helps reducing the size of the reflection.
  48527. * 0 by Default.
  48528. */
  48529. groundMirrorFallOffDistance: number;
  48530. /**
  48531. * Specifies the ground mirror texture type.
  48532. * Unsigned Int by Default.
  48533. */
  48534. groundMirrorTextureType: number;
  48535. /**
  48536. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48537. * the shown objects.
  48538. */
  48539. groundYBias: number;
  48540. /**
  48541. * Specifies wether or not to create a skybox.
  48542. * True by default.
  48543. */
  48544. createSkybox: boolean;
  48545. /**
  48546. * Specifies the skybox size.
  48547. * 20 by default.
  48548. */
  48549. skyboxSize: number;
  48550. /**
  48551. * The texture used on the skybox for the main color.
  48552. * Comes from the BabylonJS CDN by default.
  48553. *
  48554. * Remarks: Can be either a texture or a url.
  48555. */
  48556. skyboxTexture: string | BaseTexture;
  48557. /**
  48558. * The color mixed in the skybox texture by default.
  48559. * BabylonJS clearColor by default.
  48560. */
  48561. skyboxColor: Color3;
  48562. /**
  48563. * The background rotation around the Y axis of the scene.
  48564. * This helps aligning the key lights of your scene with the background.
  48565. * 0 by default.
  48566. */
  48567. backgroundYRotation: number;
  48568. /**
  48569. * Compute automatically the size of the elements to best fit with the scene.
  48570. */
  48571. sizeAuto: boolean;
  48572. /**
  48573. * Default position of the rootMesh if autoSize is not true.
  48574. */
  48575. rootPosition: Vector3;
  48576. /**
  48577. * Sets up the image processing in the scene.
  48578. * true by default.
  48579. */
  48580. setupImageProcessing: boolean;
  48581. /**
  48582. * The texture used as your environment texture in the scene.
  48583. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48584. *
  48585. * Remarks: Can be either a texture or a url.
  48586. */
  48587. environmentTexture: string | BaseTexture;
  48588. /**
  48589. * The value of the exposure to apply to the scene.
  48590. * 0.6 by default if setupImageProcessing is true.
  48591. */
  48592. cameraExposure: number;
  48593. /**
  48594. * The value of the contrast to apply to the scene.
  48595. * 1.6 by default if setupImageProcessing is true.
  48596. */
  48597. cameraContrast: number;
  48598. /**
  48599. * Specifies wether or not tonemapping should be enabled in the scene.
  48600. * true by default if setupImageProcessing is true.
  48601. */
  48602. toneMappingEnabled: boolean;
  48603. }
  48604. /**
  48605. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48606. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48607. * It also helps with the default setup of your imageProcessing configuration.
  48608. */
  48609. export class EnvironmentHelper {
  48610. /**
  48611. * Default ground texture URL.
  48612. */
  48613. private static _groundTextureCDNUrl;
  48614. /**
  48615. * Default skybox texture URL.
  48616. */
  48617. private static _skyboxTextureCDNUrl;
  48618. /**
  48619. * Default environment texture URL.
  48620. */
  48621. private static _environmentTextureCDNUrl;
  48622. /**
  48623. * Creates the default options for the helper.
  48624. */
  48625. private static _getDefaultOptions;
  48626. private _rootMesh;
  48627. /**
  48628. * Gets the root mesh created by the helper.
  48629. */
  48630. get rootMesh(): Mesh;
  48631. private _skybox;
  48632. /**
  48633. * Gets the skybox created by the helper.
  48634. */
  48635. get skybox(): Nullable<Mesh>;
  48636. private _skyboxTexture;
  48637. /**
  48638. * Gets the skybox texture created by the helper.
  48639. */
  48640. get skyboxTexture(): Nullable<BaseTexture>;
  48641. private _skyboxMaterial;
  48642. /**
  48643. * Gets the skybox material created by the helper.
  48644. */
  48645. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48646. private _ground;
  48647. /**
  48648. * Gets the ground mesh created by the helper.
  48649. */
  48650. get ground(): Nullable<Mesh>;
  48651. private _groundTexture;
  48652. /**
  48653. * Gets the ground texture created by the helper.
  48654. */
  48655. get groundTexture(): Nullable<BaseTexture>;
  48656. private _groundMirror;
  48657. /**
  48658. * Gets the ground mirror created by the helper.
  48659. */
  48660. get groundMirror(): Nullable<MirrorTexture>;
  48661. /**
  48662. * Gets the ground mirror render list to helps pushing the meshes
  48663. * you wish in the ground reflection.
  48664. */
  48665. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48666. private _groundMaterial;
  48667. /**
  48668. * Gets the ground material created by the helper.
  48669. */
  48670. get groundMaterial(): Nullable<BackgroundMaterial>;
  48671. /**
  48672. * Stores the creation options.
  48673. */
  48674. private readonly _scene;
  48675. private _options;
  48676. /**
  48677. * This observable will be notified with any error during the creation of the environment,
  48678. * mainly texture creation errors.
  48679. */
  48680. onErrorObservable: Observable<{
  48681. message?: string;
  48682. exception?: any;
  48683. }>;
  48684. /**
  48685. * constructor
  48686. * @param options Defines the options we want to customize the helper
  48687. * @param scene The scene to add the material to
  48688. */
  48689. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48690. /**
  48691. * Updates the background according to the new options
  48692. * @param options
  48693. */
  48694. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48695. /**
  48696. * Sets the primary color of all the available elements.
  48697. * @param color the main color to affect to the ground and the background
  48698. */
  48699. setMainColor(color: Color3): void;
  48700. /**
  48701. * Setup the image processing according to the specified options.
  48702. */
  48703. private _setupImageProcessing;
  48704. /**
  48705. * Setup the environment texture according to the specified options.
  48706. */
  48707. private _setupEnvironmentTexture;
  48708. /**
  48709. * Setup the background according to the specified options.
  48710. */
  48711. private _setupBackground;
  48712. /**
  48713. * Get the scene sizes according to the setup.
  48714. */
  48715. private _getSceneSize;
  48716. /**
  48717. * Setup the ground according to the specified options.
  48718. */
  48719. private _setupGround;
  48720. /**
  48721. * Setup the ground material according to the specified options.
  48722. */
  48723. private _setupGroundMaterial;
  48724. /**
  48725. * Setup the ground diffuse texture according to the specified options.
  48726. */
  48727. private _setupGroundDiffuseTexture;
  48728. /**
  48729. * Setup the ground mirror texture according to the specified options.
  48730. */
  48731. private _setupGroundMirrorTexture;
  48732. /**
  48733. * Setup the ground to receive the mirror texture.
  48734. */
  48735. private _setupMirrorInGroundMaterial;
  48736. /**
  48737. * Setup the skybox according to the specified options.
  48738. */
  48739. private _setupSkybox;
  48740. /**
  48741. * Setup the skybox material according to the specified options.
  48742. */
  48743. private _setupSkyboxMaterial;
  48744. /**
  48745. * Setup the skybox reflection texture according to the specified options.
  48746. */
  48747. private _setupSkyboxReflectionTexture;
  48748. private _errorHandler;
  48749. /**
  48750. * Dispose all the elements created by the Helper.
  48751. */
  48752. dispose(): void;
  48753. }
  48754. }
  48755. declare module BABYLON {
  48756. /**
  48757. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48758. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48759. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48760. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48761. */
  48762. export class PhotoDome extends TransformNode {
  48763. /**
  48764. * Define the image as a Monoscopic panoramic 360 image.
  48765. */
  48766. static readonly MODE_MONOSCOPIC: number;
  48767. /**
  48768. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48769. */
  48770. static readonly MODE_TOPBOTTOM: number;
  48771. /**
  48772. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48773. */
  48774. static readonly MODE_SIDEBYSIDE: number;
  48775. private _useDirectMapping;
  48776. /**
  48777. * The texture being displayed on the sphere
  48778. */
  48779. protected _photoTexture: Texture;
  48780. /**
  48781. * Gets or sets the texture being displayed on the sphere
  48782. */
  48783. get photoTexture(): Texture;
  48784. set photoTexture(value: Texture);
  48785. /**
  48786. * Observable raised when an error occured while loading the 360 image
  48787. */
  48788. onLoadErrorObservable: Observable<string>;
  48789. /**
  48790. * The skybox material
  48791. */
  48792. protected _material: BackgroundMaterial;
  48793. /**
  48794. * The surface used for the skybox
  48795. */
  48796. protected _mesh: Mesh;
  48797. /**
  48798. * Gets the mesh used for the skybox.
  48799. */
  48800. get mesh(): Mesh;
  48801. /**
  48802. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48803. * Also see the options.resolution property.
  48804. */
  48805. get fovMultiplier(): number;
  48806. set fovMultiplier(value: number);
  48807. private _imageMode;
  48808. /**
  48809. * Gets or set the current video mode for the video. It can be:
  48810. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48811. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48812. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48813. */
  48814. get imageMode(): number;
  48815. set imageMode(value: number);
  48816. /**
  48817. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48818. * @param name Element's name, child elements will append suffixes for their own names.
  48819. * @param urlsOfPhoto defines the url of the photo to display
  48820. * @param options defines an object containing optional or exposed sub element properties
  48821. * @param onError defines a callback called when an error occured while loading the texture
  48822. */
  48823. constructor(name: string, urlOfPhoto: string, options: {
  48824. resolution?: number;
  48825. size?: number;
  48826. useDirectMapping?: boolean;
  48827. faceForward?: boolean;
  48828. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48829. private _onBeforeCameraRenderObserver;
  48830. private _changeImageMode;
  48831. /**
  48832. * Releases resources associated with this node.
  48833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48835. */
  48836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48837. }
  48838. }
  48839. declare module BABYLON {
  48840. /**
  48841. * Class used to host RGBD texture specific utilities
  48842. */
  48843. export class RGBDTextureTools {
  48844. /**
  48845. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48846. * @param texture the texture to expand.
  48847. */
  48848. static ExpandRGBDTexture(texture: Texture): void;
  48849. }
  48850. }
  48851. declare module BABYLON {
  48852. /**
  48853. * Class used to host texture specific utilities
  48854. */
  48855. export class BRDFTextureTools {
  48856. /**
  48857. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48858. * @param scene defines the hosting scene
  48859. * @returns the environment BRDF texture
  48860. */
  48861. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48862. private static _environmentBRDFBase64Texture;
  48863. }
  48864. }
  48865. declare module BABYLON {
  48866. /**
  48867. * @hidden
  48868. */
  48869. export interface IMaterialClearCoatDefines {
  48870. CLEARCOAT: boolean;
  48871. CLEARCOAT_DEFAULTIOR: boolean;
  48872. CLEARCOAT_TEXTURE: boolean;
  48873. CLEARCOAT_TEXTUREDIRECTUV: number;
  48874. CLEARCOAT_BUMP: boolean;
  48875. CLEARCOAT_BUMPDIRECTUV: number;
  48876. CLEARCOAT_TINT: boolean;
  48877. CLEARCOAT_TINT_TEXTURE: boolean;
  48878. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48879. /** @hidden */
  48880. _areTexturesDirty: boolean;
  48881. }
  48882. /**
  48883. * Define the code related to the clear coat parameters of the pbr material.
  48884. */
  48885. export class PBRClearCoatConfiguration {
  48886. /**
  48887. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48888. * The default fits with a polyurethane material.
  48889. */
  48890. private static readonly _DefaultIndexOfRefraction;
  48891. private _isEnabled;
  48892. /**
  48893. * Defines if the clear coat is enabled in the material.
  48894. */
  48895. isEnabled: boolean;
  48896. /**
  48897. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48898. */
  48899. intensity: number;
  48900. /**
  48901. * Defines the clear coat layer roughness.
  48902. */
  48903. roughness: number;
  48904. private _indexOfRefraction;
  48905. /**
  48906. * Defines the index of refraction of the clear coat.
  48907. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48908. * The default fits with a polyurethane material.
  48909. * Changing the default value is more performance intensive.
  48910. */
  48911. indexOfRefraction: number;
  48912. private _texture;
  48913. /**
  48914. * Stores the clear coat values in a texture.
  48915. */
  48916. texture: Nullable<BaseTexture>;
  48917. private _bumpTexture;
  48918. /**
  48919. * Define the clear coat specific bump texture.
  48920. */
  48921. bumpTexture: Nullable<BaseTexture>;
  48922. private _isTintEnabled;
  48923. /**
  48924. * Defines if the clear coat tint is enabled in the material.
  48925. */
  48926. isTintEnabled: boolean;
  48927. /**
  48928. * Defines the clear coat tint of the material.
  48929. * This is only use if tint is enabled
  48930. */
  48931. tintColor: Color3;
  48932. /**
  48933. * Defines the distance at which the tint color should be found in the
  48934. * clear coat media.
  48935. * This is only use if tint is enabled
  48936. */
  48937. tintColorAtDistance: number;
  48938. /**
  48939. * Defines the clear coat layer thickness.
  48940. * This is only use if tint is enabled
  48941. */
  48942. tintThickness: number;
  48943. private _tintTexture;
  48944. /**
  48945. * Stores the clear tint values in a texture.
  48946. * rgb is tint
  48947. * a is a thickness factor
  48948. */
  48949. tintTexture: Nullable<BaseTexture>;
  48950. /** @hidden */
  48951. private _internalMarkAllSubMeshesAsTexturesDirty;
  48952. /** @hidden */
  48953. _markAllSubMeshesAsTexturesDirty(): void;
  48954. /**
  48955. * Instantiate a new istance of clear coat configuration.
  48956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48957. */
  48958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48959. /**
  48960. * Gets wehter the submesh is ready to be used or not.
  48961. * @param defines the list of "defines" to update.
  48962. * @param scene defines the scene the material belongs to.
  48963. * @param engine defines the engine the material belongs to.
  48964. * @param disableBumpMap defines wether the material disables bump or not.
  48965. * @returns - boolean indicating that the submesh is ready or not.
  48966. */
  48967. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48968. /**
  48969. * Checks to see if a texture is used in the material.
  48970. * @param defines the list of "defines" to update.
  48971. * @param scene defines the scene to the material belongs to.
  48972. */
  48973. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48974. /**
  48975. * Binds the material data.
  48976. * @param uniformBuffer defines the Uniform buffer to fill in.
  48977. * @param scene defines the scene the material belongs to.
  48978. * @param engine defines the engine the material belongs to.
  48979. * @param disableBumpMap defines wether the material disables bump or not.
  48980. * @param isFrozen defines wether the material is frozen or not.
  48981. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48982. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48983. */
  48984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48985. /**
  48986. * Checks to see if a texture is used in the material.
  48987. * @param texture - Base texture to use.
  48988. * @returns - Boolean specifying if a texture is used in the material.
  48989. */
  48990. hasTexture(texture: BaseTexture): boolean;
  48991. /**
  48992. * Returns an array of the actively used textures.
  48993. * @param activeTextures Array of BaseTextures
  48994. */
  48995. getActiveTextures(activeTextures: BaseTexture[]): void;
  48996. /**
  48997. * Returns the animatable textures.
  48998. * @param animatables Array of animatable textures.
  48999. */
  49000. getAnimatables(animatables: IAnimatable[]): void;
  49001. /**
  49002. * Disposes the resources of the material.
  49003. * @param forceDisposeTextures - Forces the disposal of all textures.
  49004. */
  49005. dispose(forceDisposeTextures?: boolean): void;
  49006. /**
  49007. * Get the current class name of the texture useful for serialization or dynamic coding.
  49008. * @returns "PBRClearCoatConfiguration"
  49009. */
  49010. getClassName(): string;
  49011. /**
  49012. * Add fallbacks to the effect fallbacks list.
  49013. * @param defines defines the Base texture to use.
  49014. * @param fallbacks defines the current fallback list.
  49015. * @param currentRank defines the current fallback rank.
  49016. * @returns the new fallback rank.
  49017. */
  49018. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49019. /**
  49020. * Add the required uniforms to the current list.
  49021. * @param uniforms defines the current uniform list.
  49022. */
  49023. static AddUniforms(uniforms: string[]): void;
  49024. /**
  49025. * Add the required samplers to the current list.
  49026. * @param samplers defines the current sampler list.
  49027. */
  49028. static AddSamplers(samplers: string[]): void;
  49029. /**
  49030. * Add the required uniforms to the current buffer.
  49031. * @param uniformBuffer defines the current uniform buffer.
  49032. */
  49033. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49034. /**
  49035. * Makes a duplicate of the current configuration into another one.
  49036. * @param clearCoatConfiguration define the config where to copy the info
  49037. */
  49038. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49039. /**
  49040. * Serializes this clear coat configuration.
  49041. * @returns - An object with the serialized config.
  49042. */
  49043. serialize(): any;
  49044. /**
  49045. * Parses a anisotropy Configuration from a serialized object.
  49046. * @param source - Serialized object.
  49047. * @param scene Defines the scene we are parsing for
  49048. * @param rootUrl Defines the rootUrl to load from
  49049. */
  49050. parse(source: any, scene: Scene, rootUrl: string): void;
  49051. }
  49052. }
  49053. declare module BABYLON {
  49054. /**
  49055. * @hidden
  49056. */
  49057. export interface IMaterialAnisotropicDefines {
  49058. ANISOTROPIC: boolean;
  49059. ANISOTROPIC_TEXTURE: boolean;
  49060. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49061. MAINUV1: boolean;
  49062. _areTexturesDirty: boolean;
  49063. _needUVs: boolean;
  49064. }
  49065. /**
  49066. * Define the code related to the anisotropic parameters of the pbr material.
  49067. */
  49068. export class PBRAnisotropicConfiguration {
  49069. private _isEnabled;
  49070. /**
  49071. * Defines if the anisotropy is enabled in the material.
  49072. */
  49073. isEnabled: boolean;
  49074. /**
  49075. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49076. */
  49077. intensity: number;
  49078. /**
  49079. * Defines if the effect is along the tangents, bitangents or in between.
  49080. * By default, the effect is "strectching" the highlights along the tangents.
  49081. */
  49082. direction: Vector2;
  49083. private _texture;
  49084. /**
  49085. * Stores the anisotropy values in a texture.
  49086. * rg is direction (like normal from -1 to 1)
  49087. * b is a intensity
  49088. */
  49089. texture: Nullable<BaseTexture>;
  49090. /** @hidden */
  49091. private _internalMarkAllSubMeshesAsTexturesDirty;
  49092. /** @hidden */
  49093. _markAllSubMeshesAsTexturesDirty(): void;
  49094. /**
  49095. * Instantiate a new istance of anisotropy configuration.
  49096. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49097. */
  49098. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49099. /**
  49100. * Specifies that the submesh is ready to be used.
  49101. * @param defines the list of "defines" to update.
  49102. * @param scene defines the scene the material belongs to.
  49103. * @returns - boolean indicating that the submesh is ready or not.
  49104. */
  49105. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49106. /**
  49107. * Checks to see if a texture is used in the material.
  49108. * @param defines the list of "defines" to update.
  49109. * @param mesh the mesh we are preparing the defines for.
  49110. * @param scene defines the scene the material belongs to.
  49111. */
  49112. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49113. /**
  49114. * Binds the material data.
  49115. * @param uniformBuffer defines the Uniform buffer to fill in.
  49116. * @param scene defines the scene the material belongs to.
  49117. * @param isFrozen defines wether the material is frozen or not.
  49118. */
  49119. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49120. /**
  49121. * Checks to see if a texture is used in the material.
  49122. * @param texture - Base texture to use.
  49123. * @returns - Boolean specifying if a texture is used in the material.
  49124. */
  49125. hasTexture(texture: BaseTexture): boolean;
  49126. /**
  49127. * Returns an array of the actively used textures.
  49128. * @param activeTextures Array of BaseTextures
  49129. */
  49130. getActiveTextures(activeTextures: BaseTexture[]): void;
  49131. /**
  49132. * Returns the animatable textures.
  49133. * @param animatables Array of animatable textures.
  49134. */
  49135. getAnimatables(animatables: IAnimatable[]): void;
  49136. /**
  49137. * Disposes the resources of the material.
  49138. * @param forceDisposeTextures - Forces the disposal of all textures.
  49139. */
  49140. dispose(forceDisposeTextures?: boolean): void;
  49141. /**
  49142. * Get the current class name of the texture useful for serialization or dynamic coding.
  49143. * @returns "PBRAnisotropicConfiguration"
  49144. */
  49145. getClassName(): string;
  49146. /**
  49147. * Add fallbacks to the effect fallbacks list.
  49148. * @param defines defines the Base texture to use.
  49149. * @param fallbacks defines the current fallback list.
  49150. * @param currentRank defines the current fallback rank.
  49151. * @returns the new fallback rank.
  49152. */
  49153. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49154. /**
  49155. * Add the required uniforms to the current list.
  49156. * @param uniforms defines the current uniform list.
  49157. */
  49158. static AddUniforms(uniforms: string[]): void;
  49159. /**
  49160. * Add the required uniforms to the current buffer.
  49161. * @param uniformBuffer defines the current uniform buffer.
  49162. */
  49163. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49164. /**
  49165. * Add the required samplers to the current list.
  49166. * @param samplers defines the current sampler list.
  49167. */
  49168. static AddSamplers(samplers: string[]): void;
  49169. /**
  49170. * Makes a duplicate of the current configuration into another one.
  49171. * @param anisotropicConfiguration define the config where to copy the info
  49172. */
  49173. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49174. /**
  49175. * Serializes this anisotropy configuration.
  49176. * @returns - An object with the serialized config.
  49177. */
  49178. serialize(): any;
  49179. /**
  49180. * Parses a anisotropy Configuration from a serialized object.
  49181. * @param source - Serialized object.
  49182. * @param scene Defines the scene we are parsing for
  49183. * @param rootUrl Defines the rootUrl to load from
  49184. */
  49185. parse(source: any, scene: Scene, rootUrl: string): void;
  49186. }
  49187. }
  49188. declare module BABYLON {
  49189. /**
  49190. * @hidden
  49191. */
  49192. export interface IMaterialBRDFDefines {
  49193. BRDF_V_HEIGHT_CORRELATED: boolean;
  49194. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49195. SPHERICAL_HARMONICS: boolean;
  49196. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49197. /** @hidden */
  49198. _areMiscDirty: boolean;
  49199. }
  49200. /**
  49201. * Define the code related to the BRDF parameters of the pbr material.
  49202. */
  49203. export class PBRBRDFConfiguration {
  49204. /**
  49205. * Default value used for the energy conservation.
  49206. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49207. */
  49208. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49209. /**
  49210. * Default value used for the Smith Visibility Height Correlated mode.
  49211. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49212. */
  49213. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49214. /**
  49215. * Default value used for the IBL diffuse part.
  49216. * This can help switching back to the polynomials mode globally which is a tiny bit
  49217. * less GPU intensive at the drawback of a lower quality.
  49218. */
  49219. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49220. /**
  49221. * Default value used for activating energy conservation for the specular workflow.
  49222. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49223. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49224. */
  49225. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49226. private _useEnergyConservation;
  49227. /**
  49228. * Defines if the material uses energy conservation.
  49229. */
  49230. useEnergyConservation: boolean;
  49231. private _useSmithVisibilityHeightCorrelated;
  49232. /**
  49233. * LEGACY Mode set to false
  49234. * Defines if the material uses height smith correlated visibility term.
  49235. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49236. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49237. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49238. * Not relying on height correlated will also disable energy conservation.
  49239. */
  49240. useSmithVisibilityHeightCorrelated: boolean;
  49241. private _useSphericalHarmonics;
  49242. /**
  49243. * LEGACY Mode set to false
  49244. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49245. * diffuse part of the IBL.
  49246. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49247. * to the ground truth.
  49248. */
  49249. useSphericalHarmonics: boolean;
  49250. private _useSpecularGlossinessInputEnergyConservation;
  49251. /**
  49252. * Defines if the material uses energy conservation, when the specular workflow is active.
  49253. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49254. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49255. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49256. */
  49257. useSpecularGlossinessInputEnergyConservation: boolean;
  49258. /** @hidden */
  49259. private _internalMarkAllSubMeshesAsMiscDirty;
  49260. /** @hidden */
  49261. _markAllSubMeshesAsMiscDirty(): void;
  49262. /**
  49263. * Instantiate a new istance of clear coat configuration.
  49264. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49265. */
  49266. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49267. /**
  49268. * Checks to see if a texture is used in the material.
  49269. * @param defines the list of "defines" to update.
  49270. */
  49271. prepareDefines(defines: IMaterialBRDFDefines): void;
  49272. /**
  49273. * Get the current class name of the texture useful for serialization or dynamic coding.
  49274. * @returns "PBRClearCoatConfiguration"
  49275. */
  49276. getClassName(): string;
  49277. /**
  49278. * Makes a duplicate of the current configuration into another one.
  49279. * @param brdfConfiguration define the config where to copy the info
  49280. */
  49281. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49282. /**
  49283. * Serializes this BRDF configuration.
  49284. * @returns - An object with the serialized config.
  49285. */
  49286. serialize(): any;
  49287. /**
  49288. * Parses a anisotropy Configuration from a serialized object.
  49289. * @param source - Serialized object.
  49290. * @param scene Defines the scene we are parsing for
  49291. * @param rootUrl Defines the rootUrl to load from
  49292. */
  49293. parse(source: any, scene: Scene, rootUrl: string): void;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * @hidden
  49299. */
  49300. export interface IMaterialSheenDefines {
  49301. SHEEN: boolean;
  49302. SHEEN_TEXTURE: boolean;
  49303. SHEEN_TEXTUREDIRECTUV: number;
  49304. SHEEN_LINKWITHALBEDO: boolean;
  49305. /** @hidden */
  49306. _areTexturesDirty: boolean;
  49307. }
  49308. /**
  49309. * Define the code related to the Sheen parameters of the pbr material.
  49310. */
  49311. export class PBRSheenConfiguration {
  49312. private _isEnabled;
  49313. /**
  49314. * Defines if the material uses sheen.
  49315. */
  49316. isEnabled: boolean;
  49317. private _linkSheenWithAlbedo;
  49318. /**
  49319. * Defines if the sheen is linked to the sheen color.
  49320. */
  49321. linkSheenWithAlbedo: boolean;
  49322. /**
  49323. * Defines the sheen intensity.
  49324. */
  49325. intensity: number;
  49326. /**
  49327. * Defines the sheen color.
  49328. */
  49329. color: Color3;
  49330. private _texture;
  49331. /**
  49332. * Stores the sheen tint values in a texture.
  49333. * rgb is tint
  49334. * a is a intensity
  49335. */
  49336. texture: Nullable<BaseTexture>;
  49337. /** @hidden */
  49338. private _internalMarkAllSubMeshesAsTexturesDirty;
  49339. /** @hidden */
  49340. _markAllSubMeshesAsTexturesDirty(): void;
  49341. /**
  49342. * Instantiate a new istance of clear coat configuration.
  49343. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49344. */
  49345. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49346. /**
  49347. * Specifies that the submesh is ready to be used.
  49348. * @param defines the list of "defines" to update.
  49349. * @param scene defines the scene the material belongs to.
  49350. * @returns - boolean indicating that the submesh is ready or not.
  49351. */
  49352. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49353. /**
  49354. * Checks to see if a texture is used in the material.
  49355. * @param defines the list of "defines" to update.
  49356. * @param scene defines the scene the material belongs to.
  49357. */
  49358. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49359. /**
  49360. * Binds the material data.
  49361. * @param uniformBuffer defines the Uniform buffer to fill in.
  49362. * @param scene defines the scene the material belongs to.
  49363. * @param isFrozen defines wether the material is frozen or not.
  49364. */
  49365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49366. /**
  49367. * Checks to see if a texture is used in the material.
  49368. * @param texture - Base texture to use.
  49369. * @returns - Boolean specifying if a texture is used in the material.
  49370. */
  49371. hasTexture(texture: BaseTexture): boolean;
  49372. /**
  49373. * Returns an array of the actively used textures.
  49374. * @param activeTextures Array of BaseTextures
  49375. */
  49376. getActiveTextures(activeTextures: BaseTexture[]): void;
  49377. /**
  49378. * Returns the animatable textures.
  49379. * @param animatables Array of animatable textures.
  49380. */
  49381. getAnimatables(animatables: IAnimatable[]): void;
  49382. /**
  49383. * Disposes the resources of the material.
  49384. * @param forceDisposeTextures - Forces the disposal of all textures.
  49385. */
  49386. dispose(forceDisposeTextures?: boolean): void;
  49387. /**
  49388. * Get the current class name of the texture useful for serialization or dynamic coding.
  49389. * @returns "PBRSheenConfiguration"
  49390. */
  49391. getClassName(): string;
  49392. /**
  49393. * Add fallbacks to the effect fallbacks list.
  49394. * @param defines defines the Base texture to use.
  49395. * @param fallbacks defines the current fallback list.
  49396. * @param currentRank defines the current fallback rank.
  49397. * @returns the new fallback rank.
  49398. */
  49399. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49400. /**
  49401. * Add the required uniforms to the current list.
  49402. * @param uniforms defines the current uniform list.
  49403. */
  49404. static AddUniforms(uniforms: string[]): void;
  49405. /**
  49406. * Add the required uniforms to the current buffer.
  49407. * @param uniformBuffer defines the current uniform buffer.
  49408. */
  49409. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49410. /**
  49411. * Add the required samplers to the current list.
  49412. * @param samplers defines the current sampler list.
  49413. */
  49414. static AddSamplers(samplers: string[]): void;
  49415. /**
  49416. * Makes a duplicate of the current configuration into another one.
  49417. * @param sheenConfiguration define the config where to copy the info
  49418. */
  49419. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49420. /**
  49421. * Serializes this BRDF configuration.
  49422. * @returns - An object with the serialized config.
  49423. */
  49424. serialize(): any;
  49425. /**
  49426. * Parses a anisotropy Configuration from a serialized object.
  49427. * @param source - Serialized object.
  49428. * @param scene Defines the scene we are parsing for
  49429. * @param rootUrl Defines the rootUrl to load from
  49430. */
  49431. parse(source: any, scene: Scene, rootUrl: string): void;
  49432. }
  49433. }
  49434. declare module BABYLON {
  49435. /**
  49436. * @hidden
  49437. */
  49438. export interface IMaterialSubSurfaceDefines {
  49439. SUBSURFACE: boolean;
  49440. SS_REFRACTION: boolean;
  49441. SS_TRANSLUCENCY: boolean;
  49442. SS_SCATERRING: boolean;
  49443. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49444. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49445. SS_REFRACTIONMAP_3D: boolean;
  49446. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49447. SS_LODINREFRACTIONALPHA: boolean;
  49448. SS_GAMMAREFRACTION: boolean;
  49449. SS_RGBDREFRACTION: boolean;
  49450. SS_LINEARSPECULARREFRACTION: boolean;
  49451. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49452. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49453. /** @hidden */
  49454. _areTexturesDirty: boolean;
  49455. }
  49456. /**
  49457. * Define the code related to the sub surface parameters of the pbr material.
  49458. */
  49459. export class PBRSubSurfaceConfiguration {
  49460. private _isRefractionEnabled;
  49461. /**
  49462. * Defines if the refraction is enabled in the material.
  49463. */
  49464. isRefractionEnabled: boolean;
  49465. private _isTranslucencyEnabled;
  49466. /**
  49467. * Defines if the translucency is enabled in the material.
  49468. */
  49469. isTranslucencyEnabled: boolean;
  49470. private _isScatteringEnabled;
  49471. /**
  49472. * Defines the refraction intensity of the material.
  49473. * The refraction when enabled replaces the Diffuse part of the material.
  49474. * The intensity helps transitionning between diffuse and refraction.
  49475. */
  49476. refractionIntensity: number;
  49477. /**
  49478. * Defines the translucency intensity of the material.
  49479. * When translucency has been enabled, this defines how much of the "translucency"
  49480. * is addded to the diffuse part of the material.
  49481. */
  49482. translucencyIntensity: number;
  49483. /**
  49484. * Defines the scattering intensity of the material.
  49485. * When scattering has been enabled, this defines how much of the "scattered light"
  49486. * is addded to the diffuse part of the material.
  49487. */
  49488. scatteringIntensity: number;
  49489. private _thicknessTexture;
  49490. /**
  49491. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49492. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49493. * 0 would mean minimumThickness
  49494. * 1 would mean maximumThickness
  49495. * The other channels might be use as a mask to vary the different effects intensity.
  49496. */
  49497. thicknessTexture: Nullable<BaseTexture>;
  49498. private _refractionTexture;
  49499. /**
  49500. * Defines the texture to use for refraction.
  49501. */
  49502. refractionTexture: Nullable<BaseTexture>;
  49503. private _indexOfRefraction;
  49504. /**
  49505. * Defines the index of refraction used in the material.
  49506. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49507. */
  49508. indexOfRefraction: number;
  49509. private _invertRefractionY;
  49510. /**
  49511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49512. */
  49513. invertRefractionY: boolean;
  49514. private _linkRefractionWithTransparency;
  49515. /**
  49516. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49517. * Materials half opaque for instance using refraction could benefit from this control.
  49518. */
  49519. linkRefractionWithTransparency: boolean;
  49520. /**
  49521. * Defines the minimum thickness stored in the thickness map.
  49522. * If no thickness map is defined, this value will be used to simulate thickness.
  49523. */
  49524. minimumThickness: number;
  49525. /**
  49526. * Defines the maximum thickness stored in the thickness map.
  49527. */
  49528. maximumThickness: number;
  49529. /**
  49530. * Defines the volume tint of the material.
  49531. * This is used for both translucency and scattering.
  49532. */
  49533. tintColor: Color3;
  49534. /**
  49535. * Defines the distance at which the tint color should be found in the media.
  49536. * This is used for refraction only.
  49537. */
  49538. tintColorAtDistance: number;
  49539. /**
  49540. * Defines how far each channel transmit through the media.
  49541. * It is defined as a color to simplify it selection.
  49542. */
  49543. diffusionDistance: Color3;
  49544. private _useMaskFromThicknessTexture;
  49545. /**
  49546. * Stores the intensity of the different subsurface effects in the thickness texture.
  49547. * * the green channel is the translucency intensity.
  49548. * * the blue channel is the scattering intensity.
  49549. * * the alpha channel is the refraction intensity.
  49550. */
  49551. useMaskFromThicknessTexture: boolean;
  49552. /** @hidden */
  49553. private _internalMarkAllSubMeshesAsTexturesDirty;
  49554. /** @hidden */
  49555. _markAllSubMeshesAsTexturesDirty(): void;
  49556. /**
  49557. * Instantiate a new istance of sub surface configuration.
  49558. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49559. */
  49560. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49561. /**
  49562. * Gets wehter the submesh is ready to be used or not.
  49563. * @param defines the list of "defines" to update.
  49564. * @param scene defines the scene the material belongs to.
  49565. * @returns - boolean indicating that the submesh is ready or not.
  49566. */
  49567. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49568. /**
  49569. * Checks to see if a texture is used in the material.
  49570. * @param defines the list of "defines" to update.
  49571. * @param scene defines the scene to the material belongs to.
  49572. */
  49573. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49574. /**
  49575. * Binds the material data.
  49576. * @param uniformBuffer defines the Uniform buffer to fill in.
  49577. * @param scene defines the scene the material belongs to.
  49578. * @param engine defines the engine the material belongs to.
  49579. * @param isFrozen defines wether the material is frozen or not.
  49580. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49581. */
  49582. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49583. /**
  49584. * Unbinds the material from the mesh.
  49585. * @param activeEffect defines the effect that should be unbound from.
  49586. * @returns true if unbound, otherwise false
  49587. */
  49588. unbind(activeEffect: Effect): boolean;
  49589. /**
  49590. * Returns the texture used for refraction or null if none is used.
  49591. * @param scene defines the scene the material belongs to.
  49592. * @returns - Refraction texture if present. If no refraction texture and refraction
  49593. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49594. */
  49595. private _getRefractionTexture;
  49596. /**
  49597. * Returns true if alpha blending should be disabled.
  49598. */
  49599. get disableAlphaBlending(): boolean;
  49600. /**
  49601. * Fills the list of render target textures.
  49602. * @param renderTargets the list of render targets to update
  49603. */
  49604. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49605. /**
  49606. * Checks to see if a texture is used in the material.
  49607. * @param texture - Base texture to use.
  49608. * @returns - Boolean specifying if a texture is used in the material.
  49609. */
  49610. hasTexture(texture: BaseTexture): boolean;
  49611. /**
  49612. * Gets a boolean indicating that current material needs to register RTT
  49613. * @returns true if this uses a render target otherwise false.
  49614. */
  49615. hasRenderTargetTextures(): boolean;
  49616. /**
  49617. * Returns an array of the actively used textures.
  49618. * @param activeTextures Array of BaseTextures
  49619. */
  49620. getActiveTextures(activeTextures: BaseTexture[]): void;
  49621. /**
  49622. * Returns the animatable textures.
  49623. * @param animatables Array of animatable textures.
  49624. */
  49625. getAnimatables(animatables: IAnimatable[]): void;
  49626. /**
  49627. * Disposes the resources of the material.
  49628. * @param forceDisposeTextures - Forces the disposal of all textures.
  49629. */
  49630. dispose(forceDisposeTextures?: boolean): void;
  49631. /**
  49632. * Get the current class name of the texture useful for serialization or dynamic coding.
  49633. * @returns "PBRSubSurfaceConfiguration"
  49634. */
  49635. getClassName(): string;
  49636. /**
  49637. * Add fallbacks to the effect fallbacks list.
  49638. * @param defines defines the Base texture to use.
  49639. * @param fallbacks defines the current fallback list.
  49640. * @param currentRank defines the current fallback rank.
  49641. * @returns the new fallback rank.
  49642. */
  49643. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49644. /**
  49645. * Add the required uniforms to the current list.
  49646. * @param uniforms defines the current uniform list.
  49647. */
  49648. static AddUniforms(uniforms: string[]): void;
  49649. /**
  49650. * Add the required samplers to the current list.
  49651. * @param samplers defines the current sampler list.
  49652. */
  49653. static AddSamplers(samplers: string[]): void;
  49654. /**
  49655. * Add the required uniforms to the current buffer.
  49656. * @param uniformBuffer defines the current uniform buffer.
  49657. */
  49658. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49659. /**
  49660. * Makes a duplicate of the current configuration into another one.
  49661. * @param configuration define the config where to copy the info
  49662. */
  49663. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49664. /**
  49665. * Serializes this Sub Surface configuration.
  49666. * @returns - An object with the serialized config.
  49667. */
  49668. serialize(): any;
  49669. /**
  49670. * Parses a anisotropy Configuration from a serialized object.
  49671. * @param source - Serialized object.
  49672. * @param scene Defines the scene we are parsing for
  49673. * @param rootUrl Defines the rootUrl to load from
  49674. */
  49675. parse(source: any, scene: Scene, rootUrl: string): void;
  49676. }
  49677. }
  49678. declare module BABYLON {
  49679. /** @hidden */
  49680. export var pbrFragmentDeclaration: {
  49681. name: string;
  49682. shader: string;
  49683. };
  49684. }
  49685. declare module BABYLON {
  49686. /** @hidden */
  49687. export var pbrUboDeclaration: {
  49688. name: string;
  49689. shader: string;
  49690. };
  49691. }
  49692. declare module BABYLON {
  49693. /** @hidden */
  49694. export var pbrFragmentExtraDeclaration: {
  49695. name: string;
  49696. shader: string;
  49697. };
  49698. }
  49699. declare module BABYLON {
  49700. /** @hidden */
  49701. export var pbrFragmentSamplersDeclaration: {
  49702. name: string;
  49703. shader: string;
  49704. };
  49705. }
  49706. declare module BABYLON {
  49707. /** @hidden */
  49708. export var pbrHelperFunctions: {
  49709. name: string;
  49710. shader: string;
  49711. };
  49712. }
  49713. declare module BABYLON {
  49714. /** @hidden */
  49715. export var harmonicsFunctions: {
  49716. name: string;
  49717. shader: string;
  49718. };
  49719. }
  49720. declare module BABYLON {
  49721. /** @hidden */
  49722. export var pbrDirectLightingSetupFunctions: {
  49723. name: string;
  49724. shader: string;
  49725. };
  49726. }
  49727. declare module BABYLON {
  49728. /** @hidden */
  49729. export var pbrDirectLightingFalloffFunctions: {
  49730. name: string;
  49731. shader: string;
  49732. };
  49733. }
  49734. declare module BABYLON {
  49735. /** @hidden */
  49736. export var pbrBRDFFunctions: {
  49737. name: string;
  49738. shader: string;
  49739. };
  49740. }
  49741. declare module BABYLON {
  49742. /** @hidden */
  49743. export var pbrDirectLightingFunctions: {
  49744. name: string;
  49745. shader: string;
  49746. };
  49747. }
  49748. declare module BABYLON {
  49749. /** @hidden */
  49750. export var pbrIBLFunctions: {
  49751. name: string;
  49752. shader: string;
  49753. };
  49754. }
  49755. declare module BABYLON {
  49756. /** @hidden */
  49757. export var pbrDebug: {
  49758. name: string;
  49759. shader: string;
  49760. };
  49761. }
  49762. declare module BABYLON {
  49763. /** @hidden */
  49764. export var pbrPixelShader: {
  49765. name: string;
  49766. shader: string;
  49767. };
  49768. }
  49769. declare module BABYLON {
  49770. /** @hidden */
  49771. export var pbrVertexDeclaration: {
  49772. name: string;
  49773. shader: string;
  49774. };
  49775. }
  49776. declare module BABYLON {
  49777. /** @hidden */
  49778. export var pbrVertexShader: {
  49779. name: string;
  49780. shader: string;
  49781. };
  49782. }
  49783. declare module BABYLON {
  49784. /**
  49785. * Manages the defines for the PBR Material.
  49786. * @hidden
  49787. */
  49788. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49789. PBR: boolean;
  49790. MAINUV1: boolean;
  49791. MAINUV2: boolean;
  49792. UV1: boolean;
  49793. UV2: boolean;
  49794. ALBEDO: boolean;
  49795. ALBEDODIRECTUV: number;
  49796. VERTEXCOLOR: boolean;
  49797. AMBIENT: boolean;
  49798. AMBIENTDIRECTUV: number;
  49799. AMBIENTINGRAYSCALE: boolean;
  49800. OPACITY: boolean;
  49801. VERTEXALPHA: boolean;
  49802. OPACITYDIRECTUV: number;
  49803. OPACITYRGB: boolean;
  49804. ALPHATEST: boolean;
  49805. DEPTHPREPASS: boolean;
  49806. ALPHABLEND: boolean;
  49807. ALPHAFROMALBEDO: boolean;
  49808. ALPHATESTVALUE: string;
  49809. SPECULAROVERALPHA: boolean;
  49810. RADIANCEOVERALPHA: boolean;
  49811. ALPHAFRESNEL: boolean;
  49812. LINEARALPHAFRESNEL: boolean;
  49813. PREMULTIPLYALPHA: boolean;
  49814. EMISSIVE: boolean;
  49815. EMISSIVEDIRECTUV: number;
  49816. REFLECTIVITY: boolean;
  49817. REFLECTIVITYDIRECTUV: number;
  49818. SPECULARTERM: boolean;
  49819. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49820. MICROSURFACEAUTOMATIC: boolean;
  49821. LODBASEDMICROSFURACE: boolean;
  49822. MICROSURFACEMAP: boolean;
  49823. MICROSURFACEMAPDIRECTUV: number;
  49824. METALLICWORKFLOW: boolean;
  49825. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49826. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49827. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49828. AOSTOREINMETALMAPRED: boolean;
  49829. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49830. ENVIRONMENTBRDF: boolean;
  49831. ENVIRONMENTBRDF_RGBD: boolean;
  49832. NORMAL: boolean;
  49833. TANGENT: boolean;
  49834. BUMP: boolean;
  49835. BUMPDIRECTUV: number;
  49836. OBJECTSPACE_NORMALMAP: boolean;
  49837. PARALLAX: boolean;
  49838. PARALLAXOCCLUSION: boolean;
  49839. NORMALXYSCALE: boolean;
  49840. LIGHTMAP: boolean;
  49841. LIGHTMAPDIRECTUV: number;
  49842. USELIGHTMAPASSHADOWMAP: boolean;
  49843. GAMMALIGHTMAP: boolean;
  49844. RGBDLIGHTMAP: boolean;
  49845. REFLECTION: boolean;
  49846. REFLECTIONMAP_3D: boolean;
  49847. REFLECTIONMAP_SPHERICAL: boolean;
  49848. REFLECTIONMAP_PLANAR: boolean;
  49849. REFLECTIONMAP_CUBIC: boolean;
  49850. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49851. REFLECTIONMAP_PROJECTION: boolean;
  49852. REFLECTIONMAP_SKYBOX: boolean;
  49853. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49854. REFLECTIONMAP_EXPLICIT: boolean;
  49855. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49856. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49857. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49858. INVERTCUBICMAP: boolean;
  49859. USESPHERICALFROMREFLECTIONMAP: boolean;
  49860. USEIRRADIANCEMAP: boolean;
  49861. SPHERICAL_HARMONICS: boolean;
  49862. USESPHERICALINVERTEX: boolean;
  49863. REFLECTIONMAP_OPPOSITEZ: boolean;
  49864. LODINREFLECTIONALPHA: boolean;
  49865. GAMMAREFLECTION: boolean;
  49866. RGBDREFLECTION: boolean;
  49867. LINEARSPECULARREFLECTION: boolean;
  49868. RADIANCEOCCLUSION: boolean;
  49869. HORIZONOCCLUSION: boolean;
  49870. INSTANCES: boolean;
  49871. NUM_BONE_INFLUENCERS: number;
  49872. BonesPerMesh: number;
  49873. BONETEXTURE: boolean;
  49874. NONUNIFORMSCALING: boolean;
  49875. MORPHTARGETS: boolean;
  49876. MORPHTARGETS_NORMAL: boolean;
  49877. MORPHTARGETS_TANGENT: boolean;
  49878. MORPHTARGETS_UV: boolean;
  49879. NUM_MORPH_INFLUENCERS: number;
  49880. IMAGEPROCESSING: boolean;
  49881. VIGNETTE: boolean;
  49882. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49883. VIGNETTEBLENDMODEOPAQUE: boolean;
  49884. TONEMAPPING: boolean;
  49885. TONEMAPPING_ACES: boolean;
  49886. CONTRAST: boolean;
  49887. COLORCURVES: boolean;
  49888. COLORGRADING: boolean;
  49889. COLORGRADING3D: boolean;
  49890. SAMPLER3DGREENDEPTH: boolean;
  49891. SAMPLER3DBGRMAP: boolean;
  49892. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49893. EXPOSURE: boolean;
  49894. MULTIVIEW: boolean;
  49895. USEPHYSICALLIGHTFALLOFF: boolean;
  49896. USEGLTFLIGHTFALLOFF: boolean;
  49897. TWOSIDEDLIGHTING: boolean;
  49898. SHADOWFLOAT: boolean;
  49899. CLIPPLANE: boolean;
  49900. CLIPPLANE2: boolean;
  49901. CLIPPLANE3: boolean;
  49902. CLIPPLANE4: boolean;
  49903. CLIPPLANE5: boolean;
  49904. CLIPPLANE6: boolean;
  49905. POINTSIZE: boolean;
  49906. FOG: boolean;
  49907. LOGARITHMICDEPTH: boolean;
  49908. FORCENORMALFORWARD: boolean;
  49909. SPECULARAA: boolean;
  49910. CLEARCOAT: boolean;
  49911. CLEARCOAT_DEFAULTIOR: boolean;
  49912. CLEARCOAT_TEXTURE: boolean;
  49913. CLEARCOAT_TEXTUREDIRECTUV: number;
  49914. CLEARCOAT_BUMP: boolean;
  49915. CLEARCOAT_BUMPDIRECTUV: number;
  49916. CLEARCOAT_TINT: boolean;
  49917. CLEARCOAT_TINT_TEXTURE: boolean;
  49918. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49919. ANISOTROPIC: boolean;
  49920. ANISOTROPIC_TEXTURE: boolean;
  49921. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49922. BRDF_V_HEIGHT_CORRELATED: boolean;
  49923. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49924. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49925. SHEEN: boolean;
  49926. SHEEN_TEXTURE: boolean;
  49927. SHEEN_TEXTUREDIRECTUV: number;
  49928. SHEEN_LINKWITHALBEDO: boolean;
  49929. SUBSURFACE: boolean;
  49930. SS_REFRACTION: boolean;
  49931. SS_TRANSLUCENCY: boolean;
  49932. SS_SCATERRING: boolean;
  49933. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49934. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49935. SS_REFRACTIONMAP_3D: boolean;
  49936. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49937. SS_LODINREFRACTIONALPHA: boolean;
  49938. SS_GAMMAREFRACTION: boolean;
  49939. SS_RGBDREFRACTION: boolean;
  49940. SS_LINEARSPECULARREFRACTION: boolean;
  49941. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49942. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49943. UNLIT: boolean;
  49944. DEBUGMODE: number;
  49945. /**
  49946. * Initializes the PBR Material defines.
  49947. */
  49948. constructor();
  49949. /**
  49950. * Resets the PBR Material defines.
  49951. */
  49952. reset(): void;
  49953. }
  49954. /**
  49955. * The Physically based material base class of BJS.
  49956. *
  49957. * This offers the main features of a standard PBR material.
  49958. * For more information, please refer to the documentation :
  49959. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49960. */
  49961. export abstract class PBRBaseMaterial extends PushMaterial {
  49962. /**
  49963. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49964. */
  49965. static readonly PBRMATERIAL_OPAQUE: number;
  49966. /**
  49967. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49968. */
  49969. static readonly PBRMATERIAL_ALPHATEST: number;
  49970. /**
  49971. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49972. */
  49973. static readonly PBRMATERIAL_ALPHABLEND: number;
  49974. /**
  49975. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49976. * They are also discarded below the alpha cutoff threshold to improve performances.
  49977. */
  49978. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49979. /**
  49980. * Defines the default value of how much AO map is occluding the analytical lights
  49981. * (point spot...).
  49982. */
  49983. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49984. /**
  49985. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49986. */
  49987. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49988. /**
  49989. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49990. * to enhance interoperability with other engines.
  49991. */
  49992. static readonly LIGHTFALLOFF_GLTF: number;
  49993. /**
  49994. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49995. * to enhance interoperability with other materials.
  49996. */
  49997. static readonly LIGHTFALLOFF_STANDARD: number;
  49998. /**
  49999. * Intensity of the direct lights e.g. the four lights available in your scene.
  50000. * This impacts both the direct diffuse and specular highlights.
  50001. */
  50002. protected _directIntensity: number;
  50003. /**
  50004. * Intensity of the emissive part of the material.
  50005. * This helps controlling the emissive effect without modifying the emissive color.
  50006. */
  50007. protected _emissiveIntensity: number;
  50008. /**
  50009. * Intensity of the environment e.g. how much the environment will light the object
  50010. * either through harmonics for rough material or through the refelction for shiny ones.
  50011. */
  50012. protected _environmentIntensity: number;
  50013. /**
  50014. * This is a special control allowing the reduction of the specular highlights coming from the
  50015. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50016. */
  50017. protected _specularIntensity: number;
  50018. /**
  50019. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50020. */
  50021. private _lightingInfos;
  50022. /**
  50023. * Debug Control allowing disabling the bump map on this material.
  50024. */
  50025. protected _disableBumpMap: boolean;
  50026. /**
  50027. * AKA Diffuse Texture in standard nomenclature.
  50028. */
  50029. protected _albedoTexture: Nullable<BaseTexture>;
  50030. /**
  50031. * AKA Occlusion Texture in other nomenclature.
  50032. */
  50033. protected _ambientTexture: Nullable<BaseTexture>;
  50034. /**
  50035. * AKA Occlusion Texture Intensity in other nomenclature.
  50036. */
  50037. protected _ambientTextureStrength: number;
  50038. /**
  50039. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50040. * 1 means it completely occludes it
  50041. * 0 mean it has no impact
  50042. */
  50043. protected _ambientTextureImpactOnAnalyticalLights: number;
  50044. /**
  50045. * Stores the alpha values in a texture.
  50046. */
  50047. protected _opacityTexture: Nullable<BaseTexture>;
  50048. /**
  50049. * Stores the reflection values in a texture.
  50050. */
  50051. protected _reflectionTexture: Nullable<BaseTexture>;
  50052. /**
  50053. * Stores the emissive values in a texture.
  50054. */
  50055. protected _emissiveTexture: Nullable<BaseTexture>;
  50056. /**
  50057. * AKA Specular texture in other nomenclature.
  50058. */
  50059. protected _reflectivityTexture: Nullable<BaseTexture>;
  50060. /**
  50061. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50062. */
  50063. protected _metallicTexture: Nullable<BaseTexture>;
  50064. /**
  50065. * Specifies the metallic scalar of the metallic/roughness workflow.
  50066. * Can also be used to scale the metalness values of the metallic texture.
  50067. */
  50068. protected _metallic: Nullable<number>;
  50069. /**
  50070. * Specifies the roughness scalar of the metallic/roughness workflow.
  50071. * Can also be used to scale the roughness values of the metallic texture.
  50072. */
  50073. protected _roughness: Nullable<number>;
  50074. /**
  50075. * Specifies the an F0 factor to help configuring the material F0.
  50076. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50077. * to 0.5 the previously hard coded value stays the same.
  50078. * Can also be used to scale the F0 values of the metallic texture.
  50079. */
  50080. protected _metallicF0Factor: number;
  50081. /**
  50082. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50083. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50084. * your expectation as it multiplies with the texture data.
  50085. */
  50086. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50087. /**
  50088. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50089. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50090. */
  50091. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50092. /**
  50093. * Stores surface normal data used to displace a mesh in a texture.
  50094. */
  50095. protected _bumpTexture: Nullable<BaseTexture>;
  50096. /**
  50097. * Stores the pre-calculated light information of a mesh in a texture.
  50098. */
  50099. protected _lightmapTexture: Nullable<BaseTexture>;
  50100. /**
  50101. * The color of a material in ambient lighting.
  50102. */
  50103. protected _ambientColor: Color3;
  50104. /**
  50105. * AKA Diffuse Color in other nomenclature.
  50106. */
  50107. protected _albedoColor: Color3;
  50108. /**
  50109. * AKA Specular Color in other nomenclature.
  50110. */
  50111. protected _reflectivityColor: Color3;
  50112. /**
  50113. * The color applied when light is reflected from a material.
  50114. */
  50115. protected _reflectionColor: Color3;
  50116. /**
  50117. * The color applied when light is emitted from a material.
  50118. */
  50119. protected _emissiveColor: Color3;
  50120. /**
  50121. * AKA Glossiness in other nomenclature.
  50122. */
  50123. protected _microSurface: number;
  50124. /**
  50125. * Specifies that the material will use the light map as a show map.
  50126. */
  50127. protected _useLightmapAsShadowmap: boolean;
  50128. /**
  50129. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50130. * makes the reflect vector face the model (under horizon).
  50131. */
  50132. protected _useHorizonOcclusion: boolean;
  50133. /**
  50134. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50135. * too much the area relying on ambient texture to define their ambient occlusion.
  50136. */
  50137. protected _useRadianceOcclusion: boolean;
  50138. /**
  50139. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50140. */
  50141. protected _useAlphaFromAlbedoTexture: boolean;
  50142. /**
  50143. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50145. */
  50146. protected _useSpecularOverAlpha: boolean;
  50147. /**
  50148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50149. */
  50150. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50151. /**
  50152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50153. */
  50154. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50155. /**
  50156. * Specifies if the metallic texture contains the roughness information in its green channel.
  50157. */
  50158. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50159. /**
  50160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50161. */
  50162. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50163. /**
  50164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50165. */
  50166. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50167. /**
  50168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50169. */
  50170. protected _useAmbientInGrayScale: boolean;
  50171. /**
  50172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50173. * The material will try to infer what glossiness each pixel should be.
  50174. */
  50175. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50176. /**
  50177. * Defines the falloff type used in this material.
  50178. * It by default is Physical.
  50179. */
  50180. protected _lightFalloff: number;
  50181. /**
  50182. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50183. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50184. */
  50185. protected _useRadianceOverAlpha: boolean;
  50186. /**
  50187. * Allows using an object space normal map (instead of tangent space).
  50188. */
  50189. protected _useObjectSpaceNormalMap: boolean;
  50190. /**
  50191. * Allows using the bump map in parallax mode.
  50192. */
  50193. protected _useParallax: boolean;
  50194. /**
  50195. * Allows using the bump map in parallax occlusion mode.
  50196. */
  50197. protected _useParallaxOcclusion: boolean;
  50198. /**
  50199. * Controls the scale bias of the parallax mode.
  50200. */
  50201. protected _parallaxScaleBias: number;
  50202. /**
  50203. * If sets to true, disables all the lights affecting the material.
  50204. */
  50205. protected _disableLighting: boolean;
  50206. /**
  50207. * Number of Simultaneous lights allowed on the material.
  50208. */
  50209. protected _maxSimultaneousLights: number;
  50210. /**
  50211. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50212. */
  50213. protected _invertNormalMapX: boolean;
  50214. /**
  50215. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50216. */
  50217. protected _invertNormalMapY: boolean;
  50218. /**
  50219. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50220. */
  50221. protected _twoSidedLighting: boolean;
  50222. /**
  50223. * Defines the alpha limits in alpha test mode.
  50224. */
  50225. protected _alphaCutOff: number;
  50226. /**
  50227. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50228. */
  50229. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  50233. */
  50234. protected _useAlphaFresnel: boolean;
  50235. /**
  50236. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50237. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50238. */
  50239. protected _useLinearAlphaFresnel: boolean;
  50240. /**
  50241. * The transparency mode of the material.
  50242. */
  50243. protected _transparencyMode: Nullable<number>;
  50244. /**
  50245. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50246. * from cos thetav and roughness:
  50247. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50248. */
  50249. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50250. /**
  50251. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50252. */
  50253. protected _forceIrradianceInFragment: boolean;
  50254. /**
  50255. * Force normal to face away from face.
  50256. */
  50257. protected _forceNormalForward: boolean;
  50258. /**
  50259. * Enables specular anti aliasing in the PBR shader.
  50260. * It will both interacts on the Geometry for analytical and IBL lighting.
  50261. * It also prefilter the roughness map based on the bump values.
  50262. */
  50263. protected _enableSpecularAntiAliasing: boolean;
  50264. /**
  50265. * Default configuration related to image processing available in the PBR Material.
  50266. */
  50267. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50268. /**
  50269. * Keep track of the image processing observer to allow dispose and replace.
  50270. */
  50271. private _imageProcessingObserver;
  50272. /**
  50273. * Attaches a new image processing configuration to the PBR Material.
  50274. * @param configuration
  50275. */
  50276. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50277. /**
  50278. * Stores the available render targets.
  50279. */
  50280. private _renderTargets;
  50281. /**
  50282. * Sets the global ambient color for the material used in lighting calculations.
  50283. */
  50284. private _globalAmbientColor;
  50285. /**
  50286. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50287. */
  50288. private _useLogarithmicDepth;
  50289. /**
  50290. * If set to true, no lighting calculations will be applied.
  50291. */
  50292. private _unlit;
  50293. private _debugMode;
  50294. /**
  50295. * @hidden
  50296. * This is reserved for the inspector.
  50297. * Defines the material debug mode.
  50298. * It helps seeing only some components of the material while troubleshooting.
  50299. */
  50300. debugMode: number;
  50301. /**
  50302. * @hidden
  50303. * This is reserved for the inspector.
  50304. * Specify from where on screen the debug mode should start.
  50305. * The value goes from -1 (full screen) to 1 (not visible)
  50306. * It helps with side by side comparison against the final render
  50307. * This defaults to -1
  50308. */
  50309. private debugLimit;
  50310. /**
  50311. * @hidden
  50312. * This is reserved for the inspector.
  50313. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50314. * You can use the factor to better multiply the final value.
  50315. */
  50316. private debugFactor;
  50317. /**
  50318. * Defines the clear coat layer parameters for the material.
  50319. */
  50320. readonly clearCoat: PBRClearCoatConfiguration;
  50321. /**
  50322. * Defines the anisotropic parameters for the material.
  50323. */
  50324. readonly anisotropy: PBRAnisotropicConfiguration;
  50325. /**
  50326. * Defines the BRDF parameters for the material.
  50327. */
  50328. readonly brdf: PBRBRDFConfiguration;
  50329. /**
  50330. * Defines the Sheen parameters for the material.
  50331. */
  50332. readonly sheen: PBRSheenConfiguration;
  50333. /**
  50334. * Defines the SubSurface parameters for the material.
  50335. */
  50336. readonly subSurface: PBRSubSurfaceConfiguration;
  50337. /**
  50338. * Custom callback helping to override the default shader used in the material.
  50339. */
  50340. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50341. protected _rebuildInParallel: boolean;
  50342. /**
  50343. * Instantiates a new PBRMaterial instance.
  50344. *
  50345. * @param name The material name
  50346. * @param scene The scene the material will be use in.
  50347. */
  50348. constructor(name: string, scene: Scene);
  50349. /**
  50350. * Gets a boolean indicating that current material needs to register RTT
  50351. */
  50352. get hasRenderTargetTextures(): boolean;
  50353. /**
  50354. * Gets the name of the material class.
  50355. */
  50356. getClassName(): string;
  50357. /**
  50358. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50359. */
  50360. get useLogarithmicDepth(): boolean;
  50361. /**
  50362. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50363. */
  50364. set useLogarithmicDepth(value: boolean);
  50365. /**
  50366. * Gets the current transparency mode.
  50367. */
  50368. get transparencyMode(): Nullable<number>;
  50369. /**
  50370. * Sets the transparency mode of the material.
  50371. *
  50372. * | Value | Type | Description |
  50373. * | ----- | ----------------------------------- | ----------- |
  50374. * | 0 | OPAQUE | |
  50375. * | 1 | ALPHATEST | |
  50376. * | 2 | ALPHABLEND | |
  50377. * | 3 | ALPHATESTANDBLEND | |
  50378. *
  50379. */
  50380. set transparencyMode(value: Nullable<number>);
  50381. /**
  50382. * Returns true if alpha blending should be disabled.
  50383. */
  50384. private get _disableAlphaBlending();
  50385. /**
  50386. * Specifies whether or not this material should be rendered in alpha blend mode.
  50387. */
  50388. needAlphaBlending(): boolean;
  50389. /**
  50390. * Specifies if the mesh will require alpha blending.
  50391. * @param mesh - BJS mesh.
  50392. */
  50393. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50394. /**
  50395. * Specifies whether or not this material should be rendered in alpha test mode.
  50396. */
  50397. needAlphaTesting(): boolean;
  50398. /**
  50399. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50400. */
  50401. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50402. /**
  50403. * Gets the texture used for the alpha test.
  50404. */
  50405. getAlphaTestTexture(): Nullable<BaseTexture>;
  50406. /**
  50407. * Specifies that the submesh is ready to be used.
  50408. * @param mesh - BJS mesh.
  50409. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50410. * @param useInstances - Specifies that instances should be used.
  50411. * @returns - boolean indicating that the submesh is ready or not.
  50412. */
  50413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50414. /**
  50415. * Specifies if the material uses metallic roughness workflow.
  50416. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50417. */
  50418. isMetallicWorkflow(): boolean;
  50419. private _prepareEffect;
  50420. private _prepareDefines;
  50421. /**
  50422. * Force shader compilation
  50423. */
  50424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50425. /**
  50426. * Initializes the uniform buffer layout for the shader.
  50427. */
  50428. buildUniformLayout(): void;
  50429. /**
  50430. * Unbinds the material from the mesh
  50431. */
  50432. unbind(): void;
  50433. /**
  50434. * Binds the submesh data.
  50435. * @param world - The world matrix.
  50436. * @param mesh - The BJS mesh.
  50437. * @param subMesh - A submesh of the BJS mesh.
  50438. */
  50439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50440. /**
  50441. * Returns the animatable textures.
  50442. * @returns - Array of animatable textures.
  50443. */
  50444. getAnimatables(): IAnimatable[];
  50445. /**
  50446. * Returns the texture used for reflections.
  50447. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50448. */
  50449. private _getReflectionTexture;
  50450. /**
  50451. * Returns an array of the actively used textures.
  50452. * @returns - Array of BaseTextures
  50453. */
  50454. getActiveTextures(): BaseTexture[];
  50455. /**
  50456. * Checks to see if a texture is used in the material.
  50457. * @param texture - Base texture to use.
  50458. * @returns - Boolean specifying if a texture is used in the material.
  50459. */
  50460. hasTexture(texture: BaseTexture): boolean;
  50461. /**
  50462. * Disposes the resources of the material.
  50463. * @param forceDisposeEffect - Forces the disposal of effects.
  50464. * @param forceDisposeTextures - Forces the disposal of all textures.
  50465. */
  50466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50467. }
  50468. }
  50469. declare module BABYLON {
  50470. /**
  50471. * The Physically based material of BJS.
  50472. *
  50473. * This offers the main features of a standard PBR material.
  50474. * For more information, please refer to the documentation :
  50475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50476. */
  50477. export class PBRMaterial extends PBRBaseMaterial {
  50478. /**
  50479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50480. */
  50481. static readonly PBRMATERIAL_OPAQUE: number;
  50482. /**
  50483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50484. */
  50485. static readonly PBRMATERIAL_ALPHATEST: number;
  50486. /**
  50487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50488. */
  50489. static readonly PBRMATERIAL_ALPHABLEND: number;
  50490. /**
  50491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50492. * They are also discarded below the alpha cutoff threshold to improve performances.
  50493. */
  50494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50495. /**
  50496. * Defines the default value of how much AO map is occluding the analytical lights
  50497. * (point spot...).
  50498. */
  50499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50500. /**
  50501. * Intensity of the direct lights e.g. the four lights available in your scene.
  50502. * This impacts both the direct diffuse and specular highlights.
  50503. */
  50504. directIntensity: number;
  50505. /**
  50506. * Intensity of the emissive part of the material.
  50507. * This helps controlling the emissive effect without modifying the emissive color.
  50508. */
  50509. emissiveIntensity: number;
  50510. /**
  50511. * Intensity of the environment e.g. how much the environment will light the object
  50512. * either through harmonics for rough material or through the refelction for shiny ones.
  50513. */
  50514. environmentIntensity: number;
  50515. /**
  50516. * This is a special control allowing the reduction of the specular highlights coming from the
  50517. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50518. */
  50519. specularIntensity: number;
  50520. /**
  50521. * Debug Control allowing disabling the bump map on this material.
  50522. */
  50523. disableBumpMap: boolean;
  50524. /**
  50525. * AKA Diffuse Texture in standard nomenclature.
  50526. */
  50527. albedoTexture: BaseTexture;
  50528. /**
  50529. * AKA Occlusion Texture in other nomenclature.
  50530. */
  50531. ambientTexture: BaseTexture;
  50532. /**
  50533. * AKA Occlusion Texture Intensity in other nomenclature.
  50534. */
  50535. ambientTextureStrength: number;
  50536. /**
  50537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50538. * 1 means it completely occludes it
  50539. * 0 mean it has no impact
  50540. */
  50541. ambientTextureImpactOnAnalyticalLights: number;
  50542. /**
  50543. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50544. */
  50545. opacityTexture: BaseTexture;
  50546. /**
  50547. * Stores the reflection values in a texture.
  50548. */
  50549. reflectionTexture: Nullable<BaseTexture>;
  50550. /**
  50551. * Stores the emissive values in a texture.
  50552. */
  50553. emissiveTexture: BaseTexture;
  50554. /**
  50555. * AKA Specular texture in other nomenclature.
  50556. */
  50557. reflectivityTexture: BaseTexture;
  50558. /**
  50559. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50560. */
  50561. metallicTexture: BaseTexture;
  50562. /**
  50563. * Specifies the metallic scalar of the metallic/roughness workflow.
  50564. * Can also be used to scale the metalness values of the metallic texture.
  50565. */
  50566. metallic: Nullable<number>;
  50567. /**
  50568. * Specifies the roughness scalar of the metallic/roughness workflow.
  50569. * Can also be used to scale the roughness values of the metallic texture.
  50570. */
  50571. roughness: Nullable<number>;
  50572. /**
  50573. * Specifies the an F0 factor to help configuring the material F0.
  50574. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50575. * to 0.5 the previously hard coded value stays the same.
  50576. * Can also be used to scale the F0 values of the metallic texture.
  50577. */
  50578. metallicF0Factor: number;
  50579. /**
  50580. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50581. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50582. * your expectation as it multiplies with the texture data.
  50583. */
  50584. useMetallicF0FactorFromMetallicTexture: boolean;
  50585. /**
  50586. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50587. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50588. */
  50589. microSurfaceTexture: BaseTexture;
  50590. /**
  50591. * Stores surface normal data used to displace a mesh in a texture.
  50592. */
  50593. bumpTexture: BaseTexture;
  50594. /**
  50595. * Stores the pre-calculated light information of a mesh in a texture.
  50596. */
  50597. lightmapTexture: BaseTexture;
  50598. /**
  50599. * Stores the refracted light information in a texture.
  50600. */
  50601. get refractionTexture(): Nullable<BaseTexture>;
  50602. set refractionTexture(value: Nullable<BaseTexture>);
  50603. /**
  50604. * The color of a material in ambient lighting.
  50605. */
  50606. ambientColor: Color3;
  50607. /**
  50608. * AKA Diffuse Color in other nomenclature.
  50609. */
  50610. albedoColor: Color3;
  50611. /**
  50612. * AKA Specular Color in other nomenclature.
  50613. */
  50614. reflectivityColor: Color3;
  50615. /**
  50616. * The color reflected from the material.
  50617. */
  50618. reflectionColor: Color3;
  50619. /**
  50620. * The color emitted from the material.
  50621. */
  50622. emissiveColor: Color3;
  50623. /**
  50624. * AKA Glossiness in other nomenclature.
  50625. */
  50626. microSurface: number;
  50627. /**
  50628. * source material index of refraction (IOR)' / 'destination material IOR.
  50629. */
  50630. get indexOfRefraction(): number;
  50631. set indexOfRefraction(value: number);
  50632. /**
  50633. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50634. */
  50635. get invertRefractionY(): boolean;
  50636. set invertRefractionY(value: boolean);
  50637. /**
  50638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50639. * Materials half opaque for instance using refraction could benefit from this control.
  50640. */
  50641. get linkRefractionWithTransparency(): boolean;
  50642. set linkRefractionWithTransparency(value: boolean);
  50643. /**
  50644. * If true, the light map contains occlusion information instead of lighting info.
  50645. */
  50646. useLightmapAsShadowmap: boolean;
  50647. /**
  50648. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50649. */
  50650. useAlphaFromAlbedoTexture: boolean;
  50651. /**
  50652. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50653. */
  50654. forceAlphaTest: boolean;
  50655. /**
  50656. * Defines the alpha limits in alpha test mode.
  50657. */
  50658. alphaCutOff: number;
  50659. /**
  50660. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50661. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50662. */
  50663. useSpecularOverAlpha: boolean;
  50664. /**
  50665. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50666. */
  50667. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50668. /**
  50669. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50670. */
  50671. useRoughnessFromMetallicTextureAlpha: boolean;
  50672. /**
  50673. * Specifies if the metallic texture contains the roughness information in its green channel.
  50674. */
  50675. useRoughnessFromMetallicTextureGreen: boolean;
  50676. /**
  50677. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50678. */
  50679. useMetallnessFromMetallicTextureBlue: boolean;
  50680. /**
  50681. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50682. */
  50683. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50684. /**
  50685. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50686. */
  50687. useAmbientInGrayScale: boolean;
  50688. /**
  50689. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50690. * The material will try to infer what glossiness each pixel should be.
  50691. */
  50692. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50693. /**
  50694. * BJS is using an harcoded light falloff based on a manually sets up range.
  50695. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50696. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50697. */
  50698. get usePhysicalLightFalloff(): boolean;
  50699. /**
  50700. * BJS is using an harcoded light falloff based on a manually sets up range.
  50701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50703. */
  50704. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  50710. /**
  50711. * In order to support the falloff compatibility with gltf, a special mode has been added
  50712. * to reproduce the gltf light falloff.
  50713. */
  50714. set useGLTFLightFalloff(value: boolean);
  50715. /**
  50716. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50717. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50718. */
  50719. useRadianceOverAlpha: boolean;
  50720. /**
  50721. * Allows using an object space normal map (instead of tangent space).
  50722. */
  50723. useObjectSpaceNormalMap: boolean;
  50724. /**
  50725. * Allows using the bump map in parallax mode.
  50726. */
  50727. useParallax: boolean;
  50728. /**
  50729. * Allows using the bump map in parallax occlusion mode.
  50730. */
  50731. useParallaxOcclusion: boolean;
  50732. /**
  50733. * Controls the scale bias of the parallax mode.
  50734. */
  50735. parallaxScaleBias: number;
  50736. /**
  50737. * If sets to true, disables all the lights affecting the material.
  50738. */
  50739. disableLighting: boolean;
  50740. /**
  50741. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50742. */
  50743. forceIrradianceInFragment: boolean;
  50744. /**
  50745. * Number of Simultaneous lights allowed on the material.
  50746. */
  50747. maxSimultaneousLights: number;
  50748. /**
  50749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50750. */
  50751. invertNormalMapX: boolean;
  50752. /**
  50753. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50754. */
  50755. invertNormalMapY: boolean;
  50756. /**
  50757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50758. */
  50759. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  50763. */
  50764. useAlphaFresnel: boolean;
  50765. /**
  50766. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50767. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50768. */
  50769. useLinearAlphaFresnel: boolean;
  50770. /**
  50771. * Let user defines the brdf lookup texture used for IBL.
  50772. * A default 8bit version is embedded but you could point at :
  50773. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50774. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50775. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50776. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50777. */
  50778. environmentBRDFTexture: Nullable<BaseTexture>;
  50779. /**
  50780. * Force normal to face away from face.
  50781. */
  50782. forceNormalForward: boolean;
  50783. /**
  50784. * Enables specular anti aliasing in the PBR shader.
  50785. * It will both interacts on the Geometry for analytical and IBL lighting.
  50786. * It also prefilter the roughness map based on the bump values.
  50787. */
  50788. enableSpecularAntiAliasing: boolean;
  50789. /**
  50790. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50791. * makes the reflect vector face the model (under horizon).
  50792. */
  50793. useHorizonOcclusion: boolean;
  50794. /**
  50795. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50796. * too much the area relying on ambient texture to define their ambient occlusion.
  50797. */
  50798. useRadianceOcclusion: boolean;
  50799. /**
  50800. * If set to true, no lighting calculations will be applied.
  50801. */
  50802. unlit: boolean;
  50803. /**
  50804. * Gets the image processing configuration used either in this material.
  50805. */
  50806. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50807. /**
  50808. * Sets the Default image processing configuration used either in the this material.
  50809. *
  50810. * If sets to null, the scene one is in use.
  50811. */
  50812. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50813. /**
  50814. * Gets wether the color curves effect is enabled.
  50815. */
  50816. get cameraColorCurvesEnabled(): boolean;
  50817. /**
  50818. * Sets wether the color curves effect is enabled.
  50819. */
  50820. set cameraColorCurvesEnabled(value: boolean);
  50821. /**
  50822. * Gets wether the color grading effect is enabled.
  50823. */
  50824. get cameraColorGradingEnabled(): boolean;
  50825. /**
  50826. * Gets wether the color grading effect is enabled.
  50827. */
  50828. set cameraColorGradingEnabled(value: boolean);
  50829. /**
  50830. * Gets wether tonemapping is enabled or not.
  50831. */
  50832. get cameraToneMappingEnabled(): boolean;
  50833. /**
  50834. * Sets wether tonemapping is enabled or not
  50835. */
  50836. set cameraToneMappingEnabled(value: boolean);
  50837. /**
  50838. * The camera exposure used on this material.
  50839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50840. * This corresponds to a photographic exposure.
  50841. */
  50842. get cameraExposure(): number;
  50843. /**
  50844. * The camera exposure used on this material.
  50845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50846. * This corresponds to a photographic exposure.
  50847. */
  50848. set cameraExposure(value: number);
  50849. /**
  50850. * Gets The camera contrast used on this material.
  50851. */
  50852. get cameraContrast(): number;
  50853. /**
  50854. * Sets The camera contrast used on this material.
  50855. */
  50856. set cameraContrast(value: number);
  50857. /**
  50858. * Gets the Color Grading 2D Lookup Texture.
  50859. */
  50860. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50861. /**
  50862. * Sets the Color Grading 2D Lookup Texture.
  50863. */
  50864. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50865. /**
  50866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50868. * 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;
  50869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50870. */
  50871. get cameraColorCurves(): Nullable<ColorCurves>;
  50872. /**
  50873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50875. * 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;
  50876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50877. */
  50878. set cameraColorCurves(value: Nullable<ColorCurves>);
  50879. /**
  50880. * Instantiates a new PBRMaterial instance.
  50881. *
  50882. * @param name The material name
  50883. * @param scene The scene the material will be use in.
  50884. */
  50885. constructor(name: string, scene: Scene);
  50886. /**
  50887. * Returns the name of this material class.
  50888. */
  50889. getClassName(): string;
  50890. /**
  50891. * Makes a duplicate of the current material.
  50892. * @param name - name to use for the new material.
  50893. */
  50894. clone(name: string): PBRMaterial;
  50895. /**
  50896. * Serializes this PBR Material.
  50897. * @returns - An object with the serialized material.
  50898. */
  50899. serialize(): any;
  50900. /**
  50901. * Parses a PBR Material from a serialized object.
  50902. * @param source - Serialized object.
  50903. * @param scene - BJS scene instance.
  50904. * @param rootUrl - url for the scene object
  50905. * @returns - PBRMaterial
  50906. */
  50907. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50908. }
  50909. }
  50910. declare module BABYLON {
  50911. /**
  50912. * Direct draw surface info
  50913. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50914. */
  50915. export interface DDSInfo {
  50916. /**
  50917. * Width of the texture
  50918. */
  50919. width: number;
  50920. /**
  50921. * Width of the texture
  50922. */
  50923. height: number;
  50924. /**
  50925. * Number of Mipmaps for the texture
  50926. * @see https://en.wikipedia.org/wiki/Mipmap
  50927. */
  50928. mipmapCount: number;
  50929. /**
  50930. * If the textures format is a known fourCC format
  50931. * @see https://www.fourcc.org/
  50932. */
  50933. isFourCC: boolean;
  50934. /**
  50935. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50936. */
  50937. isRGB: boolean;
  50938. /**
  50939. * If the texture is a lumincance format
  50940. */
  50941. isLuminance: boolean;
  50942. /**
  50943. * If this is a cube texture
  50944. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50945. */
  50946. isCube: boolean;
  50947. /**
  50948. * If the texture is a compressed format eg. FOURCC_DXT1
  50949. */
  50950. isCompressed: boolean;
  50951. /**
  50952. * The dxgiFormat of the texture
  50953. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50954. */
  50955. dxgiFormat: number;
  50956. /**
  50957. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50958. */
  50959. textureType: number;
  50960. /**
  50961. * Sphericle polynomial created for the dds texture
  50962. */
  50963. sphericalPolynomial?: SphericalPolynomial;
  50964. }
  50965. /**
  50966. * Class used to provide DDS decompression tools
  50967. */
  50968. export class DDSTools {
  50969. /**
  50970. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50971. */
  50972. static StoreLODInAlphaChannel: boolean;
  50973. /**
  50974. * Gets DDS information from an array buffer
  50975. * @param arrayBuffer defines the array buffer to read data from
  50976. * @returns the DDS information
  50977. */
  50978. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50979. private static _FloatView;
  50980. private static _Int32View;
  50981. private static _ToHalfFloat;
  50982. private static _FromHalfFloat;
  50983. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50984. private static _GetHalfFloatRGBAArrayBuffer;
  50985. private static _GetFloatRGBAArrayBuffer;
  50986. private static _GetFloatAsUIntRGBAArrayBuffer;
  50987. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50988. private static _GetRGBAArrayBuffer;
  50989. private static _ExtractLongWordOrder;
  50990. private static _GetRGBArrayBuffer;
  50991. private static _GetLuminanceArrayBuffer;
  50992. /**
  50993. * Uploads DDS Levels to a Babylon Texture
  50994. * @hidden
  50995. */
  50996. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50997. }
  50998. interface ThinEngine {
  50999. /**
  51000. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51001. * @param rootUrl defines the url where the file to load is located
  51002. * @param scene defines the current scene
  51003. * @param lodScale defines scale to apply to the mip map selection
  51004. * @param lodOffset defines offset to apply to the mip map selection
  51005. * @param onLoad defines an optional callback raised when the texture is loaded
  51006. * @param onError defines an optional callback raised if there is an issue to load the texture
  51007. * @param format defines the format of the data
  51008. * @param forcedExtension defines the extension to use to pick the right loader
  51009. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51010. * @returns the cube texture as an InternalTexture
  51011. */
  51012. 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;
  51013. }
  51014. }
  51015. declare module BABYLON {
  51016. /**
  51017. * Implementation of the DDS Texture Loader.
  51018. * @hidden
  51019. */
  51020. export class _DDSTextureLoader implements IInternalTextureLoader {
  51021. /**
  51022. * Defines wether the loader supports cascade loading the different faces.
  51023. */
  51024. readonly supportCascades: boolean;
  51025. /**
  51026. * This returns if the loader support the current file information.
  51027. * @param extension defines the file extension of the file being loaded
  51028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51029. * @param fallback defines the fallback internal texture if any
  51030. * @param isBase64 defines whether the texture is encoded as a base64
  51031. * @param isBuffer defines whether the texture data are stored as a buffer
  51032. * @returns true if the loader can load the specified file
  51033. */
  51034. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51035. /**
  51036. * Transform the url before loading if required.
  51037. * @param rootUrl the url of the texture
  51038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51039. * @returns the transformed texture
  51040. */
  51041. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51042. /**
  51043. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51044. * @param rootUrl the url of the texture
  51045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51046. * @returns the fallback texture
  51047. */
  51048. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51049. /**
  51050. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51051. * @param data contains the texture data
  51052. * @param texture defines the BabylonJS internal texture
  51053. * @param createPolynomials will be true if polynomials have been requested
  51054. * @param onLoad defines the callback to trigger once the texture is ready
  51055. * @param onError defines the callback to trigger in case of error
  51056. */
  51057. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51058. /**
  51059. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51060. * @param data contains the texture data
  51061. * @param texture defines the BabylonJS internal texture
  51062. * @param callback defines the method to call once ready to upload
  51063. */
  51064. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51065. }
  51066. }
  51067. declare module BABYLON {
  51068. /**
  51069. * Implementation of the ENV Texture Loader.
  51070. * @hidden
  51071. */
  51072. export class _ENVTextureLoader implements IInternalTextureLoader {
  51073. /**
  51074. * Defines wether the loader supports cascade loading the different faces.
  51075. */
  51076. readonly supportCascades: boolean;
  51077. /**
  51078. * This returns if the loader support the current file information.
  51079. * @param extension defines the file extension of the file being loaded
  51080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51081. * @param fallback defines the fallback internal texture if any
  51082. * @param isBase64 defines whether the texture is encoded as a base64
  51083. * @param isBuffer defines whether the texture data are stored as a buffer
  51084. * @returns true if the loader can load the specified file
  51085. */
  51086. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51087. /**
  51088. * Transform the url before loading if required.
  51089. * @param rootUrl the url of the texture
  51090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51091. * @returns the transformed texture
  51092. */
  51093. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51094. /**
  51095. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51096. * @param rootUrl the url of the texture
  51097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51098. * @returns the fallback texture
  51099. */
  51100. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51101. /**
  51102. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51103. * @param data contains the texture data
  51104. * @param texture defines the BabylonJS internal texture
  51105. * @param createPolynomials will be true if polynomials have been requested
  51106. * @param onLoad defines the callback to trigger once the texture is ready
  51107. * @param onError defines the callback to trigger in case of error
  51108. */
  51109. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51110. /**
  51111. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51112. * @param data contains the texture data
  51113. * @param texture defines the BabylonJS internal texture
  51114. * @param callback defines the method to call once ready to upload
  51115. */
  51116. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51117. }
  51118. }
  51119. declare module BABYLON {
  51120. /**
  51121. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51122. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51123. */
  51124. export class KhronosTextureContainer {
  51125. /** contents of the KTX container file */
  51126. arrayBuffer: any;
  51127. private static HEADER_LEN;
  51128. private static COMPRESSED_2D;
  51129. private static COMPRESSED_3D;
  51130. private static TEX_2D;
  51131. private static TEX_3D;
  51132. /**
  51133. * Gets the openGL type
  51134. */
  51135. glType: number;
  51136. /**
  51137. * Gets the openGL type size
  51138. */
  51139. glTypeSize: number;
  51140. /**
  51141. * Gets the openGL format
  51142. */
  51143. glFormat: number;
  51144. /**
  51145. * Gets the openGL internal format
  51146. */
  51147. glInternalFormat: number;
  51148. /**
  51149. * Gets the base internal format
  51150. */
  51151. glBaseInternalFormat: number;
  51152. /**
  51153. * Gets image width in pixel
  51154. */
  51155. pixelWidth: number;
  51156. /**
  51157. * Gets image height in pixel
  51158. */
  51159. pixelHeight: number;
  51160. /**
  51161. * Gets image depth in pixels
  51162. */
  51163. pixelDepth: number;
  51164. /**
  51165. * Gets the number of array elements
  51166. */
  51167. numberOfArrayElements: number;
  51168. /**
  51169. * Gets the number of faces
  51170. */
  51171. numberOfFaces: number;
  51172. /**
  51173. * Gets the number of mipmap levels
  51174. */
  51175. numberOfMipmapLevels: number;
  51176. /**
  51177. * Gets the bytes of key value data
  51178. */
  51179. bytesOfKeyValueData: number;
  51180. /**
  51181. * Gets the load type
  51182. */
  51183. loadType: number;
  51184. /**
  51185. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51186. */
  51187. isInvalid: boolean;
  51188. /**
  51189. * Creates a new KhronosTextureContainer
  51190. * @param arrayBuffer contents of the KTX container file
  51191. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51192. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51193. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51194. */
  51195. constructor(
  51196. /** contents of the KTX container file */
  51197. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51198. /**
  51199. * Uploads KTX content to a Babylon Texture.
  51200. * It is assumed that the texture has already been created & is currently bound
  51201. * @hidden
  51202. */
  51203. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51204. private _upload2DCompressedLevels;
  51205. }
  51206. }
  51207. declare module BABYLON {
  51208. /**
  51209. * Implementation of the KTX Texture Loader.
  51210. * @hidden
  51211. */
  51212. export class _KTXTextureLoader implements IInternalTextureLoader {
  51213. /**
  51214. * Defines wether the loader supports cascade loading the different faces.
  51215. */
  51216. readonly supportCascades: boolean;
  51217. /**
  51218. * This returns if the loader support the current file information.
  51219. * @param extension defines the file extension of the file being loaded
  51220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51221. * @param fallback defines the fallback internal texture if any
  51222. * @param isBase64 defines whether the texture is encoded as a base64
  51223. * @param isBuffer defines whether the texture data are stored as a buffer
  51224. * @returns true if the loader can load the specified file
  51225. */
  51226. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51227. /**
  51228. * Transform the url before loading if required.
  51229. * @param rootUrl the url of the texture
  51230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51231. * @returns the transformed texture
  51232. */
  51233. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51234. /**
  51235. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51236. * @param rootUrl the url of the texture
  51237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51238. * @returns the fallback texture
  51239. */
  51240. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51241. /**
  51242. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51243. * @param data contains the texture data
  51244. * @param texture defines the BabylonJS internal texture
  51245. * @param createPolynomials will be true if polynomials have been requested
  51246. * @param onLoad defines the callback to trigger once the texture is ready
  51247. * @param onError defines the callback to trigger in case of error
  51248. */
  51249. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51250. /**
  51251. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51252. * @param data contains the texture data
  51253. * @param texture defines the BabylonJS internal texture
  51254. * @param callback defines the method to call once ready to upload
  51255. */
  51256. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51257. }
  51258. }
  51259. declare module BABYLON {
  51260. /** @hidden */
  51261. export var _forceSceneHelpersToBundle: boolean;
  51262. interface Scene {
  51263. /**
  51264. * Creates a default light for the scene.
  51265. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51266. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51267. */
  51268. createDefaultLight(replace?: boolean): void;
  51269. /**
  51270. * Creates a default camera for the scene.
  51271. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51272. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51273. * @param replace has default false, when true replaces the active camera in the scene
  51274. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51275. */
  51276. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51277. /**
  51278. * Creates a default camera and a default light.
  51279. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51281. * @param replace has the default false, when true replaces the active camera/light in the scene
  51282. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51283. */
  51284. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51285. /**
  51286. * Creates a new sky box
  51287. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51288. * @param environmentTexture defines the texture to use as environment texture
  51289. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51290. * @param scale defines the overall scale of the skybox
  51291. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51292. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51293. * @returns a new mesh holding the sky box
  51294. */
  51295. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51296. /**
  51297. * Creates a new environment
  51298. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51299. * @param options defines the options you can use to configure the environment
  51300. * @returns the new EnvironmentHelper
  51301. */
  51302. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51303. /**
  51304. * Creates a new VREXperienceHelper
  51305. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51306. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51307. * @returns a new VREXperienceHelper
  51308. */
  51309. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51310. /**
  51311. * Creates a new WebXRDefaultExperience
  51312. * @see http://doc.babylonjs.com/how_to/webxr
  51313. * @param options experience options
  51314. * @returns a promise for a new WebXRDefaultExperience
  51315. */
  51316. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51317. }
  51318. }
  51319. declare module BABYLON {
  51320. /**
  51321. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51322. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51323. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51324. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51325. */
  51326. export class VideoDome extends TransformNode {
  51327. /**
  51328. * Define the video source as a Monoscopic panoramic 360 video.
  51329. */
  51330. static readonly MODE_MONOSCOPIC: number;
  51331. /**
  51332. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51333. */
  51334. static readonly MODE_TOPBOTTOM: number;
  51335. /**
  51336. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51337. */
  51338. static readonly MODE_SIDEBYSIDE: number;
  51339. private _halfDome;
  51340. private _useDirectMapping;
  51341. /**
  51342. * The video texture being displayed on the sphere
  51343. */
  51344. protected _videoTexture: VideoTexture;
  51345. /**
  51346. * Gets the video texture being displayed on the sphere
  51347. */
  51348. get videoTexture(): VideoTexture;
  51349. /**
  51350. * The skybox material
  51351. */
  51352. protected _material: BackgroundMaterial;
  51353. /**
  51354. * The surface used for the skybox
  51355. */
  51356. protected _mesh: Mesh;
  51357. /**
  51358. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51359. */
  51360. private _halfDomeMask;
  51361. /**
  51362. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51363. * Also see the options.resolution property.
  51364. */
  51365. get fovMultiplier(): number;
  51366. set fovMultiplier(value: number);
  51367. private _videoMode;
  51368. /**
  51369. * Gets or set the current video mode for the video. It can be:
  51370. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51371. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51372. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51373. */
  51374. get videoMode(): number;
  51375. set videoMode(value: number);
  51376. /**
  51377. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51378. *
  51379. */
  51380. get halfDome(): boolean;
  51381. /**
  51382. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51383. */
  51384. set halfDome(enabled: boolean);
  51385. /**
  51386. * Oberserver used in Stereoscopic VR Mode.
  51387. */
  51388. private _onBeforeCameraRenderObserver;
  51389. /**
  51390. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51391. * @param name Element's name, child elements will append suffixes for their own names.
  51392. * @param urlsOrVideo defines the url(s) or the video element to use
  51393. * @param options An object containing optional or exposed sub element properties
  51394. */
  51395. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51396. resolution?: number;
  51397. clickToPlay?: boolean;
  51398. autoPlay?: boolean;
  51399. loop?: boolean;
  51400. size?: number;
  51401. poster?: string;
  51402. faceForward?: boolean;
  51403. useDirectMapping?: boolean;
  51404. halfDomeMode?: boolean;
  51405. }, scene: Scene);
  51406. private _changeVideoMode;
  51407. /**
  51408. * Releases resources associated with this node.
  51409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51411. */
  51412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51413. }
  51414. }
  51415. declare module BABYLON {
  51416. /**
  51417. * This class can be used to get instrumentation data from a Babylon engine
  51418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51419. */
  51420. export class EngineInstrumentation implements IDisposable {
  51421. /**
  51422. * Define the instrumented engine.
  51423. */
  51424. engine: Engine;
  51425. private _captureGPUFrameTime;
  51426. private _gpuFrameTimeToken;
  51427. private _gpuFrameTime;
  51428. private _captureShaderCompilationTime;
  51429. private _shaderCompilationTime;
  51430. private _onBeginFrameObserver;
  51431. private _onEndFrameObserver;
  51432. private _onBeforeShaderCompilationObserver;
  51433. private _onAfterShaderCompilationObserver;
  51434. /**
  51435. * Gets the perf counter used for GPU frame time
  51436. */
  51437. get gpuFrameTimeCounter(): PerfCounter;
  51438. /**
  51439. * Gets the GPU frame time capture status
  51440. */
  51441. get captureGPUFrameTime(): boolean;
  51442. /**
  51443. * Enable or disable the GPU frame time capture
  51444. */
  51445. set captureGPUFrameTime(value: boolean);
  51446. /**
  51447. * Gets the perf counter used for shader compilation time
  51448. */
  51449. get shaderCompilationTimeCounter(): PerfCounter;
  51450. /**
  51451. * Gets the shader compilation time capture status
  51452. */
  51453. get captureShaderCompilationTime(): boolean;
  51454. /**
  51455. * Enable or disable the shader compilation time capture
  51456. */
  51457. set captureShaderCompilationTime(value: boolean);
  51458. /**
  51459. * Instantiates a new engine instrumentation.
  51460. * This class can be used to get instrumentation data from a Babylon engine
  51461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51462. * @param engine Defines the engine to instrument
  51463. */
  51464. constructor(
  51465. /**
  51466. * Define the instrumented engine.
  51467. */
  51468. engine: Engine);
  51469. /**
  51470. * Dispose and release associated resources.
  51471. */
  51472. dispose(): void;
  51473. }
  51474. }
  51475. declare module BABYLON {
  51476. /**
  51477. * This class can be used to get instrumentation data from a Babylon engine
  51478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51479. */
  51480. export class SceneInstrumentation implements IDisposable {
  51481. /**
  51482. * Defines the scene to instrument
  51483. */
  51484. scene: Scene;
  51485. private _captureActiveMeshesEvaluationTime;
  51486. private _activeMeshesEvaluationTime;
  51487. private _captureRenderTargetsRenderTime;
  51488. private _renderTargetsRenderTime;
  51489. private _captureFrameTime;
  51490. private _frameTime;
  51491. private _captureRenderTime;
  51492. private _renderTime;
  51493. private _captureInterFrameTime;
  51494. private _interFrameTime;
  51495. private _captureParticlesRenderTime;
  51496. private _particlesRenderTime;
  51497. private _captureSpritesRenderTime;
  51498. private _spritesRenderTime;
  51499. private _capturePhysicsTime;
  51500. private _physicsTime;
  51501. private _captureAnimationsTime;
  51502. private _animationsTime;
  51503. private _captureCameraRenderTime;
  51504. private _cameraRenderTime;
  51505. private _onBeforeActiveMeshesEvaluationObserver;
  51506. private _onAfterActiveMeshesEvaluationObserver;
  51507. private _onBeforeRenderTargetsRenderObserver;
  51508. private _onAfterRenderTargetsRenderObserver;
  51509. private _onAfterRenderObserver;
  51510. private _onBeforeDrawPhaseObserver;
  51511. private _onAfterDrawPhaseObserver;
  51512. private _onBeforeAnimationsObserver;
  51513. private _onBeforeParticlesRenderingObserver;
  51514. private _onAfterParticlesRenderingObserver;
  51515. private _onBeforeSpritesRenderingObserver;
  51516. private _onAfterSpritesRenderingObserver;
  51517. private _onBeforePhysicsObserver;
  51518. private _onAfterPhysicsObserver;
  51519. private _onAfterAnimationsObserver;
  51520. private _onBeforeCameraRenderObserver;
  51521. private _onAfterCameraRenderObserver;
  51522. /**
  51523. * Gets the perf counter used for active meshes evaluation time
  51524. */
  51525. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51526. /**
  51527. * Gets the active meshes evaluation time capture status
  51528. */
  51529. get captureActiveMeshesEvaluationTime(): boolean;
  51530. /**
  51531. * Enable or disable the active meshes evaluation time capture
  51532. */
  51533. set captureActiveMeshesEvaluationTime(value: boolean);
  51534. /**
  51535. * Gets the perf counter used for render targets render time
  51536. */
  51537. get renderTargetsRenderTimeCounter(): PerfCounter;
  51538. /**
  51539. * Gets the render targets render time capture status
  51540. */
  51541. get captureRenderTargetsRenderTime(): boolean;
  51542. /**
  51543. * Enable or disable the render targets render time capture
  51544. */
  51545. set captureRenderTargetsRenderTime(value: boolean);
  51546. /**
  51547. * Gets the perf counter used for particles render time
  51548. */
  51549. get particlesRenderTimeCounter(): PerfCounter;
  51550. /**
  51551. * Gets the particles render time capture status
  51552. */
  51553. get captureParticlesRenderTime(): boolean;
  51554. /**
  51555. * Enable or disable the particles render time capture
  51556. */
  51557. set captureParticlesRenderTime(value: boolean);
  51558. /**
  51559. * Gets the perf counter used for sprites render time
  51560. */
  51561. get spritesRenderTimeCounter(): PerfCounter;
  51562. /**
  51563. * Gets the sprites render time capture status
  51564. */
  51565. get captureSpritesRenderTime(): boolean;
  51566. /**
  51567. * Enable or disable the sprites render time capture
  51568. */
  51569. set captureSpritesRenderTime(value: boolean);
  51570. /**
  51571. * Gets the perf counter used for physics time
  51572. */
  51573. get physicsTimeCounter(): PerfCounter;
  51574. /**
  51575. * Gets the physics time capture status
  51576. */
  51577. get capturePhysicsTime(): boolean;
  51578. /**
  51579. * Enable or disable the physics time capture
  51580. */
  51581. set capturePhysicsTime(value: boolean);
  51582. /**
  51583. * Gets the perf counter used for animations time
  51584. */
  51585. get animationsTimeCounter(): PerfCounter;
  51586. /**
  51587. * Gets the animations time capture status
  51588. */
  51589. get captureAnimationsTime(): boolean;
  51590. /**
  51591. * Enable or disable the animations time capture
  51592. */
  51593. set captureAnimationsTime(value: boolean);
  51594. /**
  51595. * Gets the perf counter used for frame time capture
  51596. */
  51597. get frameTimeCounter(): PerfCounter;
  51598. /**
  51599. * Gets the frame time capture status
  51600. */
  51601. get captureFrameTime(): boolean;
  51602. /**
  51603. * Enable or disable the frame time capture
  51604. */
  51605. set captureFrameTime(value: boolean);
  51606. /**
  51607. * Gets the perf counter used for inter-frames time capture
  51608. */
  51609. get interFrameTimeCounter(): PerfCounter;
  51610. /**
  51611. * Gets the inter-frames time capture status
  51612. */
  51613. get captureInterFrameTime(): boolean;
  51614. /**
  51615. * Enable or disable the inter-frames time capture
  51616. */
  51617. set captureInterFrameTime(value: boolean);
  51618. /**
  51619. * Gets the perf counter used for render time capture
  51620. */
  51621. get renderTimeCounter(): PerfCounter;
  51622. /**
  51623. * Gets the render time capture status
  51624. */
  51625. get captureRenderTime(): boolean;
  51626. /**
  51627. * Enable or disable the render time capture
  51628. */
  51629. set captureRenderTime(value: boolean);
  51630. /**
  51631. * Gets the perf counter used for camera render time capture
  51632. */
  51633. get cameraRenderTimeCounter(): PerfCounter;
  51634. /**
  51635. * Gets the camera render time capture status
  51636. */
  51637. get captureCameraRenderTime(): boolean;
  51638. /**
  51639. * Enable or disable the camera render time capture
  51640. */
  51641. set captureCameraRenderTime(value: boolean);
  51642. /**
  51643. * Gets the perf counter used for draw calls
  51644. */
  51645. get drawCallsCounter(): PerfCounter;
  51646. /**
  51647. * Instantiates a new scene instrumentation.
  51648. * This class can be used to get instrumentation data from a Babylon engine
  51649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51650. * @param scene Defines the scene to instrument
  51651. */
  51652. constructor(
  51653. /**
  51654. * Defines the scene to instrument
  51655. */
  51656. scene: Scene);
  51657. /**
  51658. * Dispose and release associated resources.
  51659. */
  51660. dispose(): void;
  51661. }
  51662. }
  51663. declare module BABYLON {
  51664. /** @hidden */
  51665. export var glowMapGenerationPixelShader: {
  51666. name: string;
  51667. shader: string;
  51668. };
  51669. }
  51670. declare module BABYLON {
  51671. /** @hidden */
  51672. export var glowMapGenerationVertexShader: {
  51673. name: string;
  51674. shader: string;
  51675. };
  51676. }
  51677. declare module BABYLON {
  51678. /**
  51679. * Effect layer options. This helps customizing the behaviour
  51680. * of the effect layer.
  51681. */
  51682. export interface IEffectLayerOptions {
  51683. /**
  51684. * Multiplication factor apply to the canvas size to compute the render target size
  51685. * used to generated the objects (the smaller the faster).
  51686. */
  51687. mainTextureRatio: number;
  51688. /**
  51689. * Enforces a fixed size texture to ensure effect stability across devices.
  51690. */
  51691. mainTextureFixedSize?: number;
  51692. /**
  51693. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51694. */
  51695. alphaBlendingMode: number;
  51696. /**
  51697. * The camera attached to the layer.
  51698. */
  51699. camera: Nullable<Camera>;
  51700. /**
  51701. * The rendering group to draw the layer in.
  51702. */
  51703. renderingGroupId: number;
  51704. }
  51705. /**
  51706. * The effect layer Helps adding post process effect blended with the main pass.
  51707. *
  51708. * This can be for instance use to generate glow or higlight effects on the scene.
  51709. *
  51710. * The effect layer class can not be used directly and is intented to inherited from to be
  51711. * customized per effects.
  51712. */
  51713. export abstract class EffectLayer {
  51714. private _vertexBuffers;
  51715. private _indexBuffer;
  51716. private _cachedDefines;
  51717. private _effectLayerMapGenerationEffect;
  51718. private _effectLayerOptions;
  51719. private _mergeEffect;
  51720. protected _scene: Scene;
  51721. protected _engine: Engine;
  51722. protected _maxSize: number;
  51723. protected _mainTextureDesiredSize: ISize;
  51724. protected _mainTexture: RenderTargetTexture;
  51725. protected _shouldRender: boolean;
  51726. protected _postProcesses: PostProcess[];
  51727. protected _textures: BaseTexture[];
  51728. protected _emissiveTextureAndColor: {
  51729. texture: Nullable<BaseTexture>;
  51730. color: Color4;
  51731. };
  51732. /**
  51733. * The name of the layer
  51734. */
  51735. name: string;
  51736. /**
  51737. * The clear color of the texture used to generate the glow map.
  51738. */
  51739. neutralColor: Color4;
  51740. /**
  51741. * Specifies wether the highlight layer is enabled or not.
  51742. */
  51743. isEnabled: boolean;
  51744. /**
  51745. * Gets the camera attached to the layer.
  51746. */
  51747. get camera(): Nullable<Camera>;
  51748. /**
  51749. * Gets the rendering group id the layer should render in.
  51750. */
  51751. get renderingGroupId(): number;
  51752. set renderingGroupId(renderingGroupId: number);
  51753. /**
  51754. * An event triggered when the effect layer has been disposed.
  51755. */
  51756. onDisposeObservable: Observable<EffectLayer>;
  51757. /**
  51758. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51759. */
  51760. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51761. /**
  51762. * An event triggered when the generated texture is being merged in the scene.
  51763. */
  51764. onBeforeComposeObservable: Observable<EffectLayer>;
  51765. /**
  51766. * An event triggered when the mesh is rendered into the effect render target.
  51767. */
  51768. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51769. /**
  51770. * An event triggered after the mesh has been rendered into the effect render target.
  51771. */
  51772. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51773. /**
  51774. * An event triggered when the generated texture has been merged in the scene.
  51775. */
  51776. onAfterComposeObservable: Observable<EffectLayer>;
  51777. /**
  51778. * An event triggered when the efffect layer changes its size.
  51779. */
  51780. onSizeChangedObservable: Observable<EffectLayer>;
  51781. /** @hidden */
  51782. static _SceneComponentInitialization: (scene: Scene) => void;
  51783. /**
  51784. * Instantiates a new effect Layer and references it in the scene.
  51785. * @param name The name of the layer
  51786. * @param scene The scene to use the layer in
  51787. */
  51788. constructor(
  51789. /** The Friendly of the effect in the scene */
  51790. name: string, scene: Scene);
  51791. /**
  51792. * Get the effect name of the layer.
  51793. * @return The effect name
  51794. */
  51795. abstract getEffectName(): string;
  51796. /**
  51797. * Checks for the readiness of the element composing the layer.
  51798. * @param subMesh the mesh to check for
  51799. * @param useInstances specify wether or not to use instances to render the mesh
  51800. * @return true if ready otherwise, false
  51801. */
  51802. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51803. /**
  51804. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51805. * @returns true if the effect requires stencil during the main canvas render pass.
  51806. */
  51807. abstract needStencil(): boolean;
  51808. /**
  51809. * Create the merge effect. This is the shader use to blit the information back
  51810. * to the main canvas at the end of the scene rendering.
  51811. * @returns The effect containing the shader used to merge the effect on the main canvas
  51812. */
  51813. protected abstract _createMergeEffect(): Effect;
  51814. /**
  51815. * Creates the render target textures and post processes used in the effect layer.
  51816. */
  51817. protected abstract _createTextureAndPostProcesses(): void;
  51818. /**
  51819. * Implementation specific of rendering the generating effect on the main canvas.
  51820. * @param effect The effect used to render through
  51821. */
  51822. protected abstract _internalRender(effect: Effect): void;
  51823. /**
  51824. * Sets the required values for both the emissive texture and and the main color.
  51825. */
  51826. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51827. /**
  51828. * Free any resources and references associated to a mesh.
  51829. * Internal use
  51830. * @param mesh The mesh to free.
  51831. */
  51832. abstract _disposeMesh(mesh: Mesh): void;
  51833. /**
  51834. * Serializes this layer (Glow or Highlight for example)
  51835. * @returns a serialized layer object
  51836. */
  51837. abstract serialize?(): any;
  51838. /**
  51839. * Initializes the effect layer with the required options.
  51840. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51841. */
  51842. protected _init(options: Partial<IEffectLayerOptions>): void;
  51843. /**
  51844. * Generates the index buffer of the full screen quad blending to the main canvas.
  51845. */
  51846. private _generateIndexBuffer;
  51847. /**
  51848. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51849. */
  51850. private _generateVertexBuffer;
  51851. /**
  51852. * Sets the main texture desired size which is the closest power of two
  51853. * of the engine canvas size.
  51854. */
  51855. private _setMainTextureSize;
  51856. /**
  51857. * Creates the main texture for the effect layer.
  51858. */
  51859. protected _createMainTexture(): void;
  51860. /**
  51861. * Adds specific effects defines.
  51862. * @param defines The defines to add specifics to.
  51863. */
  51864. protected _addCustomEffectDefines(defines: string[]): void;
  51865. /**
  51866. * Checks for the readiness of the element composing the layer.
  51867. * @param subMesh the mesh to check for
  51868. * @param useInstances specify wether or not to use instances to render the mesh
  51869. * @param emissiveTexture the associated emissive texture used to generate the glow
  51870. * @return true if ready otherwise, false
  51871. */
  51872. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51873. /**
  51874. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51875. */
  51876. render(): void;
  51877. /**
  51878. * Determine if a given mesh will be used in the current effect.
  51879. * @param mesh mesh to test
  51880. * @returns true if the mesh will be used
  51881. */
  51882. hasMesh(mesh: AbstractMesh): boolean;
  51883. /**
  51884. * Returns true if the layer contains information to display, otherwise false.
  51885. * @returns true if the glow layer should be rendered
  51886. */
  51887. shouldRender(): boolean;
  51888. /**
  51889. * Returns true if the mesh should render, otherwise false.
  51890. * @param mesh The mesh to render
  51891. * @returns true if it should render otherwise false
  51892. */
  51893. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51894. /**
  51895. * Returns true if the mesh can be rendered, otherwise false.
  51896. * @param mesh The mesh to render
  51897. * @param material The material used on the mesh
  51898. * @returns true if it can be rendered otherwise false
  51899. */
  51900. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51901. /**
  51902. * Returns true if the mesh should render, otherwise false.
  51903. * @param mesh The mesh to render
  51904. * @returns true if it should render otherwise false
  51905. */
  51906. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51907. /**
  51908. * Renders the submesh passed in parameter to the generation map.
  51909. */
  51910. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51911. /**
  51912. * Defines wether the current material of the mesh should be use to render the effect.
  51913. * @param mesh defines the current mesh to render
  51914. */
  51915. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51916. /**
  51917. * Rebuild the required buffers.
  51918. * @hidden Internal use only.
  51919. */
  51920. _rebuild(): void;
  51921. /**
  51922. * Dispose only the render target textures and post process.
  51923. */
  51924. private _disposeTextureAndPostProcesses;
  51925. /**
  51926. * Dispose the highlight layer and free resources.
  51927. */
  51928. dispose(): void;
  51929. /**
  51930. * Gets the class name of the effect layer
  51931. * @returns the string with the class name of the effect layer
  51932. */
  51933. getClassName(): string;
  51934. /**
  51935. * Creates an effect layer from parsed effect layer data
  51936. * @param parsedEffectLayer defines effect layer data
  51937. * @param scene defines the current scene
  51938. * @param rootUrl defines the root URL containing the effect layer information
  51939. * @returns a parsed effect Layer
  51940. */
  51941. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51942. }
  51943. }
  51944. declare module BABYLON {
  51945. interface AbstractScene {
  51946. /**
  51947. * The list of effect layers (highlights/glow) added to the scene
  51948. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51949. * @see http://doc.babylonjs.com/how_to/glow_layer
  51950. */
  51951. effectLayers: Array<EffectLayer>;
  51952. /**
  51953. * Removes the given effect layer from this scene.
  51954. * @param toRemove defines the effect layer to remove
  51955. * @returns the index of the removed effect layer
  51956. */
  51957. removeEffectLayer(toRemove: EffectLayer): number;
  51958. /**
  51959. * Adds the given effect layer to this scene
  51960. * @param newEffectLayer defines the effect layer to add
  51961. */
  51962. addEffectLayer(newEffectLayer: EffectLayer): void;
  51963. }
  51964. /**
  51965. * Defines the layer scene component responsible to manage any effect layers
  51966. * in a given scene.
  51967. */
  51968. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51969. /**
  51970. * The component name helpfull to identify the component in the list of scene components.
  51971. */
  51972. readonly name: string;
  51973. /**
  51974. * The scene the component belongs to.
  51975. */
  51976. scene: Scene;
  51977. private _engine;
  51978. private _renderEffects;
  51979. private _needStencil;
  51980. private _previousStencilState;
  51981. /**
  51982. * Creates a new instance of the component for the given scene
  51983. * @param scene Defines the scene to register the component in
  51984. */
  51985. constructor(scene: Scene);
  51986. /**
  51987. * Registers the component in a given scene
  51988. */
  51989. register(): void;
  51990. /**
  51991. * Rebuilds the elements related to this component in case of
  51992. * context lost for instance.
  51993. */
  51994. rebuild(): void;
  51995. /**
  51996. * Serializes the component data to the specified json object
  51997. * @param serializationObject The object to serialize to
  51998. */
  51999. serialize(serializationObject: any): void;
  52000. /**
  52001. * Adds all the elements from the container to the scene
  52002. * @param container the container holding the elements
  52003. */
  52004. addFromContainer(container: AbstractScene): void;
  52005. /**
  52006. * Removes all the elements in the container from the scene
  52007. * @param container contains the elements to remove
  52008. * @param dispose if the removed element should be disposed (default: false)
  52009. */
  52010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52011. /**
  52012. * Disposes the component and the associated ressources.
  52013. */
  52014. dispose(): void;
  52015. private _isReadyForMesh;
  52016. private _renderMainTexture;
  52017. private _setStencil;
  52018. private _setStencilBack;
  52019. private _draw;
  52020. private _drawCamera;
  52021. private _drawRenderingGroup;
  52022. }
  52023. }
  52024. declare module BABYLON {
  52025. /** @hidden */
  52026. export var glowMapMergePixelShader: {
  52027. name: string;
  52028. shader: string;
  52029. };
  52030. }
  52031. declare module BABYLON {
  52032. /** @hidden */
  52033. export var glowMapMergeVertexShader: {
  52034. name: string;
  52035. shader: string;
  52036. };
  52037. }
  52038. declare module BABYLON {
  52039. interface AbstractScene {
  52040. /**
  52041. * Return a the first highlight layer of the scene with a given name.
  52042. * @param name The name of the highlight layer to look for.
  52043. * @return The highlight layer if found otherwise null.
  52044. */
  52045. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52046. }
  52047. /**
  52048. * Glow layer options. This helps customizing the behaviour
  52049. * of the glow layer.
  52050. */
  52051. export interface IGlowLayerOptions {
  52052. /**
  52053. * Multiplication factor apply to the canvas size to compute the render target size
  52054. * used to generated the glowing objects (the smaller the faster).
  52055. */
  52056. mainTextureRatio: number;
  52057. /**
  52058. * Enforces a fixed size texture to ensure resize independant blur.
  52059. */
  52060. mainTextureFixedSize?: number;
  52061. /**
  52062. * How big is the kernel of the blur texture.
  52063. */
  52064. blurKernelSize: number;
  52065. /**
  52066. * The camera attached to the layer.
  52067. */
  52068. camera: Nullable<Camera>;
  52069. /**
  52070. * Enable MSAA by chosing the number of samples.
  52071. */
  52072. mainTextureSamples?: number;
  52073. /**
  52074. * The rendering group to draw the layer in.
  52075. */
  52076. renderingGroupId: number;
  52077. }
  52078. /**
  52079. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52080. *
  52081. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52082. *
  52083. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52084. */
  52085. export class GlowLayer extends EffectLayer {
  52086. /**
  52087. * Effect Name of the layer.
  52088. */
  52089. static readonly EffectName: string;
  52090. /**
  52091. * The default blur kernel size used for the glow.
  52092. */
  52093. static DefaultBlurKernelSize: number;
  52094. /**
  52095. * The default texture size ratio used for the glow.
  52096. */
  52097. static DefaultTextureRatio: number;
  52098. /**
  52099. * Sets the kernel size of the blur.
  52100. */
  52101. set blurKernelSize(value: number);
  52102. /**
  52103. * Gets the kernel size of the blur.
  52104. */
  52105. get blurKernelSize(): number;
  52106. /**
  52107. * Sets the glow intensity.
  52108. */
  52109. set intensity(value: number);
  52110. /**
  52111. * Gets the glow intensity.
  52112. */
  52113. get intensity(): number;
  52114. private _options;
  52115. private _intensity;
  52116. private _horizontalBlurPostprocess1;
  52117. private _verticalBlurPostprocess1;
  52118. private _horizontalBlurPostprocess2;
  52119. private _verticalBlurPostprocess2;
  52120. private _blurTexture1;
  52121. private _blurTexture2;
  52122. private _postProcesses1;
  52123. private _postProcesses2;
  52124. private _includedOnlyMeshes;
  52125. private _excludedMeshes;
  52126. private _meshesUsingTheirOwnMaterials;
  52127. /**
  52128. * Callback used to let the user override the color selection on a per mesh basis
  52129. */
  52130. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52131. /**
  52132. * Callback used to let the user override the texture selection on a per mesh basis
  52133. */
  52134. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52135. /**
  52136. * Instantiates a new glow Layer and references it to the scene.
  52137. * @param name The name of the layer
  52138. * @param scene The scene to use the layer in
  52139. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52140. */
  52141. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52142. /**
  52143. * Get the effect name of the layer.
  52144. * @return The effect name
  52145. */
  52146. getEffectName(): string;
  52147. /**
  52148. * Create the merge effect. This is the shader use to blit the information back
  52149. * to the main canvas at the end of the scene rendering.
  52150. */
  52151. protected _createMergeEffect(): Effect;
  52152. /**
  52153. * Creates the render target textures and post processes used in the glow layer.
  52154. */
  52155. protected _createTextureAndPostProcesses(): void;
  52156. /**
  52157. * Checks for the readiness of the element composing the layer.
  52158. * @param subMesh the mesh to check for
  52159. * @param useInstances specify wether or not to use instances to render the mesh
  52160. * @param emissiveTexture the associated emissive texture used to generate the glow
  52161. * @return true if ready otherwise, false
  52162. */
  52163. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52164. /**
  52165. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52166. */
  52167. needStencil(): boolean;
  52168. /**
  52169. * Returns true if the mesh can be rendered, otherwise false.
  52170. * @param mesh The mesh to render
  52171. * @param material The material used on the mesh
  52172. * @returns true if it can be rendered otherwise false
  52173. */
  52174. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52175. /**
  52176. * Implementation specific of rendering the generating effect on the main canvas.
  52177. * @param effect The effect used to render through
  52178. */
  52179. protected _internalRender(effect: Effect): void;
  52180. /**
  52181. * Sets the required values for both the emissive texture and and the main color.
  52182. */
  52183. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52184. /**
  52185. * Returns true if the mesh should render, otherwise false.
  52186. * @param mesh The mesh to render
  52187. * @returns true if it should render otherwise false
  52188. */
  52189. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52190. /**
  52191. * Adds specific effects defines.
  52192. * @param defines The defines to add specifics to.
  52193. */
  52194. protected _addCustomEffectDefines(defines: string[]): void;
  52195. /**
  52196. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52197. * @param mesh The mesh to exclude from the glow layer
  52198. */
  52199. addExcludedMesh(mesh: Mesh): void;
  52200. /**
  52201. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52202. * @param mesh The mesh to remove
  52203. */
  52204. removeExcludedMesh(mesh: Mesh): void;
  52205. /**
  52206. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52207. * @param mesh The mesh to include in the glow layer
  52208. */
  52209. addIncludedOnlyMesh(mesh: Mesh): void;
  52210. /**
  52211. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52212. * @param mesh The mesh to remove
  52213. */
  52214. removeIncludedOnlyMesh(mesh: Mesh): void;
  52215. /**
  52216. * Determine if a given mesh will be used in the glow layer
  52217. * @param mesh The mesh to test
  52218. * @returns true if the mesh will be highlighted by the current glow layer
  52219. */
  52220. hasMesh(mesh: AbstractMesh): boolean;
  52221. /**
  52222. * Defines wether the current material of the mesh should be use to render the effect.
  52223. * @param mesh defines the current mesh to render
  52224. */
  52225. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52226. /**
  52227. * Add a mesh to be rendered through its own material and not with emissive only.
  52228. * @param mesh The mesh for which we need to use its material
  52229. */
  52230. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52231. /**
  52232. * Remove a mesh from being rendered through its own material and not with emissive only.
  52233. * @param mesh The mesh for which we need to not use its material
  52234. */
  52235. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52236. /**
  52237. * Free any resources and references associated to a mesh.
  52238. * Internal use
  52239. * @param mesh The mesh to free.
  52240. * @hidden
  52241. */
  52242. _disposeMesh(mesh: Mesh): void;
  52243. /**
  52244. * Gets the class name of the effect layer
  52245. * @returns the string with the class name of the effect layer
  52246. */
  52247. getClassName(): string;
  52248. /**
  52249. * Serializes this glow layer
  52250. * @returns a serialized glow layer object
  52251. */
  52252. serialize(): any;
  52253. /**
  52254. * Creates a Glow Layer from parsed glow layer data
  52255. * @param parsedGlowLayer defines glow layer data
  52256. * @param scene defines the current scene
  52257. * @param rootUrl defines the root URL containing the glow layer information
  52258. * @returns a parsed Glow Layer
  52259. */
  52260. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52261. }
  52262. }
  52263. declare module BABYLON {
  52264. /** @hidden */
  52265. export var glowBlurPostProcessPixelShader: {
  52266. name: string;
  52267. shader: string;
  52268. };
  52269. }
  52270. declare module BABYLON {
  52271. interface AbstractScene {
  52272. /**
  52273. * Return a the first highlight layer of the scene with a given name.
  52274. * @param name The name of the highlight layer to look for.
  52275. * @return The highlight layer if found otherwise null.
  52276. */
  52277. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52278. }
  52279. /**
  52280. * Highlight layer options. This helps customizing the behaviour
  52281. * of the highlight layer.
  52282. */
  52283. export interface IHighlightLayerOptions {
  52284. /**
  52285. * Multiplication factor apply to the canvas size to compute the render target size
  52286. * used to generated the glowing objects (the smaller the faster).
  52287. */
  52288. mainTextureRatio: number;
  52289. /**
  52290. * Enforces a fixed size texture to ensure resize independant blur.
  52291. */
  52292. mainTextureFixedSize?: number;
  52293. /**
  52294. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52295. * of the picture to blur (the smaller the faster).
  52296. */
  52297. blurTextureSizeRatio: number;
  52298. /**
  52299. * How big in texel of the blur texture is the vertical blur.
  52300. */
  52301. blurVerticalSize: number;
  52302. /**
  52303. * How big in texel of the blur texture is the horizontal blur.
  52304. */
  52305. blurHorizontalSize: number;
  52306. /**
  52307. * Alpha blending mode used to apply the blur. Default is combine.
  52308. */
  52309. alphaBlendingMode: number;
  52310. /**
  52311. * The camera attached to the layer.
  52312. */
  52313. camera: Nullable<Camera>;
  52314. /**
  52315. * Should we display highlight as a solid stroke?
  52316. */
  52317. isStroke?: boolean;
  52318. /**
  52319. * The rendering group to draw the layer in.
  52320. */
  52321. renderingGroupId: number;
  52322. }
  52323. /**
  52324. * The highlight layer Helps adding a glow effect around a mesh.
  52325. *
  52326. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52327. * glowy meshes to your scene.
  52328. *
  52329. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52330. */
  52331. export class HighlightLayer extends EffectLayer {
  52332. name: string;
  52333. /**
  52334. * Effect Name of the highlight layer.
  52335. */
  52336. static readonly EffectName: string;
  52337. /**
  52338. * The neutral color used during the preparation of the glow effect.
  52339. * This is black by default as the blend operation is a blend operation.
  52340. */
  52341. static NeutralColor: Color4;
  52342. /**
  52343. * Stencil value used for glowing meshes.
  52344. */
  52345. static GlowingMeshStencilReference: number;
  52346. /**
  52347. * Stencil value used for the other meshes in the scene.
  52348. */
  52349. static NormalMeshStencilReference: number;
  52350. /**
  52351. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52352. */
  52353. innerGlow: boolean;
  52354. /**
  52355. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52356. */
  52357. outerGlow: boolean;
  52358. /**
  52359. * Specifies the horizontal size of the blur.
  52360. */
  52361. set blurHorizontalSize(value: number);
  52362. /**
  52363. * Specifies the vertical size of the blur.
  52364. */
  52365. set blurVerticalSize(value: number);
  52366. /**
  52367. * Gets the horizontal size of the blur.
  52368. */
  52369. get blurHorizontalSize(): number;
  52370. /**
  52371. * Gets the vertical size of the blur.
  52372. */
  52373. get blurVerticalSize(): number;
  52374. /**
  52375. * An event triggered when the highlight layer is being blurred.
  52376. */
  52377. onBeforeBlurObservable: Observable<HighlightLayer>;
  52378. /**
  52379. * An event triggered when the highlight layer has been blurred.
  52380. */
  52381. onAfterBlurObservable: Observable<HighlightLayer>;
  52382. private _instanceGlowingMeshStencilReference;
  52383. private _options;
  52384. private _downSamplePostprocess;
  52385. private _horizontalBlurPostprocess;
  52386. private _verticalBlurPostprocess;
  52387. private _blurTexture;
  52388. private _meshes;
  52389. private _excludedMeshes;
  52390. /**
  52391. * Instantiates a new highlight Layer and references it to the scene..
  52392. * @param name The name of the layer
  52393. * @param scene The scene to use the layer in
  52394. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52395. */
  52396. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52397. /**
  52398. * Get the effect name of the layer.
  52399. * @return The effect name
  52400. */
  52401. getEffectName(): string;
  52402. /**
  52403. * Create the merge effect. This is the shader use to blit the information back
  52404. * to the main canvas at the end of the scene rendering.
  52405. */
  52406. protected _createMergeEffect(): Effect;
  52407. /**
  52408. * Creates the render target textures and post processes used in the highlight layer.
  52409. */
  52410. protected _createTextureAndPostProcesses(): void;
  52411. /**
  52412. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52413. */
  52414. needStencil(): boolean;
  52415. /**
  52416. * Checks for the readiness of the element composing the layer.
  52417. * @param subMesh the mesh to check for
  52418. * @param useInstances specify wether or not to use instances to render the mesh
  52419. * @param emissiveTexture the associated emissive texture used to generate the glow
  52420. * @return true if ready otherwise, false
  52421. */
  52422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52423. /**
  52424. * Implementation specific of rendering the generating effect on the main canvas.
  52425. * @param effect The effect used to render through
  52426. */
  52427. protected _internalRender(effect: Effect): void;
  52428. /**
  52429. * Returns true if the layer contains information to display, otherwise false.
  52430. */
  52431. shouldRender(): boolean;
  52432. /**
  52433. * Returns true if the mesh should render, otherwise false.
  52434. * @param mesh The mesh to render
  52435. * @returns true if it should render otherwise false
  52436. */
  52437. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52438. /**
  52439. * Sets the required values for both the emissive texture and and the main color.
  52440. */
  52441. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52442. /**
  52443. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52444. * @param mesh The mesh to exclude from the highlight layer
  52445. */
  52446. addExcludedMesh(mesh: Mesh): void;
  52447. /**
  52448. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52449. * @param mesh The mesh to highlight
  52450. */
  52451. removeExcludedMesh(mesh: Mesh): void;
  52452. /**
  52453. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52454. * @param mesh mesh to test
  52455. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52456. */
  52457. hasMesh(mesh: AbstractMesh): boolean;
  52458. /**
  52459. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52460. * @param mesh The mesh to highlight
  52461. * @param color The color of the highlight
  52462. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52463. */
  52464. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52465. /**
  52466. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52467. * @param mesh The mesh to highlight
  52468. */
  52469. removeMesh(mesh: Mesh): void;
  52470. /**
  52471. * Force the stencil to the normal expected value for none glowing parts
  52472. */
  52473. private _defaultStencilReference;
  52474. /**
  52475. * Free any resources and references associated to a mesh.
  52476. * Internal use
  52477. * @param mesh The mesh to free.
  52478. * @hidden
  52479. */
  52480. _disposeMesh(mesh: Mesh): void;
  52481. /**
  52482. * Dispose the highlight layer and free resources.
  52483. */
  52484. dispose(): void;
  52485. /**
  52486. * Gets the class name of the effect layer
  52487. * @returns the string with the class name of the effect layer
  52488. */
  52489. getClassName(): string;
  52490. /**
  52491. * Serializes this Highlight layer
  52492. * @returns a serialized Highlight layer object
  52493. */
  52494. serialize(): any;
  52495. /**
  52496. * Creates a Highlight layer from parsed Highlight layer data
  52497. * @param parsedHightlightLayer defines the Highlight layer data
  52498. * @param scene defines the current scene
  52499. * @param rootUrl defines the root URL containing the Highlight layer information
  52500. * @returns a parsed Highlight layer
  52501. */
  52502. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. interface AbstractScene {
  52507. /**
  52508. * The list of layers (background and foreground) of the scene
  52509. */
  52510. layers: Array<Layer>;
  52511. }
  52512. /**
  52513. * Defines the layer scene component responsible to manage any layers
  52514. * in a given scene.
  52515. */
  52516. export class LayerSceneComponent implements ISceneComponent {
  52517. /**
  52518. * The component name helpfull to identify the component in the list of scene components.
  52519. */
  52520. readonly name: string;
  52521. /**
  52522. * The scene the component belongs to.
  52523. */
  52524. scene: Scene;
  52525. private _engine;
  52526. /**
  52527. * Creates a new instance of the component for the given scene
  52528. * @param scene Defines the scene to register the component in
  52529. */
  52530. constructor(scene: Scene);
  52531. /**
  52532. * Registers the component in a given scene
  52533. */
  52534. register(): void;
  52535. /**
  52536. * Rebuilds the elements related to this component in case of
  52537. * context lost for instance.
  52538. */
  52539. rebuild(): void;
  52540. /**
  52541. * Disposes the component and the associated ressources.
  52542. */
  52543. dispose(): void;
  52544. private _draw;
  52545. private _drawCameraPredicate;
  52546. private _drawCameraBackground;
  52547. private _drawCameraForeground;
  52548. private _drawRenderTargetPredicate;
  52549. private _drawRenderTargetBackground;
  52550. private _drawRenderTargetForeground;
  52551. /**
  52552. * Adds all the elements from the container to the scene
  52553. * @param container the container holding the elements
  52554. */
  52555. addFromContainer(container: AbstractScene): void;
  52556. /**
  52557. * Removes all the elements in the container from the scene
  52558. * @param container contains the elements to remove
  52559. * @param dispose if the removed element should be disposed (default: false)
  52560. */
  52561. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52562. }
  52563. }
  52564. declare module BABYLON {
  52565. /** @hidden */
  52566. export var layerPixelShader: {
  52567. name: string;
  52568. shader: string;
  52569. };
  52570. }
  52571. declare module BABYLON {
  52572. /** @hidden */
  52573. export var layerVertexShader: {
  52574. name: string;
  52575. shader: string;
  52576. };
  52577. }
  52578. declare module BABYLON {
  52579. /**
  52580. * This represents a full screen 2d layer.
  52581. * This can be useful to display a picture in the background of your scene for instance.
  52582. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52583. */
  52584. export class Layer {
  52585. /**
  52586. * Define the name of the layer.
  52587. */
  52588. name: string;
  52589. /**
  52590. * Define the texture the layer should display.
  52591. */
  52592. texture: Nullable<Texture>;
  52593. /**
  52594. * Is the layer in background or foreground.
  52595. */
  52596. isBackground: boolean;
  52597. /**
  52598. * Define the color of the layer (instead of texture).
  52599. */
  52600. color: Color4;
  52601. /**
  52602. * Define the scale of the layer in order to zoom in out of the texture.
  52603. */
  52604. scale: Vector2;
  52605. /**
  52606. * Define an offset for the layer in order to shift the texture.
  52607. */
  52608. offset: Vector2;
  52609. /**
  52610. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52611. */
  52612. alphaBlendingMode: number;
  52613. /**
  52614. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52615. * Alpha test will not mix with the background color in case of transparency.
  52616. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52617. */
  52618. alphaTest: boolean;
  52619. /**
  52620. * Define a mask to restrict the layer to only some of the scene cameras.
  52621. */
  52622. layerMask: number;
  52623. /**
  52624. * Define the list of render target the layer is visible into.
  52625. */
  52626. renderTargetTextures: RenderTargetTexture[];
  52627. /**
  52628. * Define if the layer is only used in renderTarget or if it also
  52629. * renders in the main frame buffer of the canvas.
  52630. */
  52631. renderOnlyInRenderTargetTextures: boolean;
  52632. private _scene;
  52633. private _vertexBuffers;
  52634. private _indexBuffer;
  52635. private _effect;
  52636. private _previousDefines;
  52637. /**
  52638. * An event triggered when the layer is disposed.
  52639. */
  52640. onDisposeObservable: Observable<Layer>;
  52641. private _onDisposeObserver;
  52642. /**
  52643. * Back compatibility with callback before the onDisposeObservable existed.
  52644. * The set callback will be triggered when the layer has been disposed.
  52645. */
  52646. set onDispose(callback: () => void);
  52647. /**
  52648. * An event triggered before rendering the scene
  52649. */
  52650. onBeforeRenderObservable: Observable<Layer>;
  52651. private _onBeforeRenderObserver;
  52652. /**
  52653. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52654. * The set callback will be triggered just before rendering the layer.
  52655. */
  52656. set onBeforeRender(callback: () => void);
  52657. /**
  52658. * An event triggered after rendering the scene
  52659. */
  52660. onAfterRenderObservable: Observable<Layer>;
  52661. private _onAfterRenderObserver;
  52662. /**
  52663. * Back compatibility with callback before the onAfterRenderObservable existed.
  52664. * The set callback will be triggered just after rendering the layer.
  52665. */
  52666. set onAfterRender(callback: () => void);
  52667. /**
  52668. * Instantiates a new layer.
  52669. * This represents a full screen 2d layer.
  52670. * This can be useful to display a picture in the background of your scene for instance.
  52671. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52672. * @param name Define the name of the layer in the scene
  52673. * @param imgUrl Define the url of the texture to display in the layer
  52674. * @param scene Define the scene the layer belongs to
  52675. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52676. * @param color Defines a color for the layer
  52677. */
  52678. constructor(
  52679. /**
  52680. * Define the name of the layer.
  52681. */
  52682. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52683. private _createIndexBuffer;
  52684. /** @hidden */
  52685. _rebuild(): void;
  52686. /**
  52687. * Renders the layer in the scene.
  52688. */
  52689. render(): void;
  52690. /**
  52691. * Disposes and releases the associated ressources.
  52692. */
  52693. dispose(): void;
  52694. }
  52695. }
  52696. declare module BABYLON {
  52697. /** @hidden */
  52698. export var lensFlarePixelShader: {
  52699. name: string;
  52700. shader: string;
  52701. };
  52702. }
  52703. declare module BABYLON {
  52704. /** @hidden */
  52705. export var lensFlareVertexShader: {
  52706. name: string;
  52707. shader: string;
  52708. };
  52709. }
  52710. declare module BABYLON {
  52711. /**
  52712. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52713. * It is usually composed of several `lensFlare`.
  52714. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52715. */
  52716. export class LensFlareSystem {
  52717. /**
  52718. * Define the name of the lens flare system
  52719. */
  52720. name: string;
  52721. /**
  52722. * List of lens flares used in this system.
  52723. */
  52724. lensFlares: LensFlare[];
  52725. /**
  52726. * Define a limit from the border the lens flare can be visible.
  52727. */
  52728. borderLimit: number;
  52729. /**
  52730. * Define a viewport border we do not want to see the lens flare in.
  52731. */
  52732. viewportBorder: number;
  52733. /**
  52734. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52735. */
  52736. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52737. /**
  52738. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52739. */
  52740. layerMask: number;
  52741. /**
  52742. * Define the id of the lens flare system in the scene.
  52743. * (equal to name by default)
  52744. */
  52745. id: string;
  52746. private _scene;
  52747. private _emitter;
  52748. private _vertexBuffers;
  52749. private _indexBuffer;
  52750. private _effect;
  52751. private _positionX;
  52752. private _positionY;
  52753. private _isEnabled;
  52754. /** @hidden */
  52755. static _SceneComponentInitialization: (scene: Scene) => void;
  52756. /**
  52757. * Instantiates a lens flare system.
  52758. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52759. * It is usually composed of several `lensFlare`.
  52760. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52761. * @param name Define the name of the lens flare system in the scene
  52762. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52763. * @param scene Define the scene the lens flare system belongs to
  52764. */
  52765. constructor(
  52766. /**
  52767. * Define the name of the lens flare system
  52768. */
  52769. name: string, emitter: any, scene: Scene);
  52770. /**
  52771. * Define if the lens flare system is enabled.
  52772. */
  52773. get isEnabled(): boolean;
  52774. set isEnabled(value: boolean);
  52775. /**
  52776. * Get the scene the effects belongs to.
  52777. * @returns the scene holding the lens flare system
  52778. */
  52779. getScene(): Scene;
  52780. /**
  52781. * Get the emitter of the lens flare system.
  52782. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52783. * @returns the emitter of the lens flare system
  52784. */
  52785. getEmitter(): any;
  52786. /**
  52787. * Set the emitter of the lens flare system.
  52788. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52789. * @param newEmitter Define the new emitter of the system
  52790. */
  52791. setEmitter(newEmitter: any): void;
  52792. /**
  52793. * Get the lens flare system emitter position.
  52794. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52795. * @returns the position
  52796. */
  52797. getEmitterPosition(): Vector3;
  52798. /**
  52799. * @hidden
  52800. */
  52801. computeEffectivePosition(globalViewport: Viewport): boolean;
  52802. /** @hidden */
  52803. _isVisible(): boolean;
  52804. /**
  52805. * @hidden
  52806. */
  52807. render(): boolean;
  52808. /**
  52809. * Dispose and release the lens flare with its associated resources.
  52810. */
  52811. dispose(): void;
  52812. /**
  52813. * Parse a lens flare system from a JSON repressentation
  52814. * @param parsedLensFlareSystem Define the JSON to parse
  52815. * @param scene Define the scene the parsed system should be instantiated in
  52816. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52817. * @returns the parsed system
  52818. */
  52819. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52820. /**
  52821. * Serialize the current Lens Flare System into a JSON representation.
  52822. * @returns the serialized JSON
  52823. */
  52824. serialize(): any;
  52825. }
  52826. }
  52827. declare module BABYLON {
  52828. /**
  52829. * This represents one of the lens effect in a `lensFlareSystem`.
  52830. * It controls one of the indiviual texture used in the effect.
  52831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52832. */
  52833. export class LensFlare {
  52834. /**
  52835. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52836. */
  52837. size: number;
  52838. /**
  52839. * 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.
  52840. */
  52841. position: number;
  52842. /**
  52843. * Define the lens color.
  52844. */
  52845. color: Color3;
  52846. /**
  52847. * Define the lens texture.
  52848. */
  52849. texture: Nullable<Texture>;
  52850. /**
  52851. * Define the alpha mode to render this particular lens.
  52852. */
  52853. alphaMode: number;
  52854. private _system;
  52855. /**
  52856. * Creates a new Lens Flare.
  52857. * This represents one of the lens effect in a `lensFlareSystem`.
  52858. * It controls one of the indiviual texture used in the effect.
  52859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52860. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52861. * @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.
  52862. * @param color Define the lens color
  52863. * @param imgUrl Define the lens texture url
  52864. * @param system Define the `lensFlareSystem` this flare is part of
  52865. * @returns The newly created Lens Flare
  52866. */
  52867. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52868. /**
  52869. * Instantiates a new Lens Flare.
  52870. * This represents one of the lens effect in a `lensFlareSystem`.
  52871. * It controls one of the indiviual texture used in the effect.
  52872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52873. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52874. * @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.
  52875. * @param color Define the lens color
  52876. * @param imgUrl Define the lens texture url
  52877. * @param system Define the `lensFlareSystem` this flare is part of
  52878. */
  52879. constructor(
  52880. /**
  52881. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52882. */
  52883. size: number,
  52884. /**
  52885. * 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.
  52886. */
  52887. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52888. /**
  52889. * Dispose and release the lens flare with its associated resources.
  52890. */
  52891. dispose(): void;
  52892. }
  52893. }
  52894. declare module BABYLON {
  52895. interface AbstractScene {
  52896. /**
  52897. * The list of lens flare system added to the scene
  52898. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52899. */
  52900. lensFlareSystems: Array<LensFlareSystem>;
  52901. /**
  52902. * Removes the given lens flare system from this scene.
  52903. * @param toRemove The lens flare system to remove
  52904. * @returns The index of the removed lens flare system
  52905. */
  52906. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52907. /**
  52908. * Adds the given lens flare system to this scene
  52909. * @param newLensFlareSystem The lens flare system to add
  52910. */
  52911. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52912. /**
  52913. * Gets a lens flare system using its name
  52914. * @param name defines the name to look for
  52915. * @returns the lens flare system or null if not found
  52916. */
  52917. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52918. /**
  52919. * Gets a lens flare system using its id
  52920. * @param id defines the id to look for
  52921. * @returns the lens flare system or null if not found
  52922. */
  52923. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52924. }
  52925. /**
  52926. * Defines the lens flare scene component responsible to manage any lens flares
  52927. * in a given scene.
  52928. */
  52929. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52930. /**
  52931. * The component name helpfull to identify the component in the list of scene components.
  52932. */
  52933. readonly name: string;
  52934. /**
  52935. * The scene the component belongs to.
  52936. */
  52937. scene: Scene;
  52938. /**
  52939. * Creates a new instance of the component for the given scene
  52940. * @param scene Defines the scene to register the component in
  52941. */
  52942. constructor(scene: Scene);
  52943. /**
  52944. * Registers the component in a given scene
  52945. */
  52946. register(): void;
  52947. /**
  52948. * Rebuilds the elements related to this component in case of
  52949. * context lost for instance.
  52950. */
  52951. rebuild(): void;
  52952. /**
  52953. * Adds all the elements from the container to the scene
  52954. * @param container the container holding the elements
  52955. */
  52956. addFromContainer(container: AbstractScene): void;
  52957. /**
  52958. * Removes all the elements in the container from the scene
  52959. * @param container contains the elements to remove
  52960. * @param dispose if the removed element should be disposed (default: false)
  52961. */
  52962. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52963. /**
  52964. * Serializes the component data to the specified json object
  52965. * @param serializationObject The object to serialize to
  52966. */
  52967. serialize(serializationObject: any): void;
  52968. /**
  52969. * Disposes the component and the associated ressources.
  52970. */
  52971. dispose(): void;
  52972. private _draw;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * Defines the shadow generator component responsible to manage any shadow generators
  52978. * in a given scene.
  52979. */
  52980. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52981. /**
  52982. * The component name helpfull to identify the component in the list of scene components.
  52983. */
  52984. readonly name: string;
  52985. /**
  52986. * The scene the component belongs to.
  52987. */
  52988. scene: Scene;
  52989. /**
  52990. * Creates a new instance of the component for the given scene
  52991. * @param scene Defines the scene to register the component in
  52992. */
  52993. constructor(scene: Scene);
  52994. /**
  52995. * Registers the component in a given scene
  52996. */
  52997. register(): void;
  52998. /**
  52999. * Rebuilds the elements related to this component in case of
  53000. * context lost for instance.
  53001. */
  53002. rebuild(): void;
  53003. /**
  53004. * Serializes the component data to the specified json object
  53005. * @param serializationObject The object to serialize to
  53006. */
  53007. serialize(serializationObject: any): void;
  53008. /**
  53009. * Adds all the elements from the container to the scene
  53010. * @param container the container holding the elements
  53011. */
  53012. addFromContainer(container: AbstractScene): void;
  53013. /**
  53014. * Removes all the elements in the container from the scene
  53015. * @param container contains the elements to remove
  53016. * @param dispose if the removed element should be disposed (default: false)
  53017. */
  53018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53019. /**
  53020. * Rebuilds the elements related to this component in case of
  53021. * context lost for instance.
  53022. */
  53023. dispose(): void;
  53024. private _gatherRenderTargets;
  53025. }
  53026. }
  53027. declare module BABYLON {
  53028. /**
  53029. * A point light is a light defined by an unique point in world space.
  53030. * The light is emitted in every direction from this point.
  53031. * A good example of a point light is a standard light bulb.
  53032. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53033. */
  53034. export class PointLight extends ShadowLight {
  53035. private _shadowAngle;
  53036. /**
  53037. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53038. * This specifies what angle the shadow will use to be created.
  53039. *
  53040. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53041. */
  53042. get shadowAngle(): number;
  53043. /**
  53044. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53045. * This specifies what angle the shadow will use to be created.
  53046. *
  53047. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53048. */
  53049. set shadowAngle(value: number);
  53050. /**
  53051. * Gets the direction if it has been set.
  53052. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53053. */
  53054. get direction(): Vector3;
  53055. /**
  53056. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53057. */
  53058. set direction(value: Vector3);
  53059. /**
  53060. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53061. * A PointLight emits the light in every direction.
  53062. * It can cast shadows.
  53063. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53064. * ```javascript
  53065. * var pointLight = new PointLight("pl", camera.position, scene);
  53066. * ```
  53067. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53068. * @param name The light friendly name
  53069. * @param position The position of the point light in the scene
  53070. * @param scene The scene the lights belongs to
  53071. */
  53072. constructor(name: string, position: Vector3, scene: Scene);
  53073. /**
  53074. * Returns the string "PointLight"
  53075. * @returns the class name
  53076. */
  53077. getClassName(): string;
  53078. /**
  53079. * Returns the integer 0.
  53080. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53081. */
  53082. getTypeID(): number;
  53083. /**
  53084. * Specifies wether or not the shadowmap should be a cube texture.
  53085. * @returns true if the shadowmap needs to be a cube texture.
  53086. */
  53087. needCube(): boolean;
  53088. /**
  53089. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53090. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53091. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53092. */
  53093. getShadowDirection(faceIndex?: number): Vector3;
  53094. /**
  53095. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53096. * - fov = PI / 2
  53097. * - aspect ratio : 1.0
  53098. * - z-near and far equal to the active camera minZ and maxZ.
  53099. * Returns the PointLight.
  53100. */
  53101. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53102. protected _buildUniformLayout(): void;
  53103. /**
  53104. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53105. * @param effect The effect to update
  53106. * @param lightIndex The index of the light in the effect to update
  53107. * @returns The point light
  53108. */
  53109. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53110. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53111. /**
  53112. * Prepares the list of defines specific to the light type.
  53113. * @param defines the list of defines
  53114. * @param lightIndex defines the index of the light for the effect
  53115. */
  53116. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53117. }
  53118. }
  53119. declare module BABYLON {
  53120. /**
  53121. * Header information of HDR texture files.
  53122. */
  53123. export interface HDRInfo {
  53124. /**
  53125. * The height of the texture in pixels.
  53126. */
  53127. height: number;
  53128. /**
  53129. * The width of the texture in pixels.
  53130. */
  53131. width: number;
  53132. /**
  53133. * The index of the beginning of the data in the binary file.
  53134. */
  53135. dataPosition: number;
  53136. }
  53137. /**
  53138. * This groups tools to convert HDR texture to native colors array.
  53139. */
  53140. export class HDRTools {
  53141. private static Ldexp;
  53142. private static Rgbe2float;
  53143. private static readStringLine;
  53144. /**
  53145. * Reads header information from an RGBE texture stored in a native array.
  53146. * More information on this format are available here:
  53147. * https://en.wikipedia.org/wiki/RGBE_image_format
  53148. *
  53149. * @param uint8array The binary file stored in native array.
  53150. * @return The header information.
  53151. */
  53152. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53153. /**
  53154. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53155. * This RGBE texture needs to store the information as a panorama.
  53156. *
  53157. * More information on this format are available here:
  53158. * https://en.wikipedia.org/wiki/RGBE_image_format
  53159. *
  53160. * @param buffer The binary file stored in an array buffer.
  53161. * @param size The expected size of the extracted cubemap.
  53162. * @return The Cube Map information.
  53163. */
  53164. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53165. /**
  53166. * Returns the pixels data extracted from an RGBE texture.
  53167. * This pixels will be stored left to right up to down in the R G B order in one array.
  53168. *
  53169. * More information on this format are available here:
  53170. * https://en.wikipedia.org/wiki/RGBE_image_format
  53171. *
  53172. * @param uint8array The binary file stored in an array buffer.
  53173. * @param hdrInfo The header information of the file.
  53174. * @return The pixels data in RGB right to left up to down order.
  53175. */
  53176. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53177. private static RGBE_ReadPixels_RLE;
  53178. }
  53179. }
  53180. declare module BABYLON {
  53181. /**
  53182. * This represents a texture coming from an HDR input.
  53183. *
  53184. * The only supported format is currently panorama picture stored in RGBE format.
  53185. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53186. */
  53187. export class HDRCubeTexture extends BaseTexture {
  53188. private static _facesMapping;
  53189. private _generateHarmonics;
  53190. private _noMipmap;
  53191. private _textureMatrix;
  53192. private _size;
  53193. private _onLoad;
  53194. private _onError;
  53195. /**
  53196. * The texture URL.
  53197. */
  53198. url: string;
  53199. /**
  53200. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53201. */
  53202. coordinatesMode: number;
  53203. protected _isBlocking: boolean;
  53204. /**
  53205. * Sets wether or not the texture is blocking during loading.
  53206. */
  53207. set isBlocking(value: boolean);
  53208. /**
  53209. * Gets wether or not the texture is blocking during loading.
  53210. */
  53211. get isBlocking(): boolean;
  53212. protected _rotationY: number;
  53213. /**
  53214. * Sets texture matrix rotation angle around Y axis in radians.
  53215. */
  53216. set rotationY(value: number);
  53217. /**
  53218. * Gets texture matrix rotation angle around Y axis radians.
  53219. */
  53220. get rotationY(): number;
  53221. /**
  53222. * Gets or sets the center of the bounding box associated with the cube texture
  53223. * It must define where the camera used to render the texture was set
  53224. */
  53225. boundingBoxPosition: Vector3;
  53226. private _boundingBoxSize;
  53227. /**
  53228. * Gets or sets the size of the bounding box associated with the cube texture
  53229. * When defined, the cubemap will switch to local mode
  53230. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53231. * @example https://www.babylonjs-playground.com/#RNASML
  53232. */
  53233. set boundingBoxSize(value: Vector3);
  53234. get boundingBoxSize(): Vector3;
  53235. /**
  53236. * Instantiates an HDRTexture from the following parameters.
  53237. *
  53238. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53239. * @param scene The scene the texture will be used in
  53240. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53241. * @param noMipmap Forces to not generate the mipmap if true
  53242. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53243. * @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)
  53244. * @param reserved Reserved flag for internal use.
  53245. */
  53246. 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>);
  53247. /**
  53248. * Get the current class name of the texture useful for serialization or dynamic coding.
  53249. * @returns "HDRCubeTexture"
  53250. */
  53251. getClassName(): string;
  53252. /**
  53253. * Occurs when the file is raw .hdr file.
  53254. */
  53255. private loadTexture;
  53256. clone(): HDRCubeTexture;
  53257. delayLoad(): void;
  53258. /**
  53259. * Get the texture reflection matrix used to rotate/transform the reflection.
  53260. * @returns the reflection matrix
  53261. */
  53262. getReflectionTextureMatrix(): Matrix;
  53263. /**
  53264. * Set the texture reflection matrix used to rotate/transform the reflection.
  53265. * @param value Define the reflection matrix to set
  53266. */
  53267. setReflectionTextureMatrix(value: Matrix): void;
  53268. /**
  53269. * Parses a JSON representation of an HDR Texture in order to create the texture
  53270. * @param parsedTexture Define the JSON representation
  53271. * @param scene Define the scene the texture should be created in
  53272. * @param rootUrl Define the root url in case we need to load relative dependencies
  53273. * @returns the newly created texture after parsing
  53274. */
  53275. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53276. serialize(): any;
  53277. }
  53278. }
  53279. declare module BABYLON {
  53280. /**
  53281. * Class used to control physics engine
  53282. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53283. */
  53284. export class PhysicsEngine implements IPhysicsEngine {
  53285. private _physicsPlugin;
  53286. /**
  53287. * Global value used to control the smallest number supported by the simulation
  53288. */
  53289. static Epsilon: number;
  53290. private _impostors;
  53291. private _joints;
  53292. private _subTimeStep;
  53293. /**
  53294. * Gets the gravity vector used by the simulation
  53295. */
  53296. gravity: Vector3;
  53297. /**
  53298. * Factory used to create the default physics plugin.
  53299. * @returns The default physics plugin
  53300. */
  53301. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53302. /**
  53303. * Creates a new Physics Engine
  53304. * @param gravity defines the gravity vector used by the simulation
  53305. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53306. */
  53307. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53308. /**
  53309. * Sets the gravity vector used by the simulation
  53310. * @param gravity defines the gravity vector to use
  53311. */
  53312. setGravity(gravity: Vector3): void;
  53313. /**
  53314. * Set the time step of the physics engine.
  53315. * Default is 1/60.
  53316. * To slow it down, enter 1/600 for example.
  53317. * To speed it up, 1/30
  53318. * @param newTimeStep defines the new timestep to apply to this world.
  53319. */
  53320. setTimeStep(newTimeStep?: number): void;
  53321. /**
  53322. * Get the time step of the physics engine.
  53323. * @returns the current time step
  53324. */
  53325. getTimeStep(): number;
  53326. /**
  53327. * Set the sub time step of the physics engine.
  53328. * Default is 0 meaning there is no sub steps
  53329. * To increase physics resolution precision, set a small value (like 1 ms)
  53330. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53331. */
  53332. setSubTimeStep(subTimeStep?: number): void;
  53333. /**
  53334. * Get the sub time step of the physics engine.
  53335. * @returns the current sub time step
  53336. */
  53337. getSubTimeStep(): number;
  53338. /**
  53339. * Release all resources
  53340. */
  53341. dispose(): void;
  53342. /**
  53343. * Gets the name of the current physics plugin
  53344. * @returns the name of the plugin
  53345. */
  53346. getPhysicsPluginName(): string;
  53347. /**
  53348. * Adding a new impostor for the impostor tracking.
  53349. * This will be done by the impostor itself.
  53350. * @param impostor the impostor to add
  53351. */
  53352. addImpostor(impostor: PhysicsImpostor): void;
  53353. /**
  53354. * Remove an impostor from the engine.
  53355. * This impostor and its mesh will not longer be updated by the physics engine.
  53356. * @param impostor the impostor to remove
  53357. */
  53358. removeImpostor(impostor: PhysicsImpostor): void;
  53359. /**
  53360. * Add a joint to the physics engine
  53361. * @param mainImpostor defines the main impostor to which the joint is added.
  53362. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53363. * @param joint defines the joint that will connect both impostors.
  53364. */
  53365. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53366. /**
  53367. * Removes a joint from the simulation
  53368. * @param mainImpostor defines the impostor used with the joint
  53369. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53370. * @param joint defines the joint to remove
  53371. */
  53372. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53373. /**
  53374. * Called by the scene. No need to call it.
  53375. * @param delta defines the timespam between frames
  53376. */
  53377. _step(delta: number): void;
  53378. /**
  53379. * Gets the current plugin used to run the simulation
  53380. * @returns current plugin
  53381. */
  53382. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53383. /**
  53384. * Gets the list of physic impostors
  53385. * @returns an array of PhysicsImpostor
  53386. */
  53387. getImpostors(): Array<PhysicsImpostor>;
  53388. /**
  53389. * Gets the impostor for a physics enabled object
  53390. * @param object defines the object impersonated by the impostor
  53391. * @returns the PhysicsImpostor or null if not found
  53392. */
  53393. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53394. /**
  53395. * Gets the impostor for a physics body object
  53396. * @param body defines physics body used by the impostor
  53397. * @returns the PhysicsImpostor or null if not found
  53398. */
  53399. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53400. /**
  53401. * Does a raycast in the physics world
  53402. * @param from when should the ray start?
  53403. * @param to when should the ray end?
  53404. * @returns PhysicsRaycastResult
  53405. */
  53406. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53407. }
  53408. }
  53409. declare module BABYLON {
  53410. /** @hidden */
  53411. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53412. private _useDeltaForWorldStep;
  53413. world: any;
  53414. name: string;
  53415. private _physicsMaterials;
  53416. private _fixedTimeStep;
  53417. private _cannonRaycastResult;
  53418. private _raycastResult;
  53419. private _physicsBodysToRemoveAfterStep;
  53420. BJSCANNON: any;
  53421. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53422. setGravity(gravity: Vector3): void;
  53423. setTimeStep(timeStep: number): void;
  53424. getTimeStep(): number;
  53425. executeStep(delta: number): void;
  53426. private _removeMarkedPhysicsBodiesFromWorld;
  53427. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53429. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53430. private _processChildMeshes;
  53431. removePhysicsBody(impostor: PhysicsImpostor): void;
  53432. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53433. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53434. private _addMaterial;
  53435. private _checkWithEpsilon;
  53436. private _createShape;
  53437. private _createHeightmap;
  53438. private _minus90X;
  53439. private _plus90X;
  53440. private _tmpPosition;
  53441. private _tmpDeltaPosition;
  53442. private _tmpUnityRotation;
  53443. private _updatePhysicsBodyTransformation;
  53444. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53445. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53446. isSupported(): boolean;
  53447. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53452. getBodyMass(impostor: PhysicsImpostor): number;
  53453. getBodyFriction(impostor: PhysicsImpostor): number;
  53454. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53455. getBodyRestitution(impostor: PhysicsImpostor): number;
  53456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53457. sleepBody(impostor: PhysicsImpostor): void;
  53458. wakeUpBody(impostor: PhysicsImpostor): void;
  53459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53460. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53463. getRadius(impostor: PhysicsImpostor): number;
  53464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53465. dispose(): void;
  53466. private _extendNamespace;
  53467. /**
  53468. * Does a raycast in the physics world
  53469. * @param from when should the ray start?
  53470. * @param to when should the ray end?
  53471. * @returns PhysicsRaycastResult
  53472. */
  53473. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53474. }
  53475. }
  53476. declare module BABYLON {
  53477. /** @hidden */
  53478. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53479. world: any;
  53480. name: string;
  53481. BJSOIMO: any;
  53482. private _raycastResult;
  53483. constructor(iterations?: number, oimoInjection?: any);
  53484. setGravity(gravity: Vector3): void;
  53485. setTimeStep(timeStep: number): void;
  53486. getTimeStep(): number;
  53487. private _tmpImpostorsArray;
  53488. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53489. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53490. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53491. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53492. private _tmpPositionVector;
  53493. removePhysicsBody(impostor: PhysicsImpostor): void;
  53494. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53495. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53496. isSupported(): boolean;
  53497. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53498. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53499. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53501. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53502. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53503. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53504. getBodyMass(impostor: PhysicsImpostor): number;
  53505. getBodyFriction(impostor: PhysicsImpostor): number;
  53506. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53507. getBodyRestitution(impostor: PhysicsImpostor): number;
  53508. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53509. sleepBody(impostor: PhysicsImpostor): void;
  53510. wakeUpBody(impostor: PhysicsImpostor): void;
  53511. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53512. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53513. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53514. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53515. getRadius(impostor: PhysicsImpostor): number;
  53516. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53517. dispose(): void;
  53518. /**
  53519. * Does a raycast in the physics world
  53520. * @param from when should the ray start?
  53521. * @param to when should the ray end?
  53522. * @returns PhysicsRaycastResult
  53523. */
  53524. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53525. }
  53526. }
  53527. declare module BABYLON {
  53528. /**
  53529. * Class containing static functions to help procedurally build meshes
  53530. */
  53531. export class RibbonBuilder {
  53532. /**
  53533. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53534. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53535. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53536. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53537. * * 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
  53538. * * 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
  53539. * * 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
  53540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53541. * * 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
  53542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53543. * * 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
  53544. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53545. * * 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
  53546. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53548. * @param name defines the name of the mesh
  53549. * @param options defines the options used to create the mesh
  53550. * @param scene defines the hosting scene
  53551. * @returns the ribbon mesh
  53552. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53554. */
  53555. static CreateRibbon(name: string, options: {
  53556. pathArray: Vector3[][];
  53557. closeArray?: boolean;
  53558. closePath?: boolean;
  53559. offset?: number;
  53560. updatable?: boolean;
  53561. sideOrientation?: number;
  53562. frontUVs?: Vector4;
  53563. backUVs?: Vector4;
  53564. instance?: Mesh;
  53565. invertUV?: boolean;
  53566. uvs?: Vector2[];
  53567. colors?: Color4[];
  53568. }, scene?: Nullable<Scene>): Mesh;
  53569. }
  53570. }
  53571. declare module BABYLON {
  53572. /**
  53573. * Class containing static functions to help procedurally build meshes
  53574. */
  53575. export class ShapeBuilder {
  53576. /**
  53577. * 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.
  53578. * * 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.
  53579. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53580. * * 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.
  53581. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53582. * * 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
  53583. * * 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
  53584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53586. * * 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
  53587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53589. * @param name defines the name of the mesh
  53590. * @param options defines the options used to create the mesh
  53591. * @param scene defines the hosting scene
  53592. * @returns the extruded shape mesh
  53593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53595. */
  53596. static ExtrudeShape(name: string, options: {
  53597. shape: Vector3[];
  53598. path: Vector3[];
  53599. scale?: number;
  53600. rotation?: number;
  53601. cap?: number;
  53602. updatable?: boolean;
  53603. sideOrientation?: number;
  53604. frontUVs?: Vector4;
  53605. backUVs?: Vector4;
  53606. instance?: Mesh;
  53607. invertUV?: boolean;
  53608. }, scene?: Nullable<Scene>): Mesh;
  53609. /**
  53610. * Creates an custom extruded shape mesh.
  53611. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53612. * * 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.
  53613. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53614. * * 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
  53615. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53616. * * 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
  53617. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53618. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53619. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53620. * * 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
  53621. * * 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
  53622. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53624. * * 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
  53625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53627. * @param name defines the name of the mesh
  53628. * @param options defines the options used to create the mesh
  53629. * @param scene defines the hosting scene
  53630. * @returns the custom extruded shape mesh
  53631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53634. */
  53635. static ExtrudeShapeCustom(name: string, options: {
  53636. shape: Vector3[];
  53637. path: Vector3[];
  53638. scaleFunction?: any;
  53639. rotationFunction?: any;
  53640. ribbonCloseArray?: boolean;
  53641. ribbonClosePath?: boolean;
  53642. cap?: number;
  53643. updatable?: boolean;
  53644. sideOrientation?: number;
  53645. frontUVs?: Vector4;
  53646. backUVs?: Vector4;
  53647. instance?: Mesh;
  53648. invertUV?: boolean;
  53649. }, scene?: Nullable<Scene>): Mesh;
  53650. private static _ExtrudeShapeGeneric;
  53651. }
  53652. }
  53653. declare module BABYLON {
  53654. /**
  53655. * AmmoJS Physics plugin
  53656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53657. * @see https://github.com/kripken/ammo.js/
  53658. */
  53659. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53660. private _useDeltaForWorldStep;
  53661. /**
  53662. * Reference to the Ammo library
  53663. */
  53664. bjsAMMO: any;
  53665. /**
  53666. * Created ammoJS world which physics bodies are added to
  53667. */
  53668. world: any;
  53669. /**
  53670. * Name of the plugin
  53671. */
  53672. name: string;
  53673. private _timeStep;
  53674. private _fixedTimeStep;
  53675. private _maxSteps;
  53676. private _tmpQuaternion;
  53677. private _tmpAmmoTransform;
  53678. private _tmpAmmoQuaternion;
  53679. private _tmpAmmoConcreteContactResultCallback;
  53680. private _collisionConfiguration;
  53681. private _dispatcher;
  53682. private _overlappingPairCache;
  53683. private _solver;
  53684. private _softBodySolver;
  53685. private _tmpAmmoVectorA;
  53686. private _tmpAmmoVectorB;
  53687. private _tmpAmmoVectorC;
  53688. private _tmpAmmoVectorD;
  53689. private _tmpContactCallbackResult;
  53690. private _tmpAmmoVectorRCA;
  53691. private _tmpAmmoVectorRCB;
  53692. private _raycastResult;
  53693. private static readonly DISABLE_COLLISION_FLAG;
  53694. private static readonly KINEMATIC_FLAG;
  53695. private static readonly DISABLE_DEACTIVATION_FLAG;
  53696. /**
  53697. * Initializes the ammoJS plugin
  53698. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53699. * @param ammoInjection can be used to inject your own ammo reference
  53700. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53701. */
  53702. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53703. /**
  53704. * Sets the gravity of the physics world (m/(s^2))
  53705. * @param gravity Gravity to set
  53706. */
  53707. setGravity(gravity: Vector3): void;
  53708. /**
  53709. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53710. * @param timeStep timestep to use in seconds
  53711. */
  53712. setTimeStep(timeStep: number): void;
  53713. /**
  53714. * 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)
  53715. * @param fixedTimeStep fixedTimeStep to use in seconds
  53716. */
  53717. setFixedTimeStep(fixedTimeStep: number): void;
  53718. /**
  53719. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53720. * @param maxSteps the maximum number of steps by the physics engine per frame
  53721. */
  53722. setMaxSteps(maxSteps: number): void;
  53723. /**
  53724. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53725. * @returns the current timestep in seconds
  53726. */
  53727. getTimeStep(): number;
  53728. /**
  53729. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53730. */
  53731. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53732. private _isImpostorInContact;
  53733. private _isImpostorPairInContact;
  53734. private _stepSimulation;
  53735. /**
  53736. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53737. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53738. * After the step the babylon meshes are set to the position of the physics imposters
  53739. * @param delta amount of time to step forward
  53740. * @param impostors array of imposters to update before/after the step
  53741. */
  53742. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53743. /**
  53744. * Update babylon mesh to match physics world object
  53745. * @param impostor imposter to match
  53746. */
  53747. private _afterSoftStep;
  53748. /**
  53749. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53750. * @param impostor imposter to match
  53751. */
  53752. private _ropeStep;
  53753. /**
  53754. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53755. * @param impostor imposter to match
  53756. */
  53757. private _softbodyOrClothStep;
  53758. private _tmpVector;
  53759. private _tmpMatrix;
  53760. /**
  53761. * Applies an impulse on the imposter
  53762. * @param impostor imposter to apply impulse to
  53763. * @param force amount of force to be applied to the imposter
  53764. * @param contactPoint the location to apply the impulse on the imposter
  53765. */
  53766. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53767. /**
  53768. * Applies a force on the imposter
  53769. * @param impostor imposter to apply force
  53770. * @param force amount of force to be applied to the imposter
  53771. * @param contactPoint the location to apply the force on the imposter
  53772. */
  53773. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53774. /**
  53775. * Creates a physics body using the plugin
  53776. * @param impostor the imposter to create the physics body on
  53777. */
  53778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53779. /**
  53780. * Removes the physics body from the imposter and disposes of the body's memory
  53781. * @param impostor imposter to remove the physics body from
  53782. */
  53783. removePhysicsBody(impostor: PhysicsImpostor): void;
  53784. /**
  53785. * Generates a joint
  53786. * @param impostorJoint the imposter joint to create the joint with
  53787. */
  53788. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53789. /**
  53790. * Removes a joint
  53791. * @param impostorJoint the imposter joint to remove the joint from
  53792. */
  53793. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53794. private _addMeshVerts;
  53795. /**
  53796. * Initialise the soft body vertices to match its object's (mesh) vertices
  53797. * Softbody vertices (nodes) are in world space and to match this
  53798. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53799. * @param impostor to create the softbody for
  53800. */
  53801. private _softVertexData;
  53802. /**
  53803. * Create an impostor's soft body
  53804. * @param impostor to create the softbody for
  53805. */
  53806. private _createSoftbody;
  53807. /**
  53808. * Create cloth for an impostor
  53809. * @param impostor to create the softbody for
  53810. */
  53811. private _createCloth;
  53812. /**
  53813. * Create rope for an impostor
  53814. * @param impostor to create the softbody for
  53815. */
  53816. private _createRope;
  53817. /**
  53818. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53819. * @param impostor to create the custom physics shape for
  53820. */
  53821. private _createCustom;
  53822. private _addHullVerts;
  53823. private _createShape;
  53824. /**
  53825. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53826. * @param impostor imposter containing the physics body and babylon object
  53827. */
  53828. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53829. /**
  53830. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53831. * @param impostor imposter containing the physics body and babylon object
  53832. * @param newPosition new position
  53833. * @param newRotation new rotation
  53834. */
  53835. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53836. /**
  53837. * If this plugin is supported
  53838. * @returns true if its supported
  53839. */
  53840. isSupported(): boolean;
  53841. /**
  53842. * Sets the linear velocity of the physics body
  53843. * @param impostor imposter to set the velocity on
  53844. * @param velocity velocity to set
  53845. */
  53846. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53847. /**
  53848. * Sets the angular velocity of the physics body
  53849. * @param impostor imposter to set the velocity on
  53850. * @param velocity velocity to set
  53851. */
  53852. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53853. /**
  53854. * gets the linear velocity
  53855. * @param impostor imposter to get linear velocity from
  53856. * @returns linear velocity
  53857. */
  53858. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53859. /**
  53860. * gets the angular velocity
  53861. * @param impostor imposter to get angular velocity from
  53862. * @returns angular velocity
  53863. */
  53864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53865. /**
  53866. * Sets the mass of physics body
  53867. * @param impostor imposter to set the mass on
  53868. * @param mass mass to set
  53869. */
  53870. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53871. /**
  53872. * Gets the mass of the physics body
  53873. * @param impostor imposter to get the mass from
  53874. * @returns mass
  53875. */
  53876. getBodyMass(impostor: PhysicsImpostor): number;
  53877. /**
  53878. * Gets friction of the impostor
  53879. * @param impostor impostor to get friction from
  53880. * @returns friction value
  53881. */
  53882. getBodyFriction(impostor: PhysicsImpostor): number;
  53883. /**
  53884. * Sets friction of the impostor
  53885. * @param impostor impostor to set friction on
  53886. * @param friction friction value
  53887. */
  53888. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53889. /**
  53890. * Gets restitution of the impostor
  53891. * @param impostor impostor to get restitution from
  53892. * @returns restitution value
  53893. */
  53894. getBodyRestitution(impostor: PhysicsImpostor): number;
  53895. /**
  53896. * Sets resitution of the impostor
  53897. * @param impostor impostor to set resitution on
  53898. * @param restitution resitution value
  53899. */
  53900. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53901. /**
  53902. * Gets pressure inside the impostor
  53903. * @param impostor impostor to get pressure from
  53904. * @returns pressure value
  53905. */
  53906. getBodyPressure(impostor: PhysicsImpostor): number;
  53907. /**
  53908. * Sets pressure inside a soft body impostor
  53909. * Cloth and rope must remain 0 pressure
  53910. * @param impostor impostor to set pressure on
  53911. * @param pressure pressure value
  53912. */
  53913. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53914. /**
  53915. * Gets stiffness of the impostor
  53916. * @param impostor impostor to get stiffness from
  53917. * @returns pressure value
  53918. */
  53919. getBodyStiffness(impostor: PhysicsImpostor): number;
  53920. /**
  53921. * Sets stiffness of the impostor
  53922. * @param impostor impostor to set stiffness on
  53923. * @param stiffness stiffness value from 0 to 1
  53924. */
  53925. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53926. /**
  53927. * Gets velocityIterations of the impostor
  53928. * @param impostor impostor to get velocity iterations from
  53929. * @returns velocityIterations value
  53930. */
  53931. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53932. /**
  53933. * Sets velocityIterations of the impostor
  53934. * @param impostor impostor to set velocity iterations on
  53935. * @param velocityIterations velocityIterations value
  53936. */
  53937. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53938. /**
  53939. * Gets positionIterations of the impostor
  53940. * @param impostor impostor to get position iterations from
  53941. * @returns positionIterations value
  53942. */
  53943. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53944. /**
  53945. * Sets positionIterations of the impostor
  53946. * @param impostor impostor to set position on
  53947. * @param positionIterations positionIterations value
  53948. */
  53949. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53950. /**
  53951. * Append an anchor to a cloth object
  53952. * @param impostor is the cloth impostor to add anchor to
  53953. * @param otherImpostor is the rigid impostor to anchor to
  53954. * @param width ratio across width from 0 to 1
  53955. * @param height ratio up height from 0 to 1
  53956. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53957. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53958. */
  53959. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53960. /**
  53961. * Append an hook to a rope object
  53962. * @param impostor is the rope impostor to add hook to
  53963. * @param otherImpostor is the rigid impostor to hook to
  53964. * @param length ratio along the rope from 0 to 1
  53965. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53966. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53967. */
  53968. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53969. /**
  53970. * Sleeps the physics body and stops it from being active
  53971. * @param impostor impostor to sleep
  53972. */
  53973. sleepBody(impostor: PhysicsImpostor): void;
  53974. /**
  53975. * Activates the physics body
  53976. * @param impostor impostor to activate
  53977. */
  53978. wakeUpBody(impostor: PhysicsImpostor): void;
  53979. /**
  53980. * Updates the distance parameters of the joint
  53981. * @param joint joint to update
  53982. * @param maxDistance maximum distance of the joint
  53983. * @param minDistance minimum distance of the joint
  53984. */
  53985. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53986. /**
  53987. * Sets a motor on the joint
  53988. * @param joint joint to set motor on
  53989. * @param speed speed of the motor
  53990. * @param maxForce maximum force of the motor
  53991. * @param motorIndex index of the motor
  53992. */
  53993. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53994. /**
  53995. * Sets the motors limit
  53996. * @param joint joint to set limit on
  53997. * @param upperLimit upper limit
  53998. * @param lowerLimit lower limit
  53999. */
  54000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54001. /**
  54002. * Syncs the position and rotation of a mesh with the impostor
  54003. * @param mesh mesh to sync
  54004. * @param impostor impostor to update the mesh with
  54005. */
  54006. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54007. /**
  54008. * Gets the radius of the impostor
  54009. * @param impostor impostor to get radius from
  54010. * @returns the radius
  54011. */
  54012. getRadius(impostor: PhysicsImpostor): number;
  54013. /**
  54014. * Gets the box size of the impostor
  54015. * @param impostor impostor to get box size from
  54016. * @param result the resulting box size
  54017. */
  54018. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54019. /**
  54020. * Disposes of the impostor
  54021. */
  54022. dispose(): void;
  54023. /**
  54024. * Does a raycast in the physics world
  54025. * @param from when should the ray start?
  54026. * @param to when should the ray end?
  54027. * @returns PhysicsRaycastResult
  54028. */
  54029. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54030. }
  54031. }
  54032. declare module BABYLON {
  54033. interface AbstractScene {
  54034. /**
  54035. * The list of reflection probes added to the scene
  54036. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54037. */
  54038. reflectionProbes: Array<ReflectionProbe>;
  54039. /**
  54040. * Removes the given reflection probe from this scene.
  54041. * @param toRemove The reflection probe to remove
  54042. * @returns The index of the removed reflection probe
  54043. */
  54044. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54045. /**
  54046. * Adds the given reflection probe to this scene.
  54047. * @param newReflectionProbe The reflection probe to add
  54048. */
  54049. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54050. }
  54051. /**
  54052. * Class used to generate realtime reflection / refraction cube textures
  54053. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54054. */
  54055. export class ReflectionProbe {
  54056. /** defines the name of the probe */
  54057. name: string;
  54058. private _scene;
  54059. private _renderTargetTexture;
  54060. private _projectionMatrix;
  54061. private _viewMatrix;
  54062. private _target;
  54063. private _add;
  54064. private _attachedMesh;
  54065. private _invertYAxis;
  54066. /** Gets or sets probe position (center of the cube map) */
  54067. position: Vector3;
  54068. /**
  54069. * Creates a new reflection probe
  54070. * @param name defines the name of the probe
  54071. * @param size defines the texture resolution (for each face)
  54072. * @param scene defines the hosting scene
  54073. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54074. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54075. */
  54076. constructor(
  54077. /** defines the name of the probe */
  54078. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54079. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54080. get samples(): number;
  54081. set samples(value: number);
  54082. /** Gets or sets the refresh rate to use (on every frame by default) */
  54083. get refreshRate(): number;
  54084. set refreshRate(value: number);
  54085. /**
  54086. * Gets the hosting scene
  54087. * @returns a Scene
  54088. */
  54089. getScene(): Scene;
  54090. /** Gets the internal CubeTexture used to render to */
  54091. get cubeTexture(): RenderTargetTexture;
  54092. /** Gets the list of meshes to render */
  54093. get renderList(): Nullable<AbstractMesh[]>;
  54094. /**
  54095. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54096. * @param mesh defines the mesh to attach to
  54097. */
  54098. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54099. /**
  54100. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54101. * @param renderingGroupId The rendering group id corresponding to its index
  54102. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54103. */
  54104. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54105. /**
  54106. * Clean all associated resources
  54107. */
  54108. dispose(): void;
  54109. /**
  54110. * Converts the reflection probe information to a readable string for debug purpose.
  54111. * @param fullDetails Supports for multiple levels of logging within scene loading
  54112. * @returns the human readable reflection probe info
  54113. */
  54114. toString(fullDetails?: boolean): string;
  54115. /**
  54116. * Get the class name of the relfection probe.
  54117. * @returns "ReflectionProbe"
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54122. * @returns The JSON representation of the texture
  54123. */
  54124. serialize(): any;
  54125. /**
  54126. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54127. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54128. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54129. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54130. * @returns The parsed reflection probe if successful
  54131. */
  54132. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /** @hidden */
  54137. export var _BabylonLoaderRegistered: boolean;
  54138. /**
  54139. * Helps setting up some configuration for the babylon file loader.
  54140. */
  54141. export class BabylonFileLoaderConfiguration {
  54142. /**
  54143. * The loader does not allow injecting custom physix engine into the plugins.
  54144. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54145. * So you could set this variable to your engine import to make it work.
  54146. */
  54147. static LoaderInjectedPhysicsEngine: any;
  54148. }
  54149. }
  54150. declare module BABYLON {
  54151. /**
  54152. * The Physically based simple base material of BJS.
  54153. *
  54154. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54155. * It is used as the base class for both the specGloss and metalRough conventions.
  54156. */
  54157. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54158. /**
  54159. * Number of Simultaneous lights allowed on the material.
  54160. */
  54161. maxSimultaneousLights: number;
  54162. /**
  54163. * If sets to true, disables all the lights affecting the material.
  54164. */
  54165. disableLighting: boolean;
  54166. /**
  54167. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54168. */
  54169. environmentTexture: BaseTexture;
  54170. /**
  54171. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54172. */
  54173. invertNormalMapX: boolean;
  54174. /**
  54175. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54176. */
  54177. invertNormalMapY: boolean;
  54178. /**
  54179. * Normal map used in the model.
  54180. */
  54181. normalTexture: BaseTexture;
  54182. /**
  54183. * Emissivie color used to self-illuminate the model.
  54184. */
  54185. emissiveColor: Color3;
  54186. /**
  54187. * Emissivie texture used to self-illuminate the model.
  54188. */
  54189. emissiveTexture: BaseTexture;
  54190. /**
  54191. * Occlusion Channel Strenght.
  54192. */
  54193. occlusionStrength: number;
  54194. /**
  54195. * Occlusion Texture of the material (adding extra occlusion effects).
  54196. */
  54197. occlusionTexture: BaseTexture;
  54198. /**
  54199. * Defines the alpha limits in alpha test mode.
  54200. */
  54201. alphaCutOff: number;
  54202. /**
  54203. * Gets the current double sided mode.
  54204. */
  54205. get doubleSided(): boolean;
  54206. /**
  54207. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54208. */
  54209. set doubleSided(value: boolean);
  54210. /**
  54211. * Stores the pre-calculated light information of a mesh in a texture.
  54212. */
  54213. lightmapTexture: BaseTexture;
  54214. /**
  54215. * If true, the light map contains occlusion information instead of lighting info.
  54216. */
  54217. useLightmapAsShadowmap: boolean;
  54218. /**
  54219. * Instantiates a new PBRMaterial instance.
  54220. *
  54221. * @param name The material name
  54222. * @param scene The scene the material will be use in.
  54223. */
  54224. constructor(name: string, scene: Scene);
  54225. getClassName(): string;
  54226. }
  54227. }
  54228. declare module BABYLON {
  54229. /**
  54230. * The PBR material of BJS following the metal roughness convention.
  54231. *
  54232. * This fits to the PBR convention in the GLTF definition:
  54233. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54234. */
  54235. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54236. /**
  54237. * The base color has two different interpretations depending on the value of metalness.
  54238. * When the material is a metal, the base color is the specific measured reflectance value
  54239. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54240. * of the material.
  54241. */
  54242. baseColor: Color3;
  54243. /**
  54244. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54245. * well as opacity information in the alpha channel.
  54246. */
  54247. baseTexture: BaseTexture;
  54248. /**
  54249. * Specifies the metallic scalar value of the material.
  54250. * Can also be used to scale the metalness values of the metallic texture.
  54251. */
  54252. metallic: number;
  54253. /**
  54254. * Specifies the roughness scalar value of the material.
  54255. * Can also be used to scale the roughness values of the metallic texture.
  54256. */
  54257. roughness: number;
  54258. /**
  54259. * Texture containing both the metallic value in the B channel and the
  54260. * roughness value in the G channel to keep better precision.
  54261. */
  54262. metallicRoughnessTexture: BaseTexture;
  54263. /**
  54264. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54265. *
  54266. * @param name The material name
  54267. * @param scene The scene the material will be use in.
  54268. */
  54269. constructor(name: string, scene: Scene);
  54270. /**
  54271. * Return the currrent class name of the material.
  54272. */
  54273. getClassName(): string;
  54274. /**
  54275. * Makes a duplicate of the current material.
  54276. * @param name - name to use for the new material.
  54277. */
  54278. clone(name: string): PBRMetallicRoughnessMaterial;
  54279. /**
  54280. * Serialize the material to a parsable JSON object.
  54281. */
  54282. serialize(): any;
  54283. /**
  54284. * Parses a JSON object correponding to the serialize function.
  54285. */
  54286. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * The PBR material of BJS following the specular glossiness convention.
  54292. *
  54293. * This fits to the PBR convention in the GLTF definition:
  54294. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54295. */
  54296. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54297. /**
  54298. * Specifies the diffuse color of the material.
  54299. */
  54300. diffuseColor: Color3;
  54301. /**
  54302. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54303. * channel.
  54304. */
  54305. diffuseTexture: BaseTexture;
  54306. /**
  54307. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54308. */
  54309. specularColor: Color3;
  54310. /**
  54311. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54312. */
  54313. glossiness: number;
  54314. /**
  54315. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54316. */
  54317. specularGlossinessTexture: BaseTexture;
  54318. /**
  54319. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54320. *
  54321. * @param name The material name
  54322. * @param scene The scene the material will be use in.
  54323. */
  54324. constructor(name: string, scene: Scene);
  54325. /**
  54326. * Return the currrent class name of the material.
  54327. */
  54328. getClassName(): string;
  54329. /**
  54330. * Makes a duplicate of the current material.
  54331. * @param name - name to use for the new material.
  54332. */
  54333. clone(name: string): PBRSpecularGlossinessMaterial;
  54334. /**
  54335. * Serialize the material to a parsable JSON object.
  54336. */
  54337. serialize(): any;
  54338. /**
  54339. * Parses a JSON object correponding to the serialize function.
  54340. */
  54341. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54342. }
  54343. }
  54344. declare module BABYLON {
  54345. /**
  54346. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54347. * It can help converting any input color in a desired output one. This can then be used to create effects
  54348. * from sepia, black and white to sixties or futuristic rendering...
  54349. *
  54350. * The only supported format is currently 3dl.
  54351. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54352. */
  54353. export class ColorGradingTexture extends BaseTexture {
  54354. /**
  54355. * The current texture matrix. (will always be identity in color grading texture)
  54356. */
  54357. private _textureMatrix;
  54358. /**
  54359. * The texture URL.
  54360. */
  54361. url: string;
  54362. /**
  54363. * Empty line regex stored for GC.
  54364. */
  54365. private static _noneEmptyLineRegex;
  54366. private _engine;
  54367. /**
  54368. * Instantiates a ColorGradingTexture from the following parameters.
  54369. *
  54370. * @param url The location of the color gradind data (currently only supporting 3dl)
  54371. * @param scene The scene the texture will be used in
  54372. */
  54373. constructor(url: string, scene: Scene);
  54374. /**
  54375. * Returns the texture matrix used in most of the material.
  54376. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54377. */
  54378. getTextureMatrix(): Matrix;
  54379. /**
  54380. * Occurs when the file being loaded is a .3dl LUT file.
  54381. */
  54382. private load3dlTexture;
  54383. /**
  54384. * Starts the loading process of the texture.
  54385. */
  54386. private loadTexture;
  54387. /**
  54388. * Clones the color gradind texture.
  54389. */
  54390. clone(): ColorGradingTexture;
  54391. /**
  54392. * Called during delayed load for textures.
  54393. */
  54394. delayLoad(): void;
  54395. /**
  54396. * Parses a color grading texture serialized by Babylon.
  54397. * @param parsedTexture The texture information being parsedTexture
  54398. * @param scene The scene to load the texture in
  54399. * @param rootUrl The root url of the data assets to load
  54400. * @return A color gradind texture
  54401. */
  54402. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54403. /**
  54404. * Serializes the LUT texture to json format.
  54405. */
  54406. serialize(): any;
  54407. }
  54408. }
  54409. declare module BABYLON {
  54410. /**
  54411. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54412. */
  54413. export class EquiRectangularCubeTexture extends BaseTexture {
  54414. /** The six faces of the cube. */
  54415. private static _FacesMapping;
  54416. private _noMipmap;
  54417. private _onLoad;
  54418. private _onError;
  54419. /** The size of the cubemap. */
  54420. private _size;
  54421. /** The buffer of the image. */
  54422. private _buffer;
  54423. /** The width of the input image. */
  54424. private _width;
  54425. /** The height of the input image. */
  54426. private _height;
  54427. /** The URL to the image. */
  54428. url: string;
  54429. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54430. coordinatesMode: number;
  54431. /**
  54432. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54433. * @param url The location of the image
  54434. * @param scene The scene the texture will be used in
  54435. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54436. * @param noMipmap Forces to not generate the mipmap if true
  54437. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54438. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54439. * @param onLoad — defines a callback called when texture is loaded
  54440. * @param onError — defines a callback called if there is an error
  54441. */
  54442. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54443. /**
  54444. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54445. */
  54446. private loadImage;
  54447. /**
  54448. * Convert the image buffer into a cubemap and create a CubeTexture.
  54449. */
  54450. private loadTexture;
  54451. /**
  54452. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54453. * @param buffer The ArrayBuffer that should be converted.
  54454. * @returns The buffer as Float32Array.
  54455. */
  54456. private getFloat32ArrayFromArrayBuffer;
  54457. /**
  54458. * Get the current class name of the texture useful for serialization or dynamic coding.
  54459. * @returns "EquiRectangularCubeTexture"
  54460. */
  54461. getClassName(): string;
  54462. /**
  54463. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54464. * @returns A clone of the current EquiRectangularCubeTexture.
  54465. */
  54466. clone(): EquiRectangularCubeTexture;
  54467. }
  54468. }
  54469. declare module BABYLON {
  54470. /**
  54471. * Based on jsTGALoader - Javascript loader for TGA file
  54472. * By Vincent Thibault
  54473. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54474. */
  54475. export class TGATools {
  54476. private static _TYPE_INDEXED;
  54477. private static _TYPE_RGB;
  54478. private static _TYPE_GREY;
  54479. private static _TYPE_RLE_INDEXED;
  54480. private static _TYPE_RLE_RGB;
  54481. private static _TYPE_RLE_GREY;
  54482. private static _ORIGIN_MASK;
  54483. private static _ORIGIN_SHIFT;
  54484. private static _ORIGIN_BL;
  54485. private static _ORIGIN_BR;
  54486. private static _ORIGIN_UL;
  54487. private static _ORIGIN_UR;
  54488. /**
  54489. * Gets the header of a TGA file
  54490. * @param data defines the TGA data
  54491. * @returns the header
  54492. */
  54493. static GetTGAHeader(data: Uint8Array): any;
  54494. /**
  54495. * Uploads TGA content to a Babylon Texture
  54496. * @hidden
  54497. */
  54498. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54499. /** @hidden */
  54500. 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;
  54501. /** @hidden */
  54502. 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;
  54503. /** @hidden */
  54504. 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;
  54505. /** @hidden */
  54506. 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;
  54507. /** @hidden */
  54508. 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;
  54509. /** @hidden */
  54510. 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;
  54511. }
  54512. }
  54513. declare module BABYLON {
  54514. /**
  54515. * Implementation of the TGA Texture Loader.
  54516. * @hidden
  54517. */
  54518. export class _TGATextureLoader implements IInternalTextureLoader {
  54519. /**
  54520. * Defines wether the loader supports cascade loading the different faces.
  54521. */
  54522. readonly supportCascades: boolean;
  54523. /**
  54524. * This returns if the loader support the current file information.
  54525. * @param extension defines the file extension of the file being loaded
  54526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54527. * @param fallback defines the fallback internal texture if any
  54528. * @param isBase64 defines whether the texture is encoded as a base64
  54529. * @param isBuffer defines whether the texture data are stored as a buffer
  54530. * @returns true if the loader can load the specified file
  54531. */
  54532. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54533. /**
  54534. * Transform the url before loading if required.
  54535. * @param rootUrl the url of the texture
  54536. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54537. * @returns the transformed texture
  54538. */
  54539. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54540. /**
  54541. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54542. * @param rootUrl the url of the texture
  54543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54544. * @returns the fallback texture
  54545. */
  54546. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54547. /**
  54548. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54549. * @param data contains the texture data
  54550. * @param texture defines the BabylonJS internal texture
  54551. * @param createPolynomials will be true if polynomials have been requested
  54552. * @param onLoad defines the callback to trigger once the texture is ready
  54553. * @param onError defines the callback to trigger in case of error
  54554. */
  54555. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54556. /**
  54557. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54558. * @param data contains the texture data
  54559. * @param texture defines the BabylonJS internal texture
  54560. * @param callback defines the method to call once ready to upload
  54561. */
  54562. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54563. }
  54564. }
  54565. declare module BABYLON {
  54566. /**
  54567. * Info about the .basis files
  54568. */
  54569. class BasisFileInfo {
  54570. /**
  54571. * If the file has alpha
  54572. */
  54573. hasAlpha: boolean;
  54574. /**
  54575. * Info about each image of the basis file
  54576. */
  54577. images: Array<{
  54578. levels: Array<{
  54579. width: number;
  54580. height: number;
  54581. transcodedPixels: ArrayBufferView;
  54582. }>;
  54583. }>;
  54584. }
  54585. /**
  54586. * Result of transcoding a basis file
  54587. */
  54588. class TranscodeResult {
  54589. /**
  54590. * Info about the .basis file
  54591. */
  54592. fileInfo: BasisFileInfo;
  54593. /**
  54594. * Format to use when loading the file
  54595. */
  54596. format: number;
  54597. }
  54598. /**
  54599. * Configuration options for the Basis transcoder
  54600. */
  54601. export class BasisTranscodeConfiguration {
  54602. /**
  54603. * Supported compression formats used to determine the supported output format of the transcoder
  54604. */
  54605. supportedCompressionFormats?: {
  54606. /**
  54607. * etc1 compression format
  54608. */
  54609. etc1?: boolean;
  54610. /**
  54611. * s3tc compression format
  54612. */
  54613. s3tc?: boolean;
  54614. /**
  54615. * pvrtc compression format
  54616. */
  54617. pvrtc?: boolean;
  54618. /**
  54619. * etc2 compression format
  54620. */
  54621. etc2?: boolean;
  54622. };
  54623. /**
  54624. * If mipmap levels should be loaded for transcoded images (Default: true)
  54625. */
  54626. loadMipmapLevels?: boolean;
  54627. /**
  54628. * Index of a single image to load (Default: all images)
  54629. */
  54630. loadSingleImage?: number;
  54631. }
  54632. /**
  54633. * Used to load .Basis files
  54634. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54635. */
  54636. export class BasisTools {
  54637. private static _IgnoreSupportedFormats;
  54638. /**
  54639. * URL to use when loading the basis transcoder
  54640. */
  54641. static JSModuleURL: string;
  54642. /**
  54643. * URL to use when loading the wasm module for the transcoder
  54644. */
  54645. static WasmModuleURL: string;
  54646. /**
  54647. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54648. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54649. * @returns internal format corresponding to the Basis format
  54650. */
  54651. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54652. private static _WorkerPromise;
  54653. private static _Worker;
  54654. private static _actionId;
  54655. private static _CreateWorkerAsync;
  54656. /**
  54657. * Transcodes a loaded image file to compressed pixel data
  54658. * @param imageData image data to transcode
  54659. * @param config configuration options for the transcoding
  54660. * @returns a promise resulting in the transcoded image
  54661. */
  54662. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54663. /**
  54664. * Loads a texture from the transcode result
  54665. * @param texture texture load to
  54666. * @param transcodeResult the result of transcoding the basis file to load from
  54667. */
  54668. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Loader for .basis file format
  54674. */
  54675. export class _BasisTextureLoader implements IInternalTextureLoader {
  54676. /**
  54677. * Defines whether the loader supports cascade loading the different faces.
  54678. */
  54679. readonly supportCascades: boolean;
  54680. /**
  54681. * This returns if the loader support the current file information.
  54682. * @param extension defines the file extension of the file being loaded
  54683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54684. * @param fallback defines the fallback internal texture if any
  54685. * @param isBase64 defines whether the texture is encoded as a base64
  54686. * @param isBuffer defines whether the texture data are stored as a buffer
  54687. * @returns true if the loader can load the specified file
  54688. */
  54689. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54690. /**
  54691. * Transform the url before loading if required.
  54692. * @param rootUrl the url of the texture
  54693. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54694. * @returns the transformed texture
  54695. */
  54696. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54697. /**
  54698. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54699. * @param rootUrl the url of the texture
  54700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54701. * @returns the fallback texture
  54702. */
  54703. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54704. /**
  54705. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54706. * @param data contains the texture data
  54707. * @param texture defines the BabylonJS internal texture
  54708. * @param createPolynomials will be true if polynomials have been requested
  54709. * @param onLoad defines the callback to trigger once the texture is ready
  54710. * @param onError defines the callback to trigger in case of error
  54711. */
  54712. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54713. /**
  54714. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54715. * @param data contains the texture data
  54716. * @param texture defines the BabylonJS internal texture
  54717. * @param callback defines the method to call once ready to upload
  54718. */
  54719. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /**
  54724. * 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.
  54725. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54726. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54727. */
  54728. export class CustomProceduralTexture extends ProceduralTexture {
  54729. private _animate;
  54730. private _time;
  54731. private _config;
  54732. private _texturePath;
  54733. /**
  54734. * Instantiates a new Custom Procedural Texture.
  54735. * 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.
  54736. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54737. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54738. * @param name Define the name of the texture
  54739. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54740. * @param size Define the size of the texture to create
  54741. * @param scene Define the scene the texture belongs to
  54742. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54743. * @param generateMipMaps Define if the texture should creates mip maps or not
  54744. */
  54745. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54746. private _loadJson;
  54747. /**
  54748. * Is the texture ready to be used ? (rendered at least once)
  54749. * @returns true if ready, otherwise, false.
  54750. */
  54751. isReady(): boolean;
  54752. /**
  54753. * Render the texture to its associated render target.
  54754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54755. */
  54756. render(useCameraPostProcess?: boolean): void;
  54757. /**
  54758. * Update the list of dependant textures samplers in the shader.
  54759. */
  54760. updateTextures(): void;
  54761. /**
  54762. * Update the uniform values of the procedural texture in the shader.
  54763. */
  54764. updateShaderUniforms(): void;
  54765. /**
  54766. * Define if the texture animates or not.
  54767. */
  54768. get animate(): boolean;
  54769. set animate(value: boolean);
  54770. }
  54771. }
  54772. declare module BABYLON {
  54773. /** @hidden */
  54774. export var noisePixelShader: {
  54775. name: string;
  54776. shader: string;
  54777. };
  54778. }
  54779. declare module BABYLON {
  54780. /**
  54781. * Class used to generate noise procedural textures
  54782. */
  54783. export class NoiseProceduralTexture extends ProceduralTexture {
  54784. private _time;
  54785. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54786. brightness: number;
  54787. /** Defines the number of octaves to process */
  54788. octaves: number;
  54789. /** Defines the level of persistence (0.8 by default) */
  54790. persistence: number;
  54791. /** Gets or sets animation speed factor (default is 1) */
  54792. animationSpeedFactor: number;
  54793. /**
  54794. * Creates a new NoiseProceduralTexture
  54795. * @param name defines the name fo the texture
  54796. * @param size defines the size of the texture (default is 256)
  54797. * @param scene defines the hosting scene
  54798. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54799. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54800. */
  54801. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54802. private _updateShaderUniforms;
  54803. protected _getDefines(): string;
  54804. /** Generate the current state of the procedural texture */
  54805. render(useCameraPostProcess?: boolean): void;
  54806. /**
  54807. * Serializes this noise procedural texture
  54808. * @returns a serialized noise procedural texture object
  54809. */
  54810. serialize(): any;
  54811. /**
  54812. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54813. * @param parsedTexture defines parsed texture data
  54814. * @param scene defines the current scene
  54815. * @param rootUrl defines the root URL containing noise procedural texture information
  54816. * @returns a parsed NoiseProceduralTexture
  54817. */
  54818. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54819. }
  54820. }
  54821. declare module BABYLON {
  54822. /**
  54823. * Raw cube texture where the raw buffers are passed in
  54824. */
  54825. export class RawCubeTexture extends CubeTexture {
  54826. /**
  54827. * Creates a cube texture where the raw buffers are passed in.
  54828. * @param scene defines the scene the texture is attached to
  54829. * @param data defines the array of data to use to create each face
  54830. * @param size defines the size of the textures
  54831. * @param format defines the format of the data
  54832. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54833. * @param generateMipMaps defines if the engine should generate the mip levels
  54834. * @param invertY defines if data must be stored with Y axis inverted
  54835. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54836. * @param compression defines the compression used (null by default)
  54837. */
  54838. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54839. /**
  54840. * Updates the raw cube texture.
  54841. * @param data defines the data to store
  54842. * @param format defines the data format
  54843. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54844. * @param invertY defines if data must be stored with Y axis inverted
  54845. * @param compression defines the compression used (null by default)
  54846. * @param level defines which level of the texture to update
  54847. */
  54848. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54849. /**
  54850. * Updates a raw cube texture with RGBD encoded data.
  54851. * @param data defines the array of data [mipmap][face] to use to create each face
  54852. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54855. * @returns a promsie that resolves when the operation is complete
  54856. */
  54857. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54858. /**
  54859. * Clones the raw cube texture.
  54860. * @return a new cube texture
  54861. */
  54862. clone(): CubeTexture;
  54863. /** @hidden */
  54864. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54865. }
  54866. }
  54867. declare module BABYLON {
  54868. /**
  54869. * Class used to store 3D textures containing user data
  54870. */
  54871. export class RawTexture3D extends Texture {
  54872. /** Gets or sets the texture format to use */
  54873. format: number;
  54874. private _engine;
  54875. /**
  54876. * Create a new RawTexture3D
  54877. * @param data defines the data of the texture
  54878. * @param width defines the width of the texture
  54879. * @param height defines the height of the texture
  54880. * @param depth defines the depth of the texture
  54881. * @param format defines the texture format to use
  54882. * @param scene defines the hosting scene
  54883. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54884. * @param invertY defines if texture must be stored with Y axis inverted
  54885. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54886. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54887. */
  54888. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54889. /** Gets or sets the texture format to use */
  54890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54891. /**
  54892. * Update the texture with new data
  54893. * @param data defines the data to store in the texture
  54894. */
  54895. update(data: ArrayBufferView): void;
  54896. }
  54897. }
  54898. declare module BABYLON {
  54899. /**
  54900. * Class used to store 2D array textures containing user data
  54901. */
  54902. export class RawTexture2DArray extends Texture {
  54903. /** Gets or sets the texture format to use */
  54904. format: number;
  54905. private _engine;
  54906. /**
  54907. * Create a new RawTexture2DArray
  54908. * @param data defines the data of the texture
  54909. * @param width defines the width of the texture
  54910. * @param height defines the height of the texture
  54911. * @param depth defines the number of layers of the texture
  54912. * @param format defines the texture format to use
  54913. * @param scene defines the hosting scene
  54914. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54915. * @param invertY defines if texture must be stored with Y axis inverted
  54916. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54917. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54918. */
  54919. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54920. /** Gets or sets the texture format to use */
  54921. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54922. /**
  54923. * Update the texture with new data
  54924. * @param data defines the data to store in the texture
  54925. */
  54926. update(data: ArrayBufferView): void;
  54927. }
  54928. }
  54929. declare module BABYLON {
  54930. /**
  54931. * Creates a refraction texture used by refraction channel of the standard material.
  54932. * It is like a mirror but to see through a material.
  54933. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54934. */
  54935. export class RefractionTexture extends RenderTargetTexture {
  54936. /**
  54937. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54938. * 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.
  54939. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54940. */
  54941. refractionPlane: Plane;
  54942. /**
  54943. * Define how deep under the surface we should see.
  54944. */
  54945. depth: number;
  54946. /**
  54947. * Creates a refraction texture used by refraction channel of the standard material.
  54948. * It is like a mirror but to see through a material.
  54949. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54950. * @param name Define the texture name
  54951. * @param size Define the size of the underlying texture
  54952. * @param scene Define the scene the refraction belongs to
  54953. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54954. */
  54955. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54956. /**
  54957. * Clone the refraction texture.
  54958. * @returns the cloned texture
  54959. */
  54960. clone(): RefractionTexture;
  54961. /**
  54962. * Serialize the texture to a JSON representation you could use in Parse later on
  54963. * @returns the serialized JSON representation
  54964. */
  54965. serialize(): any;
  54966. }
  54967. }
  54968. declare module BABYLON {
  54969. /**
  54970. * Defines the options related to the creation of an HtmlElementTexture
  54971. */
  54972. export interface IHtmlElementTextureOptions {
  54973. /**
  54974. * Defines wether mip maps should be created or not.
  54975. */
  54976. generateMipMaps?: boolean;
  54977. /**
  54978. * Defines the sampling mode of the texture.
  54979. */
  54980. samplingMode?: number;
  54981. /**
  54982. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54983. */
  54984. engine: Nullable<ThinEngine>;
  54985. /**
  54986. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54987. */
  54988. scene: Nullable<Scene>;
  54989. }
  54990. /**
  54991. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54992. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54993. * is automatically managed.
  54994. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54995. * in your application.
  54996. *
  54997. * As the update is not automatic, you need to call them manually.
  54998. */
  54999. export class HtmlElementTexture extends BaseTexture {
  55000. /**
  55001. * The texture URL.
  55002. */
  55003. element: HTMLVideoElement | HTMLCanvasElement;
  55004. private static readonly DefaultOptions;
  55005. private _textureMatrix;
  55006. private _engine;
  55007. private _isVideo;
  55008. private _generateMipMaps;
  55009. private _samplingMode;
  55010. /**
  55011. * Instantiates a HtmlElementTexture from the following parameters.
  55012. *
  55013. * @param name Defines the name of the texture
  55014. * @param element Defines the video or canvas the texture is filled with
  55015. * @param options Defines the other none mandatory texture creation options
  55016. */
  55017. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55018. private _createInternalTexture;
  55019. /**
  55020. * Returns the texture matrix used in most of the material.
  55021. */
  55022. getTextureMatrix(): Matrix;
  55023. /**
  55024. * Updates the content of the texture.
  55025. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55026. */
  55027. update(invertY?: Nullable<boolean>): void;
  55028. }
  55029. }
  55030. declare module BABYLON {
  55031. /**
  55032. * Enum used to define the target of a block
  55033. */
  55034. export enum NodeMaterialBlockTargets {
  55035. /** Vertex shader */
  55036. Vertex = 1,
  55037. /** Fragment shader */
  55038. Fragment = 2,
  55039. /** Neutral */
  55040. Neutral = 4,
  55041. /** Vertex and Fragment */
  55042. VertexAndFragment = 3
  55043. }
  55044. }
  55045. declare module BABYLON {
  55046. /**
  55047. * Defines the kind of connection point for node based material
  55048. */
  55049. export enum NodeMaterialBlockConnectionPointTypes {
  55050. /** Float */
  55051. Float = 1,
  55052. /** Int */
  55053. Int = 2,
  55054. /** Vector2 */
  55055. Vector2 = 4,
  55056. /** Vector3 */
  55057. Vector3 = 8,
  55058. /** Vector4 */
  55059. Vector4 = 16,
  55060. /** Color3 */
  55061. Color3 = 32,
  55062. /** Color4 */
  55063. Color4 = 64,
  55064. /** Matrix */
  55065. Matrix = 128,
  55066. /** Detect type based on connection */
  55067. AutoDetect = 1024,
  55068. /** Output type that will be defined by input type */
  55069. BasedOnInput = 2048
  55070. }
  55071. }
  55072. declare module BABYLON {
  55073. /**
  55074. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55075. */
  55076. export enum NodeMaterialBlockConnectionPointMode {
  55077. /** Value is an uniform */
  55078. Uniform = 0,
  55079. /** Value is a mesh attribute */
  55080. Attribute = 1,
  55081. /** Value is a varying between vertex and fragment shaders */
  55082. Varying = 2,
  55083. /** Mode is undefined */
  55084. Undefined = 3
  55085. }
  55086. }
  55087. declare module BABYLON {
  55088. /**
  55089. * Enum used to define system values e.g. values automatically provided by the system
  55090. */
  55091. export enum NodeMaterialSystemValues {
  55092. /** World */
  55093. World = 1,
  55094. /** View */
  55095. View = 2,
  55096. /** Projection */
  55097. Projection = 3,
  55098. /** ViewProjection */
  55099. ViewProjection = 4,
  55100. /** WorldView */
  55101. WorldView = 5,
  55102. /** WorldViewProjection */
  55103. WorldViewProjection = 6,
  55104. /** CameraPosition */
  55105. CameraPosition = 7,
  55106. /** Fog Color */
  55107. FogColor = 8,
  55108. /** Delta time */
  55109. DeltaTime = 9
  55110. }
  55111. }
  55112. declare module BABYLON {
  55113. /**
  55114. * Root class for all node material optimizers
  55115. */
  55116. export class NodeMaterialOptimizer {
  55117. /**
  55118. * Function used to optimize a NodeMaterial graph
  55119. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55120. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55121. */
  55122. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55123. }
  55124. }
  55125. declare module BABYLON {
  55126. /**
  55127. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55128. */
  55129. export class TransformBlock extends NodeMaterialBlock {
  55130. /**
  55131. * Defines the value to use to complement W value to transform it to a Vector4
  55132. */
  55133. complementW: number;
  55134. /**
  55135. * Defines the value to use to complement z value to transform it to a Vector4
  55136. */
  55137. complementZ: number;
  55138. /**
  55139. * Creates a new TransformBlock
  55140. * @param name defines the block name
  55141. */
  55142. constructor(name: string);
  55143. /**
  55144. * Gets the current class name
  55145. * @returns the class name
  55146. */
  55147. getClassName(): string;
  55148. /**
  55149. * Gets the vector input
  55150. */
  55151. get vector(): NodeMaterialConnectionPoint;
  55152. /**
  55153. * Gets the output component
  55154. */
  55155. get output(): NodeMaterialConnectionPoint;
  55156. /**
  55157. * Gets the matrix transform input
  55158. */
  55159. get transform(): NodeMaterialConnectionPoint;
  55160. protected _buildBlock(state: NodeMaterialBuildState): this;
  55161. serialize(): any;
  55162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55163. protected _dumpPropertiesCode(): string;
  55164. }
  55165. }
  55166. declare module BABYLON {
  55167. /**
  55168. * Block used to output the vertex position
  55169. */
  55170. export class VertexOutputBlock extends NodeMaterialBlock {
  55171. /**
  55172. * Creates a new VertexOutputBlock
  55173. * @param name defines the block name
  55174. */
  55175. constructor(name: string);
  55176. /**
  55177. * Gets the current class name
  55178. * @returns the class name
  55179. */
  55180. getClassName(): string;
  55181. /**
  55182. * Gets the vector input component
  55183. */
  55184. get vector(): NodeMaterialConnectionPoint;
  55185. protected _buildBlock(state: NodeMaterialBuildState): this;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /**
  55190. * Block used to output the final color
  55191. */
  55192. export class FragmentOutputBlock extends NodeMaterialBlock {
  55193. /**
  55194. * Create a new FragmentOutputBlock
  55195. * @param name defines the block name
  55196. */
  55197. constructor(name: string);
  55198. /**
  55199. * Gets the current class name
  55200. * @returns the class name
  55201. */
  55202. getClassName(): string;
  55203. /**
  55204. * Gets the rgba input component
  55205. */
  55206. get rgba(): NodeMaterialConnectionPoint;
  55207. /**
  55208. * Gets the rgb input component
  55209. */
  55210. get rgb(): NodeMaterialConnectionPoint;
  55211. /**
  55212. * Gets the a input component
  55213. */
  55214. get a(): NodeMaterialConnectionPoint;
  55215. protected _buildBlock(state: NodeMaterialBuildState): this;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * Block used to read a reflection texture from a sampler
  55221. */
  55222. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55223. private _define3DName;
  55224. private _defineCubicName;
  55225. private _defineExplicitName;
  55226. private _defineProjectionName;
  55227. private _defineLocalCubicName;
  55228. private _defineSphericalName;
  55229. private _definePlanarName;
  55230. private _defineEquirectangularName;
  55231. private _defineMirroredEquirectangularFixedName;
  55232. private _defineEquirectangularFixedName;
  55233. private _defineSkyboxName;
  55234. private _cubeSamplerName;
  55235. private _2DSamplerName;
  55236. private _positionUVWName;
  55237. private _directionWName;
  55238. private _reflectionCoordsName;
  55239. private _reflection2DCoordsName;
  55240. private _reflectionColorName;
  55241. private _reflectionMatrixName;
  55242. /**
  55243. * Gets or sets the texture associated with the node
  55244. */
  55245. texture: Nullable<BaseTexture>;
  55246. /**
  55247. * Create a new TextureBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the world position input component
  55258. */
  55259. get position(): NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the world position input component
  55262. */
  55263. get worldPosition(): NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the world normal input component
  55266. */
  55267. get worldNormal(): NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the world input component
  55270. */
  55271. get world(): NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the camera (or eye) position component
  55274. */
  55275. get cameraPosition(): NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the view input component
  55278. */
  55279. get view(): NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the rgb output component
  55282. */
  55283. get rgb(): NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the r output component
  55286. */
  55287. get r(): NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the g output component
  55290. */
  55291. get g(): NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the b output component
  55294. */
  55295. get b(): NodeMaterialConnectionPoint;
  55296. autoConfigure(material: NodeMaterial): void;
  55297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55298. isReady(): boolean;
  55299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55300. private _injectVertexCode;
  55301. private _writeOutput;
  55302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55303. protected _dumpPropertiesCode(): string;
  55304. serialize(): any;
  55305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55306. }
  55307. }
  55308. declare module BABYLON {
  55309. /**
  55310. * Interface used to configure the node material editor
  55311. */
  55312. export interface INodeMaterialEditorOptions {
  55313. /** Define the URl to load node editor script */
  55314. editorURL?: string;
  55315. }
  55316. /** @hidden */
  55317. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55318. /** BONES */
  55319. NUM_BONE_INFLUENCERS: number;
  55320. BonesPerMesh: number;
  55321. BONETEXTURE: boolean;
  55322. /** MORPH TARGETS */
  55323. MORPHTARGETS: boolean;
  55324. MORPHTARGETS_NORMAL: boolean;
  55325. MORPHTARGETS_TANGENT: boolean;
  55326. MORPHTARGETS_UV: boolean;
  55327. NUM_MORPH_INFLUENCERS: number;
  55328. /** IMAGE PROCESSING */
  55329. IMAGEPROCESSING: boolean;
  55330. VIGNETTE: boolean;
  55331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55332. VIGNETTEBLENDMODEOPAQUE: boolean;
  55333. TONEMAPPING: boolean;
  55334. TONEMAPPING_ACES: boolean;
  55335. CONTRAST: boolean;
  55336. EXPOSURE: boolean;
  55337. COLORCURVES: boolean;
  55338. COLORGRADING: boolean;
  55339. COLORGRADING3D: boolean;
  55340. SAMPLER3DGREENDEPTH: boolean;
  55341. SAMPLER3DBGRMAP: boolean;
  55342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55343. /** MISC. */
  55344. BUMPDIRECTUV: number;
  55345. constructor();
  55346. setValue(name: string, value: boolean): void;
  55347. }
  55348. /**
  55349. * Class used to configure NodeMaterial
  55350. */
  55351. export interface INodeMaterialOptions {
  55352. /**
  55353. * Defines if blocks should emit comments
  55354. */
  55355. emitComments: boolean;
  55356. }
  55357. /**
  55358. * Class used to create a node based material built by assembling shader blocks
  55359. */
  55360. export class NodeMaterial extends PushMaterial {
  55361. private static _BuildIdGenerator;
  55362. private _options;
  55363. private _vertexCompilationState;
  55364. private _fragmentCompilationState;
  55365. private _sharedData;
  55366. private _buildId;
  55367. private _buildWasSuccessful;
  55368. private _cachedWorldViewMatrix;
  55369. private _cachedWorldViewProjectionMatrix;
  55370. private _optimizers;
  55371. private _animationFrame;
  55372. /** Define the URl to load node editor script */
  55373. static EditorURL: string;
  55374. private BJSNODEMATERIALEDITOR;
  55375. /** Get the inspector from bundle or global */
  55376. private _getGlobalNodeMaterialEditor;
  55377. /**
  55378. * Gets or sets data used by visual editor
  55379. * @see https://nme.babylonjs.com
  55380. */
  55381. editorData: any;
  55382. /**
  55383. * 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)
  55384. */
  55385. ignoreAlpha: boolean;
  55386. /**
  55387. * Defines the maximum number of lights that can be used in the material
  55388. */
  55389. maxSimultaneousLights: number;
  55390. /**
  55391. * Observable raised when the material is built
  55392. */
  55393. onBuildObservable: Observable<NodeMaterial>;
  55394. /**
  55395. * Gets or sets the root nodes of the material vertex shader
  55396. */
  55397. _vertexOutputNodes: NodeMaterialBlock[];
  55398. /**
  55399. * Gets or sets the root nodes of the material fragment (pixel) shader
  55400. */
  55401. _fragmentOutputNodes: NodeMaterialBlock[];
  55402. /** Gets or sets options to control the node material overall behavior */
  55403. get options(): INodeMaterialOptions;
  55404. set options(options: INodeMaterialOptions);
  55405. /**
  55406. * Default configuration related to image processing available in the standard Material.
  55407. */
  55408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55409. /**
  55410. * Gets the image processing configuration used either in this material.
  55411. */
  55412. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55413. /**
  55414. * Sets the Default image processing configuration used either in the this material.
  55415. *
  55416. * If sets to null, the scene one is in use.
  55417. */
  55418. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55419. /**
  55420. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55421. */
  55422. attachedBlocks: NodeMaterialBlock[];
  55423. /**
  55424. * Create a new node based material
  55425. * @param name defines the material name
  55426. * @param scene defines the hosting scene
  55427. * @param options defines creation option
  55428. */
  55429. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55430. /**
  55431. * Gets the current class name of the material e.g. "NodeMaterial"
  55432. * @returns the class name
  55433. */
  55434. getClassName(): string;
  55435. /**
  55436. * Keep track of the image processing observer to allow dispose and replace.
  55437. */
  55438. private _imageProcessingObserver;
  55439. /**
  55440. * Attaches a new image processing configuration to the Standard Material.
  55441. * @param configuration
  55442. */
  55443. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55444. /**
  55445. * Get a block by its name
  55446. * @param name defines the name of the block to retrieve
  55447. * @returns the required block or null if not found
  55448. */
  55449. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55450. /**
  55451. * Get a block by its name
  55452. * @param predicate defines the predicate used to find the good candidate
  55453. * @returns the required block or null if not found
  55454. */
  55455. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55456. /**
  55457. * Get an input block by its name
  55458. * @param predicate defines the predicate used to find the good candidate
  55459. * @returns the required input block or null if not found
  55460. */
  55461. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55462. /**
  55463. * Gets the list of input blocks attached to this material
  55464. * @returns an array of InputBlocks
  55465. */
  55466. getInputBlocks(): InputBlock[];
  55467. /**
  55468. * Adds a new optimizer to the list of optimizers
  55469. * @param optimizer defines the optimizers to add
  55470. * @returns the current material
  55471. */
  55472. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55473. /**
  55474. * Remove an optimizer from the list of optimizers
  55475. * @param optimizer defines the optimizers to remove
  55476. * @returns the current material
  55477. */
  55478. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55479. /**
  55480. * Add a new block to the list of output nodes
  55481. * @param node defines the node to add
  55482. * @returns the current material
  55483. */
  55484. addOutputNode(node: NodeMaterialBlock): this;
  55485. /**
  55486. * Remove a block from the list of root nodes
  55487. * @param node defines the node to remove
  55488. * @returns the current material
  55489. */
  55490. removeOutputNode(node: NodeMaterialBlock): this;
  55491. private _addVertexOutputNode;
  55492. private _removeVertexOutputNode;
  55493. private _addFragmentOutputNode;
  55494. private _removeFragmentOutputNode;
  55495. /**
  55496. * Specifies if the material will require alpha blending
  55497. * @returns a boolean specifying if alpha blending is needed
  55498. */
  55499. needAlphaBlending(): boolean;
  55500. /**
  55501. * Specifies if this material should be rendered in alpha test mode
  55502. * @returns a boolean specifying if an alpha test is needed.
  55503. */
  55504. needAlphaTesting(): boolean;
  55505. private _initializeBlock;
  55506. private _resetDualBlocks;
  55507. /**
  55508. * Remove a block from the current node material
  55509. * @param block defines the block to remove
  55510. */
  55511. removeBlock(block: NodeMaterialBlock): void;
  55512. /**
  55513. * Build the material and generates the inner effect
  55514. * @param verbose defines if the build should log activity
  55515. */
  55516. build(verbose?: boolean): void;
  55517. /**
  55518. * Runs an otpimization phase to try to improve the shader code
  55519. */
  55520. optimize(): void;
  55521. private _prepareDefinesForAttributes;
  55522. /**
  55523. * Get if the submesh is ready to be used and all its information available.
  55524. * Child classes can use it to update shaders
  55525. * @param mesh defines the mesh to check
  55526. * @param subMesh defines which submesh to check
  55527. * @param useInstances specifies that instances should be used
  55528. * @returns a boolean indicating that the submesh is ready or not
  55529. */
  55530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55531. /**
  55532. * Get a string representing the shaders built by the current node graph
  55533. */
  55534. get compiledShaders(): string;
  55535. /**
  55536. * Binds the world matrix to the material
  55537. * @param world defines the world transformation matrix
  55538. */
  55539. bindOnlyWorldMatrix(world: Matrix): void;
  55540. /**
  55541. * Binds the submesh to this material by preparing the effect and shader to draw
  55542. * @param world defines the world transformation matrix
  55543. * @param mesh defines the mesh containing the submesh
  55544. * @param subMesh defines the submesh to bind the material to
  55545. */
  55546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55547. /**
  55548. * Gets the active textures from the material
  55549. * @returns an array of textures
  55550. */
  55551. getActiveTextures(): BaseTexture[];
  55552. /**
  55553. * Gets the list of texture blocks
  55554. * @returns an array of texture blocks
  55555. */
  55556. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55557. /**
  55558. * Specifies if the material uses a texture
  55559. * @param texture defines the texture to check against the material
  55560. * @returns a boolean specifying if the material uses the texture
  55561. */
  55562. hasTexture(texture: BaseTexture): boolean;
  55563. /**
  55564. * Disposes the material
  55565. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55566. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55567. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55568. */
  55569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55570. /** Creates the node editor window. */
  55571. private _createNodeEditor;
  55572. /**
  55573. * Launch the node material editor
  55574. * @param config Define the configuration of the editor
  55575. * @return a promise fulfilled when the node editor is visible
  55576. */
  55577. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55578. /**
  55579. * Clear the current material
  55580. */
  55581. clear(): void;
  55582. /**
  55583. * Clear the current material and set it to a default state
  55584. */
  55585. setToDefault(): void;
  55586. /**
  55587. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55588. * @param url defines the url to load from
  55589. * @returns a promise that will fullfil when the material is fully loaded
  55590. */
  55591. loadAsync(url: string): Promise<void>;
  55592. private _gatherBlocks;
  55593. /**
  55594. * Generate a string containing the code declaration required to create an equivalent of this material
  55595. * @returns a string
  55596. */
  55597. generateCode(): string;
  55598. /**
  55599. * Serializes this material in a JSON representation
  55600. * @returns the serialized material object
  55601. */
  55602. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  55603. private _restoreConnections;
  55604. /**
  55605. * Clear the current graph and load a new one from a serialization object
  55606. * @param source defines the JSON representation of the material
  55607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55608. */
  55609. loadFromSerialization(source: any, rootUrl?: string): void;
  55610. /**
  55611. * Creates a node material from parsed material data
  55612. * @param source defines the JSON representation of the material
  55613. * @param scene defines the hosting scene
  55614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55615. * @returns a new node material
  55616. */
  55617. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55618. /**
  55619. * Creates a new node material set to default basic configuration
  55620. * @param name defines the name of the material
  55621. * @param scene defines the hosting scene
  55622. * @returns a new NodeMaterial
  55623. */
  55624. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55625. }
  55626. }
  55627. declare module BABYLON {
  55628. /**
  55629. * Block used to read a texture from a sampler
  55630. */
  55631. export class TextureBlock extends NodeMaterialBlock {
  55632. private _defineName;
  55633. private _linearDefineName;
  55634. private _tempTextureRead;
  55635. private _samplerName;
  55636. private _transformedUVName;
  55637. private _textureTransformName;
  55638. private _textureInfoName;
  55639. private _mainUVName;
  55640. private _mainUVDefineName;
  55641. /**
  55642. * Gets or sets the texture associated with the node
  55643. */
  55644. texture: Nullable<Texture>;
  55645. /**
  55646. * Create a new TextureBlock
  55647. * @param name defines the block name
  55648. */
  55649. constructor(name: string);
  55650. /**
  55651. * Gets the current class name
  55652. * @returns the class name
  55653. */
  55654. getClassName(): string;
  55655. /**
  55656. * Gets the uv input component
  55657. */
  55658. get uv(): NodeMaterialConnectionPoint;
  55659. /**
  55660. * Gets the rgba output component
  55661. */
  55662. get rgba(): NodeMaterialConnectionPoint;
  55663. /**
  55664. * Gets the rgb output component
  55665. */
  55666. get rgb(): NodeMaterialConnectionPoint;
  55667. /**
  55668. * Gets the r output component
  55669. */
  55670. get r(): NodeMaterialConnectionPoint;
  55671. /**
  55672. * Gets the g output component
  55673. */
  55674. get g(): NodeMaterialConnectionPoint;
  55675. /**
  55676. * Gets the b output component
  55677. */
  55678. get b(): NodeMaterialConnectionPoint;
  55679. /**
  55680. * Gets the a output component
  55681. */
  55682. get a(): NodeMaterialConnectionPoint;
  55683. get target(): NodeMaterialBlockTargets;
  55684. autoConfigure(material: NodeMaterial): void;
  55685. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55687. private _getTextureBase;
  55688. isReady(): boolean;
  55689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55690. private get _isMixed();
  55691. private _injectVertexCode;
  55692. private _writeTextureRead;
  55693. private _writeOutput;
  55694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55695. protected _dumpPropertiesCode(): string;
  55696. serialize(): any;
  55697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55698. }
  55699. }
  55700. declare module BABYLON {
  55701. /**
  55702. * Class used to store shared data between 2 NodeMaterialBuildState
  55703. */
  55704. export class NodeMaterialBuildStateSharedData {
  55705. /**
  55706. * Gets the list of emitted varyings
  55707. */
  55708. temps: string[];
  55709. /**
  55710. * Gets the list of emitted varyings
  55711. */
  55712. varyings: string[];
  55713. /**
  55714. * Gets the varying declaration string
  55715. */
  55716. varyingDeclaration: string;
  55717. /**
  55718. * Input blocks
  55719. */
  55720. inputBlocks: InputBlock[];
  55721. /**
  55722. * Input blocks
  55723. */
  55724. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55725. /**
  55726. * Bindable blocks (Blocks that need to set data to the effect)
  55727. */
  55728. bindableBlocks: NodeMaterialBlock[];
  55729. /**
  55730. * List of blocks that can provide a compilation fallback
  55731. */
  55732. blocksWithFallbacks: NodeMaterialBlock[];
  55733. /**
  55734. * List of blocks that can provide a define update
  55735. */
  55736. blocksWithDefines: NodeMaterialBlock[];
  55737. /**
  55738. * List of blocks that can provide a repeatable content
  55739. */
  55740. repeatableContentBlocks: NodeMaterialBlock[];
  55741. /**
  55742. * List of blocks that can provide a dynamic list of uniforms
  55743. */
  55744. dynamicUniformBlocks: NodeMaterialBlock[];
  55745. /**
  55746. * List of blocks that can block the isReady function for the material
  55747. */
  55748. blockingBlocks: NodeMaterialBlock[];
  55749. /**
  55750. * Gets the list of animated inputs
  55751. */
  55752. animatedInputs: InputBlock[];
  55753. /**
  55754. * Build Id used to avoid multiple recompilations
  55755. */
  55756. buildId: number;
  55757. /** List of emitted variables */
  55758. variableNames: {
  55759. [key: string]: number;
  55760. };
  55761. /** List of emitted defines */
  55762. defineNames: {
  55763. [key: string]: number;
  55764. };
  55765. /** Should emit comments? */
  55766. emitComments: boolean;
  55767. /** Emit build activity */
  55768. verbose: boolean;
  55769. /** Gets or sets the hosting scene */
  55770. scene: Scene;
  55771. /**
  55772. * Gets the compilation hints emitted at compilation time
  55773. */
  55774. hints: {
  55775. needWorldViewMatrix: boolean;
  55776. needWorldViewProjectionMatrix: boolean;
  55777. needAlphaBlending: boolean;
  55778. needAlphaTesting: boolean;
  55779. };
  55780. /**
  55781. * List of compilation checks
  55782. */
  55783. checks: {
  55784. emitVertex: boolean;
  55785. emitFragment: boolean;
  55786. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55787. };
  55788. /** Creates a new shared data */
  55789. constructor();
  55790. /**
  55791. * Emits console errors and exceptions if there is a failing check
  55792. */
  55793. emitErrors(): void;
  55794. }
  55795. }
  55796. declare module BABYLON {
  55797. /**
  55798. * Class used to store node based material build state
  55799. */
  55800. export class NodeMaterialBuildState {
  55801. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55802. supportUniformBuffers: boolean;
  55803. /**
  55804. * Gets the list of emitted attributes
  55805. */
  55806. attributes: string[];
  55807. /**
  55808. * Gets the list of emitted uniforms
  55809. */
  55810. uniforms: string[];
  55811. /**
  55812. * Gets the list of emitted constants
  55813. */
  55814. constants: string[];
  55815. /**
  55816. * Gets the list of emitted samplers
  55817. */
  55818. samplers: string[];
  55819. /**
  55820. * Gets the list of emitted functions
  55821. */
  55822. functions: {
  55823. [key: string]: string;
  55824. };
  55825. /**
  55826. * Gets the list of emitted extensions
  55827. */
  55828. extensions: {
  55829. [key: string]: string;
  55830. };
  55831. /**
  55832. * Gets the target of the compilation state
  55833. */
  55834. target: NodeMaterialBlockTargets;
  55835. /**
  55836. * Gets the list of emitted counters
  55837. */
  55838. counters: {
  55839. [key: string]: number;
  55840. };
  55841. /**
  55842. * Shared data between multiple NodeMaterialBuildState instances
  55843. */
  55844. sharedData: NodeMaterialBuildStateSharedData;
  55845. /** @hidden */
  55846. _vertexState: NodeMaterialBuildState;
  55847. /** @hidden */
  55848. _attributeDeclaration: string;
  55849. /** @hidden */
  55850. _uniformDeclaration: string;
  55851. /** @hidden */
  55852. _constantDeclaration: string;
  55853. /** @hidden */
  55854. _samplerDeclaration: string;
  55855. /** @hidden */
  55856. _varyingTransfer: string;
  55857. private _repeatableContentAnchorIndex;
  55858. /** @hidden */
  55859. _builtCompilationString: string;
  55860. /**
  55861. * Gets the emitted compilation strings
  55862. */
  55863. compilationString: string;
  55864. /**
  55865. * Finalize the compilation strings
  55866. * @param state defines the current compilation state
  55867. */
  55868. finalize(state: NodeMaterialBuildState): void;
  55869. /** @hidden */
  55870. get _repeatableContentAnchor(): string;
  55871. /** @hidden */
  55872. _getFreeVariableName(prefix: string): string;
  55873. /** @hidden */
  55874. _getFreeDefineName(prefix: string): string;
  55875. /** @hidden */
  55876. _excludeVariableName(name: string): void;
  55877. /** @hidden */
  55878. _emit2DSampler(name: string): void;
  55879. /** @hidden */
  55880. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55881. /** @hidden */
  55882. _emitExtension(name: string, extension: string): void;
  55883. /** @hidden */
  55884. _emitFunction(name: string, code: string, comments: string): void;
  55885. /** @hidden */
  55886. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55887. replaceStrings?: {
  55888. search: RegExp;
  55889. replace: string;
  55890. }[];
  55891. repeatKey?: string;
  55892. }): string;
  55893. /** @hidden */
  55894. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55895. repeatKey?: string;
  55896. removeAttributes?: boolean;
  55897. removeUniforms?: boolean;
  55898. removeVaryings?: boolean;
  55899. removeIfDef?: boolean;
  55900. replaceStrings?: {
  55901. search: RegExp;
  55902. replace: string;
  55903. }[];
  55904. }, storeKey?: string): void;
  55905. /** @hidden */
  55906. _registerTempVariable(name: string): boolean;
  55907. /** @hidden */
  55908. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55909. /** @hidden */
  55910. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55911. /** @hidden */
  55912. _emitFloat(value: number): string;
  55913. }
  55914. }
  55915. declare module BABYLON {
  55916. /**
  55917. * Defines a block that can be used inside a node based material
  55918. */
  55919. export class NodeMaterialBlock {
  55920. private _buildId;
  55921. private _buildTarget;
  55922. private _target;
  55923. private _isFinalMerger;
  55924. private _isInput;
  55925. protected _isUnique: boolean;
  55926. /** @hidden */
  55927. _codeVariableName: string;
  55928. /** @hidden */
  55929. _inputs: NodeMaterialConnectionPoint[];
  55930. /** @hidden */
  55931. _outputs: NodeMaterialConnectionPoint[];
  55932. /** @hidden */
  55933. _preparationId: number;
  55934. /**
  55935. * Gets or sets the name of the block
  55936. */
  55937. name: string;
  55938. /**
  55939. * Gets or sets the unique id of the node
  55940. */
  55941. uniqueId: number;
  55942. /**
  55943. * Gets or sets the comments associated with this block
  55944. */
  55945. comments: string;
  55946. /**
  55947. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55948. */
  55949. get isUnique(): boolean;
  55950. /**
  55951. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55952. */
  55953. get isFinalMerger(): boolean;
  55954. /**
  55955. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55956. */
  55957. get isInput(): boolean;
  55958. /**
  55959. * Gets or sets the build Id
  55960. */
  55961. get buildId(): number;
  55962. set buildId(value: number);
  55963. /**
  55964. * Gets or sets the target of the block
  55965. */
  55966. get target(): NodeMaterialBlockTargets;
  55967. set target(value: NodeMaterialBlockTargets);
  55968. /**
  55969. * Gets the list of input points
  55970. */
  55971. get inputs(): NodeMaterialConnectionPoint[];
  55972. /** Gets the list of output points */
  55973. get outputs(): NodeMaterialConnectionPoint[];
  55974. /**
  55975. * Find an input by its name
  55976. * @param name defines the name of the input to look for
  55977. * @returns the input or null if not found
  55978. */
  55979. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55980. /**
  55981. * Find an output by its name
  55982. * @param name defines the name of the outputto look for
  55983. * @returns the output or null if not found
  55984. */
  55985. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55986. /**
  55987. * Creates a new NodeMaterialBlock
  55988. * @param name defines the block name
  55989. * @param target defines the target of that block (Vertex by default)
  55990. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55991. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55992. */
  55993. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55994. /**
  55995. * Initialize the block and prepare the context for build
  55996. * @param state defines the state that will be used for the build
  55997. */
  55998. initialize(state: NodeMaterialBuildState): void;
  55999. /**
  56000. * Bind data to effect. Will only be called for blocks with isBindable === true
  56001. * @param effect defines the effect to bind data to
  56002. * @param nodeMaterial defines the hosting NodeMaterial
  56003. * @param mesh defines the mesh that will be rendered
  56004. */
  56005. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56006. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56007. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56008. protected _writeFloat(value: number): string;
  56009. /**
  56010. * Gets the current class name e.g. "NodeMaterialBlock"
  56011. * @returns the class name
  56012. */
  56013. getClassName(): string;
  56014. /**
  56015. * Register a new input. Must be called inside a block constructor
  56016. * @param name defines the connection point name
  56017. * @param type defines the connection point type
  56018. * @param isOptional defines a boolean indicating that this input can be omitted
  56019. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56020. * @returns the current block
  56021. */
  56022. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56023. /**
  56024. * Register a new output. Must be called inside a block constructor
  56025. * @param name defines the connection point name
  56026. * @param type defines the connection point type
  56027. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56028. * @returns the current block
  56029. */
  56030. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56031. /**
  56032. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56033. * @param forOutput defines an optional connection point to check compatibility with
  56034. * @returns the first available input or null
  56035. */
  56036. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56037. /**
  56038. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56039. * @param forBlock defines an optional block to check compatibility with
  56040. * @returns the first available input or null
  56041. */
  56042. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56043. /**
  56044. * Gets the sibling of the given output
  56045. * @param current defines the current output
  56046. * @returns the next output in the list or null
  56047. */
  56048. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56049. /**
  56050. * Connect current block with another block
  56051. * @param other defines the block to connect with
  56052. * @param options define the various options to help pick the right connections
  56053. * @returns the current block
  56054. */
  56055. connectTo(other: NodeMaterialBlock, options?: {
  56056. input?: string;
  56057. output?: string;
  56058. outputSwizzle?: string;
  56059. }): this | undefined;
  56060. protected _buildBlock(state: NodeMaterialBuildState): void;
  56061. /**
  56062. * Add uniforms, samplers and uniform buffers at compilation time
  56063. * @param state defines the state to update
  56064. * @param nodeMaterial defines the node material requesting the update
  56065. * @param defines defines the material defines to update
  56066. * @param uniformBuffers defines the list of uniform buffer names
  56067. */
  56068. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56069. /**
  56070. * Add potential fallbacks if shader compilation fails
  56071. * @param mesh defines the mesh to be rendered
  56072. * @param fallbacks defines the current prioritized list of fallbacks
  56073. */
  56074. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56075. /**
  56076. * Initialize defines for shader compilation
  56077. * @param mesh defines the mesh to be rendered
  56078. * @param nodeMaterial defines the node material requesting the update
  56079. * @param defines defines the material defines to update
  56080. * @param useInstances specifies that instances should be used
  56081. */
  56082. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56083. /**
  56084. * Update defines for shader compilation
  56085. * @param mesh defines the mesh to be rendered
  56086. * @param nodeMaterial defines the node material requesting the update
  56087. * @param defines defines the material defines to update
  56088. * @param useInstances specifies that instances should be used
  56089. */
  56090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56091. /**
  56092. * Lets the block try to connect some inputs automatically
  56093. * @param material defines the hosting NodeMaterial
  56094. */
  56095. autoConfigure(material: NodeMaterial): void;
  56096. /**
  56097. * Function called when a block is declared as repeatable content generator
  56098. * @param vertexShaderState defines the current compilation state for the vertex shader
  56099. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56100. * @param mesh defines the mesh to be rendered
  56101. * @param defines defines the material defines to update
  56102. */
  56103. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56104. /**
  56105. * Checks if the block is ready
  56106. * @param mesh defines the mesh to be rendered
  56107. * @param nodeMaterial defines the node material requesting the update
  56108. * @param defines defines the material defines to update
  56109. * @param useInstances specifies that instances should be used
  56110. * @returns true if the block is ready
  56111. */
  56112. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56113. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56114. private _processBuild;
  56115. /**
  56116. * Compile the current node and generate the shader code
  56117. * @param state defines the current compilation state (uniforms, samplers, current string)
  56118. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56119. * @returns true if already built
  56120. */
  56121. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56122. protected _inputRename(name: string): string;
  56123. protected _outputRename(name: string): string;
  56124. protected _dumpPropertiesCode(): string;
  56125. /** @hidden */
  56126. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56127. /** @hidden */
  56128. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56129. /**
  56130. * Clone the current block to a new identical block
  56131. * @param scene defines the hosting scene
  56132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56133. * @returns a copy of the current block
  56134. */
  56135. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56136. /**
  56137. * Serializes this block in a JSON representation
  56138. * @returns the serialized block object
  56139. */
  56140. serialize(): any;
  56141. /** @hidden */
  56142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56143. /**
  56144. * Release resources
  56145. */
  56146. dispose(): void;
  56147. }
  56148. }
  56149. declare module BABYLON {
  56150. /**
  56151. * Enum defining the type of animations supported by InputBlock
  56152. */
  56153. export enum AnimatedInputBlockTypes {
  56154. /** No animation */
  56155. None = 0,
  56156. /** Time based animation. Will only work for floats */
  56157. Time = 1
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. /**
  56162. * Block used to expose an input value
  56163. */
  56164. export class InputBlock extends NodeMaterialBlock {
  56165. private _mode;
  56166. private _associatedVariableName;
  56167. private _storedValue;
  56168. private _valueCallback;
  56169. private _type;
  56170. private _animationType;
  56171. /** Gets or set a value used to limit the range of float values */
  56172. min: number;
  56173. /** Gets or set a value used to limit the range of float values */
  56174. max: number;
  56175. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56176. matrixMode: number;
  56177. /** @hidden */
  56178. _systemValue: Nullable<NodeMaterialSystemValues>;
  56179. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56180. visibleInInspector: boolean;
  56181. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56182. isConstant: boolean;
  56183. /** Gets or sets the group to use to display this block in the Inspector */
  56184. groupInInspector: string;
  56185. /**
  56186. * Gets or sets the connection point type (default is float)
  56187. */
  56188. get type(): NodeMaterialBlockConnectionPointTypes;
  56189. /**
  56190. * Creates a new InputBlock
  56191. * @param name defines the block name
  56192. * @param target defines the target of that block (Vertex by default)
  56193. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56194. */
  56195. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56196. /**
  56197. * Gets the output component
  56198. */
  56199. get output(): NodeMaterialConnectionPoint;
  56200. /**
  56201. * Set the source of this connection point to a vertex attribute
  56202. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56203. * @returns the current connection point
  56204. */
  56205. setAsAttribute(attributeName?: string): InputBlock;
  56206. /**
  56207. * Set the source of this connection point to a system value
  56208. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56209. * @returns the current connection point
  56210. */
  56211. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56212. /**
  56213. * Gets or sets the value of that point.
  56214. * Please note that this value will be ignored if valueCallback is defined
  56215. */
  56216. get value(): any;
  56217. set value(value: any);
  56218. /**
  56219. * Gets or sets a callback used to get the value of that point.
  56220. * Please note that setting this value will force the connection point to ignore the value property
  56221. */
  56222. get valueCallback(): () => any;
  56223. set valueCallback(value: () => any);
  56224. /**
  56225. * Gets or sets the associated variable name in the shader
  56226. */
  56227. get associatedVariableName(): string;
  56228. set associatedVariableName(value: string);
  56229. /** Gets or sets the type of animation applied to the input */
  56230. get animationType(): AnimatedInputBlockTypes;
  56231. set animationType(value: AnimatedInputBlockTypes);
  56232. /**
  56233. * Gets a boolean indicating that this connection point not defined yet
  56234. */
  56235. get isUndefined(): boolean;
  56236. /**
  56237. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56238. * In this case the connection point name must be the name of the uniform to use.
  56239. * Can only be set on inputs
  56240. */
  56241. get isUniform(): boolean;
  56242. set isUniform(value: boolean);
  56243. /**
  56244. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56245. * In this case the connection point name must be the name of the attribute to use
  56246. * Can only be set on inputs
  56247. */
  56248. get isAttribute(): boolean;
  56249. set isAttribute(value: boolean);
  56250. /**
  56251. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56252. * Can only be set on exit points
  56253. */
  56254. get isVarying(): boolean;
  56255. set isVarying(value: boolean);
  56256. /**
  56257. * Gets a boolean indicating that the current connection point is a system value
  56258. */
  56259. get isSystemValue(): boolean;
  56260. /**
  56261. * Gets or sets the current well known value or null if not defined as a system value
  56262. */
  56263. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56264. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56265. /**
  56266. * Gets the current class name
  56267. * @returns the class name
  56268. */
  56269. getClassName(): string;
  56270. /**
  56271. * Animate the input if animationType !== None
  56272. * @param scene defines the rendering scene
  56273. */
  56274. animate(scene: Scene): void;
  56275. private _emitDefine;
  56276. initialize(state: NodeMaterialBuildState): void;
  56277. /**
  56278. * Set the input block to its default value (based on its type)
  56279. */
  56280. setDefaultValue(): void;
  56281. private _emitConstant;
  56282. private _emit;
  56283. /** @hidden */
  56284. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56285. /** @hidden */
  56286. _transmit(effect: Effect, scene: Scene): void;
  56287. protected _buildBlock(state: NodeMaterialBuildState): void;
  56288. protected _dumpPropertiesCode(): string;
  56289. serialize(): any;
  56290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56291. }
  56292. }
  56293. declare module BABYLON {
  56294. /**
  56295. * Enum used to define the compatibility state between two connection points
  56296. */
  56297. export enum NodeMaterialConnectionPointCompatibilityStates {
  56298. /** Points are compatibles */
  56299. Compatible = 0,
  56300. /** Points are incompatible because of their types */
  56301. TypeIncompatible = 1,
  56302. /** Points are incompatible because of their targets (vertex vs fragment) */
  56303. TargetIncompatible = 2
  56304. }
  56305. /**
  56306. * Defines the direction of a connection point
  56307. */
  56308. export enum NodeMaterialConnectionPointDirection {
  56309. /** Input */
  56310. Input = 0,
  56311. /** Output */
  56312. Output = 1
  56313. }
  56314. /**
  56315. * Defines a connection point for a block
  56316. */
  56317. export class NodeMaterialConnectionPoint {
  56318. /** @hidden */
  56319. _ownerBlock: NodeMaterialBlock;
  56320. /** @hidden */
  56321. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56322. private _endpoints;
  56323. private _associatedVariableName;
  56324. private _direction;
  56325. /** @hidden */
  56326. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56327. /** @hidden */
  56328. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56329. private _type;
  56330. /** @hidden */
  56331. _enforceAssociatedVariableName: boolean;
  56332. /** Gets the direction of the point */
  56333. get direction(): NodeMaterialConnectionPointDirection;
  56334. /**
  56335. * Gets or sets the additional types supported by this connection point
  56336. */
  56337. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56338. /**
  56339. * Gets or sets the additional types excluded by this connection point
  56340. */
  56341. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56342. /**
  56343. * Observable triggered when this point is connected
  56344. */
  56345. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56346. /**
  56347. * Gets or sets the associated variable name in the shader
  56348. */
  56349. get associatedVariableName(): string;
  56350. set associatedVariableName(value: string);
  56351. /**
  56352. * Gets or sets the connection point type (default is float)
  56353. */
  56354. get type(): NodeMaterialBlockConnectionPointTypes;
  56355. set type(value: NodeMaterialBlockConnectionPointTypes);
  56356. /**
  56357. * Gets or sets the connection point name
  56358. */
  56359. name: string;
  56360. /**
  56361. * Gets or sets a boolean indicating that this connection point can be omitted
  56362. */
  56363. isOptional: boolean;
  56364. /**
  56365. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56366. */
  56367. define: string;
  56368. /** @hidden */
  56369. _prioritizeVertex: boolean;
  56370. private _target;
  56371. /** Gets or sets the target of that connection point */
  56372. get target(): NodeMaterialBlockTargets;
  56373. set target(value: NodeMaterialBlockTargets);
  56374. /**
  56375. * Gets a boolean indicating that the current point is connected
  56376. */
  56377. get isConnected(): boolean;
  56378. /**
  56379. * Gets a boolean indicating that the current point is connected to an input block
  56380. */
  56381. get isConnectedToInputBlock(): boolean;
  56382. /**
  56383. * Gets a the connected input block (if any)
  56384. */
  56385. get connectInputBlock(): Nullable<InputBlock>;
  56386. /** Get the other side of the connection (if any) */
  56387. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56388. /** Get the block that owns this connection point */
  56389. get ownerBlock(): NodeMaterialBlock;
  56390. /** Get the block connected on the other side of this connection (if any) */
  56391. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56392. /** Get the block connected on the endpoints of this connection (if any) */
  56393. get connectedBlocks(): Array<NodeMaterialBlock>;
  56394. /** Gets the list of connected endpoints */
  56395. get endpoints(): NodeMaterialConnectionPoint[];
  56396. /** Gets a boolean indicating if that output point is connected to at least one input */
  56397. get hasEndpoints(): boolean;
  56398. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56399. get isConnectedInVertexShader(): boolean;
  56400. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56401. get isConnectedInFragmentShader(): boolean;
  56402. /**
  56403. * Creates a new connection point
  56404. * @param name defines the connection point name
  56405. * @param ownerBlock defines the block hosting this connection point
  56406. * @param direction defines the direction of the connection point
  56407. */
  56408. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56409. /**
  56410. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56411. * @returns the class name
  56412. */
  56413. getClassName(): string;
  56414. /**
  56415. * Gets a boolean indicating if the current point can be connected to another point
  56416. * @param connectionPoint defines the other connection point
  56417. * @returns a boolean
  56418. */
  56419. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56420. /**
  56421. * Gets a number indicating if the current point can be connected to another point
  56422. * @param connectionPoint defines the other connection point
  56423. * @returns a number defining the compatibility state
  56424. */
  56425. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56426. /**
  56427. * Connect this point to another connection point
  56428. * @param connectionPoint defines the other connection point
  56429. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56430. * @returns the current connection point
  56431. */
  56432. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56433. /**
  56434. * Disconnect this point from one of his endpoint
  56435. * @param endpoint defines the other connection point
  56436. * @returns the current connection point
  56437. */
  56438. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56439. /**
  56440. * Serializes this point in a JSON representation
  56441. * @returns the serialized point object
  56442. */
  56443. serialize(): any;
  56444. /**
  56445. * Release resources
  56446. */
  56447. dispose(): void;
  56448. }
  56449. }
  56450. declare module BABYLON {
  56451. /**
  56452. * Block used to add support for vertex skinning (bones)
  56453. */
  56454. export class BonesBlock extends NodeMaterialBlock {
  56455. /**
  56456. * Creates a new BonesBlock
  56457. * @param name defines the block name
  56458. */
  56459. constructor(name: string);
  56460. /**
  56461. * Initialize the block and prepare the context for build
  56462. * @param state defines the state that will be used for the build
  56463. */
  56464. initialize(state: NodeMaterialBuildState): void;
  56465. /**
  56466. * Gets the current class name
  56467. * @returns the class name
  56468. */
  56469. getClassName(): string;
  56470. /**
  56471. * Gets the matrix indices input component
  56472. */
  56473. get matricesIndices(): NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the matrix weights input component
  56476. */
  56477. get matricesWeights(): NodeMaterialConnectionPoint;
  56478. /**
  56479. * Gets the extra matrix indices input component
  56480. */
  56481. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56482. /**
  56483. * Gets the extra matrix weights input component
  56484. */
  56485. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56486. /**
  56487. * Gets the world input component
  56488. */
  56489. get world(): NodeMaterialConnectionPoint;
  56490. /**
  56491. * Gets the output component
  56492. */
  56493. get output(): NodeMaterialConnectionPoint;
  56494. autoConfigure(material: NodeMaterial): void;
  56495. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56496. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56497. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56498. protected _buildBlock(state: NodeMaterialBuildState): this;
  56499. }
  56500. }
  56501. declare module BABYLON {
  56502. /**
  56503. * Block used to add support for instances
  56504. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56505. */
  56506. export class InstancesBlock extends NodeMaterialBlock {
  56507. /**
  56508. * Creates a new InstancesBlock
  56509. * @param name defines the block name
  56510. */
  56511. constructor(name: string);
  56512. /**
  56513. * Gets the current class name
  56514. * @returns the class name
  56515. */
  56516. getClassName(): string;
  56517. /**
  56518. * Gets the first world row input component
  56519. */
  56520. get world0(): NodeMaterialConnectionPoint;
  56521. /**
  56522. * Gets the second world row input component
  56523. */
  56524. get world1(): NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the third world row input component
  56527. */
  56528. get world2(): NodeMaterialConnectionPoint;
  56529. /**
  56530. * Gets the forth world row input component
  56531. */
  56532. get world3(): NodeMaterialConnectionPoint;
  56533. /**
  56534. * Gets the world input component
  56535. */
  56536. get world(): NodeMaterialConnectionPoint;
  56537. /**
  56538. * Gets the output component
  56539. */
  56540. get output(): NodeMaterialConnectionPoint;
  56541. autoConfigure(material: NodeMaterial): void;
  56542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56543. protected _buildBlock(state: NodeMaterialBuildState): this;
  56544. }
  56545. }
  56546. declare module BABYLON {
  56547. /**
  56548. * Block used to add morph targets support to vertex shader
  56549. */
  56550. export class MorphTargetsBlock extends NodeMaterialBlock {
  56551. private _repeatableContentAnchor;
  56552. private _repeatebleContentGenerated;
  56553. /**
  56554. * Create a new MorphTargetsBlock
  56555. * @param name defines the block name
  56556. */
  56557. constructor(name: string);
  56558. /**
  56559. * Gets the current class name
  56560. * @returns the class name
  56561. */
  56562. getClassName(): string;
  56563. /**
  56564. * Gets the position input component
  56565. */
  56566. get position(): NodeMaterialConnectionPoint;
  56567. /**
  56568. * Gets the normal input component
  56569. */
  56570. get normal(): NodeMaterialConnectionPoint;
  56571. /**
  56572. * Gets the tangent input component
  56573. */
  56574. get tangent(): NodeMaterialConnectionPoint;
  56575. /**
  56576. * Gets the tangent input component
  56577. */
  56578. get uv(): NodeMaterialConnectionPoint;
  56579. /**
  56580. * Gets the position output component
  56581. */
  56582. get positionOutput(): NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the normal output component
  56585. */
  56586. get normalOutput(): NodeMaterialConnectionPoint;
  56587. /**
  56588. * Gets the tangent output component
  56589. */
  56590. get tangentOutput(): NodeMaterialConnectionPoint;
  56591. /**
  56592. * Gets the tangent output component
  56593. */
  56594. get uvOutput(): NodeMaterialConnectionPoint;
  56595. initialize(state: NodeMaterialBuildState): void;
  56596. autoConfigure(material: NodeMaterial): void;
  56597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56599. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56600. protected _buildBlock(state: NodeMaterialBuildState): this;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /**
  56605. * Block used to get data information from a light
  56606. */
  56607. export class LightInformationBlock extends NodeMaterialBlock {
  56608. private _lightDataUniformName;
  56609. private _lightColorUniformName;
  56610. private _lightTypeDefineName;
  56611. /**
  56612. * Gets or sets the light associated with this block
  56613. */
  56614. light: Nullable<Light>;
  56615. /**
  56616. * Creates a new LightInformationBlock
  56617. * @param name defines the block name
  56618. */
  56619. constructor(name: string);
  56620. /**
  56621. * Gets the current class name
  56622. * @returns the class name
  56623. */
  56624. getClassName(): string;
  56625. /**
  56626. * Gets the world position input component
  56627. */
  56628. get worldPosition(): NodeMaterialConnectionPoint;
  56629. /**
  56630. * Gets the direction output component
  56631. */
  56632. get direction(): NodeMaterialConnectionPoint;
  56633. /**
  56634. * Gets the direction output component
  56635. */
  56636. get color(): NodeMaterialConnectionPoint;
  56637. /**
  56638. * Gets the direction output component
  56639. */
  56640. get intensity(): NodeMaterialConnectionPoint;
  56641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56643. protected _buildBlock(state: NodeMaterialBuildState): this;
  56644. serialize(): any;
  56645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56646. }
  56647. }
  56648. declare module BABYLON {
  56649. /**
  56650. * Block used to add image processing support to fragment shader
  56651. */
  56652. export class ImageProcessingBlock extends NodeMaterialBlock {
  56653. /**
  56654. * Create a new ImageProcessingBlock
  56655. * @param name defines the block name
  56656. */
  56657. constructor(name: string);
  56658. /**
  56659. * Gets the current class name
  56660. * @returns the class name
  56661. */
  56662. getClassName(): string;
  56663. /**
  56664. * Gets the color input component
  56665. */
  56666. get color(): NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the output component
  56669. */
  56670. get output(): NodeMaterialConnectionPoint;
  56671. /**
  56672. * Initialize the block and prepare the context for build
  56673. * @param state defines the state that will be used for the build
  56674. */
  56675. initialize(state: NodeMaterialBuildState): void;
  56676. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56679. protected _buildBlock(state: NodeMaterialBuildState): this;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Block used to pertub normals based on a normal map
  56685. */
  56686. export class PerturbNormalBlock extends NodeMaterialBlock {
  56687. private _tangentSpaceParameterName;
  56688. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56689. invertX: boolean;
  56690. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56691. invertY: boolean;
  56692. /**
  56693. * Create a new PerturbNormalBlock
  56694. * @param name defines the block name
  56695. */
  56696. constructor(name: string);
  56697. /**
  56698. * Gets the current class name
  56699. * @returns the class name
  56700. */
  56701. getClassName(): string;
  56702. /**
  56703. * Gets the world position input component
  56704. */
  56705. get worldPosition(): NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the world normal input component
  56708. */
  56709. get worldNormal(): NodeMaterialConnectionPoint;
  56710. /**
  56711. * Gets the uv input component
  56712. */
  56713. get uv(): NodeMaterialConnectionPoint;
  56714. /**
  56715. * Gets the normal map color input component
  56716. */
  56717. get normalMapColor(): NodeMaterialConnectionPoint;
  56718. /**
  56719. * Gets the strength input component
  56720. */
  56721. get strength(): NodeMaterialConnectionPoint;
  56722. /**
  56723. * Gets the output component
  56724. */
  56725. get output(): NodeMaterialConnectionPoint;
  56726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56728. autoConfigure(material: NodeMaterial): void;
  56729. protected _buildBlock(state: NodeMaterialBuildState): this;
  56730. protected _dumpPropertiesCode(): string;
  56731. serialize(): any;
  56732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56733. }
  56734. }
  56735. declare module BABYLON {
  56736. /**
  56737. * Block used to discard a pixel if a value is smaller than a cutoff
  56738. */
  56739. export class DiscardBlock extends NodeMaterialBlock {
  56740. /**
  56741. * Create a new DiscardBlock
  56742. * @param name defines the block name
  56743. */
  56744. constructor(name: string);
  56745. /**
  56746. * Gets the current class name
  56747. * @returns the class name
  56748. */
  56749. getClassName(): string;
  56750. /**
  56751. * Gets the color input component
  56752. */
  56753. get value(): NodeMaterialConnectionPoint;
  56754. /**
  56755. * Gets the cutoff input component
  56756. */
  56757. get cutoff(): NodeMaterialConnectionPoint;
  56758. protected _buildBlock(state: NodeMaterialBuildState): this;
  56759. }
  56760. }
  56761. declare module BABYLON {
  56762. /**
  56763. * Block used to test if the fragment shader is front facing
  56764. */
  56765. export class FrontFacingBlock extends NodeMaterialBlock {
  56766. /**
  56767. * Creates a new FrontFacingBlock
  56768. * @param name defines the block name
  56769. */
  56770. constructor(name: string);
  56771. /**
  56772. * Gets the current class name
  56773. * @returns the class name
  56774. */
  56775. getClassName(): string;
  56776. /**
  56777. * Gets the output component
  56778. */
  56779. get output(): NodeMaterialConnectionPoint;
  56780. protected _buildBlock(state: NodeMaterialBuildState): this;
  56781. }
  56782. }
  56783. declare module BABYLON {
  56784. /**
  56785. * Block used to get the derivative value on x and y of a given input
  56786. */
  56787. export class DerivativeBlock extends NodeMaterialBlock {
  56788. /**
  56789. * Create a new DerivativeBlock
  56790. * @param name defines the block name
  56791. */
  56792. constructor(name: string);
  56793. /**
  56794. * Gets the current class name
  56795. * @returns the class name
  56796. */
  56797. getClassName(): string;
  56798. /**
  56799. * Gets the input component
  56800. */
  56801. get input(): NodeMaterialConnectionPoint;
  56802. /**
  56803. * Gets the derivative output on x
  56804. */
  56805. get dx(): NodeMaterialConnectionPoint;
  56806. /**
  56807. * Gets the derivative output on y
  56808. */
  56809. get dy(): NodeMaterialConnectionPoint;
  56810. protected _buildBlock(state: NodeMaterialBuildState): this;
  56811. }
  56812. }
  56813. declare module BABYLON {
  56814. /**
  56815. * Block used to add support for scene fog
  56816. */
  56817. export class FogBlock extends NodeMaterialBlock {
  56818. private _fogDistanceName;
  56819. private _fogParameters;
  56820. /**
  56821. * Create a new FogBlock
  56822. * @param name defines the block name
  56823. */
  56824. constructor(name: string);
  56825. /**
  56826. * Gets the current class name
  56827. * @returns the class name
  56828. */
  56829. getClassName(): string;
  56830. /**
  56831. * Gets the world position input component
  56832. */
  56833. get worldPosition(): NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the view input component
  56836. */
  56837. get view(): NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the color input component
  56840. */
  56841. get input(): NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the fog color input component
  56844. */
  56845. get fogColor(): NodeMaterialConnectionPoint;
  56846. /**
  56847. * Gets the output component
  56848. */
  56849. get output(): NodeMaterialConnectionPoint;
  56850. autoConfigure(material: NodeMaterial): void;
  56851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56853. protected _buildBlock(state: NodeMaterialBuildState): this;
  56854. }
  56855. }
  56856. declare module BABYLON {
  56857. /**
  56858. * Block used to add light in the fragment shader
  56859. */
  56860. export class LightBlock extends NodeMaterialBlock {
  56861. private _lightId;
  56862. /**
  56863. * Gets or sets the light associated with this block
  56864. */
  56865. light: Nullable<Light>;
  56866. /**
  56867. * Create a new LightBlock
  56868. * @param name defines the block name
  56869. */
  56870. constructor(name: string);
  56871. /**
  56872. * Gets the current class name
  56873. * @returns the class name
  56874. */
  56875. getClassName(): string;
  56876. /**
  56877. * Gets the world position input component
  56878. */
  56879. get worldPosition(): NodeMaterialConnectionPoint;
  56880. /**
  56881. * Gets the world normal input component
  56882. */
  56883. get worldNormal(): NodeMaterialConnectionPoint;
  56884. /**
  56885. * Gets the camera (or eye) position component
  56886. */
  56887. get cameraPosition(): NodeMaterialConnectionPoint;
  56888. /**
  56889. * Gets the glossiness component
  56890. */
  56891. get glossiness(): NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the glossinness power component
  56894. */
  56895. get glossPower(): NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the diffuse color component
  56898. */
  56899. get diffuseColor(): NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the specular color component
  56902. */
  56903. get specularColor(): NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the diffuse output component
  56906. */
  56907. get diffuseOutput(): NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the specular output component
  56910. */
  56911. get specularOutput(): NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the shadow output component
  56914. */
  56915. get shadow(): NodeMaterialConnectionPoint;
  56916. autoConfigure(material: NodeMaterial): void;
  56917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56918. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56919. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56920. private _injectVertexCode;
  56921. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56922. serialize(): any;
  56923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Block used to multiply 2 values
  56929. */
  56930. export class MultiplyBlock extends NodeMaterialBlock {
  56931. /**
  56932. * Creates a new MultiplyBlock
  56933. * @param name defines the block name
  56934. */
  56935. constructor(name: string);
  56936. /**
  56937. * Gets the current class name
  56938. * @returns the class name
  56939. */
  56940. getClassName(): string;
  56941. /**
  56942. * Gets the left operand input component
  56943. */
  56944. get left(): NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the right operand input component
  56947. */
  56948. get right(): NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. get output(): NodeMaterialConnectionPoint;
  56953. protected _buildBlock(state: NodeMaterialBuildState): this;
  56954. }
  56955. }
  56956. declare module BABYLON {
  56957. /**
  56958. * Block used to add 2 vectors
  56959. */
  56960. export class AddBlock extends NodeMaterialBlock {
  56961. /**
  56962. * Creates a new AddBlock
  56963. * @param name defines the block name
  56964. */
  56965. constructor(name: string);
  56966. /**
  56967. * Gets the current class name
  56968. * @returns the class name
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Gets the left operand input component
  56973. */
  56974. get left(): NodeMaterialConnectionPoint;
  56975. /**
  56976. * Gets the right operand input component
  56977. */
  56978. get right(): NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the output component
  56981. */
  56982. get output(): NodeMaterialConnectionPoint;
  56983. protected _buildBlock(state: NodeMaterialBuildState): this;
  56984. }
  56985. }
  56986. declare module BABYLON {
  56987. /**
  56988. * Block used to scale a vector by a float
  56989. */
  56990. export class ScaleBlock extends NodeMaterialBlock {
  56991. /**
  56992. * Creates a new ScaleBlock
  56993. * @param name defines the block name
  56994. */
  56995. constructor(name: string);
  56996. /**
  56997. * Gets the current class name
  56998. * @returns the class name
  56999. */
  57000. getClassName(): string;
  57001. /**
  57002. * Gets the input component
  57003. */
  57004. get input(): NodeMaterialConnectionPoint;
  57005. /**
  57006. * Gets the factor input component
  57007. */
  57008. get factor(): NodeMaterialConnectionPoint;
  57009. /**
  57010. * Gets the output component
  57011. */
  57012. get output(): NodeMaterialConnectionPoint;
  57013. protected _buildBlock(state: NodeMaterialBuildState): this;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * Block used to clamp a float
  57019. */
  57020. export class ClampBlock extends NodeMaterialBlock {
  57021. /** Gets or sets the minimum range */
  57022. minimum: number;
  57023. /** Gets or sets the maximum range */
  57024. maximum: number;
  57025. /**
  57026. * Creates a new ClampBlock
  57027. * @param name defines the block name
  57028. */
  57029. constructor(name: string);
  57030. /**
  57031. * Gets the current class name
  57032. * @returns the class name
  57033. */
  57034. getClassName(): string;
  57035. /**
  57036. * Gets the value input component
  57037. */
  57038. get value(): NodeMaterialConnectionPoint;
  57039. /**
  57040. * Gets the output component
  57041. */
  57042. get output(): NodeMaterialConnectionPoint;
  57043. protected _buildBlock(state: NodeMaterialBuildState): this;
  57044. protected _dumpPropertiesCode(): string;
  57045. serialize(): any;
  57046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Block used to apply a cross product between 2 vectors
  57052. */
  57053. export class CrossBlock extends NodeMaterialBlock {
  57054. /**
  57055. * Creates a new CrossBlock
  57056. * @param name defines the block name
  57057. */
  57058. constructor(name: string);
  57059. /**
  57060. * Gets the current class name
  57061. * @returns the class name
  57062. */
  57063. getClassName(): string;
  57064. /**
  57065. * Gets the left operand input component
  57066. */
  57067. get left(): NodeMaterialConnectionPoint;
  57068. /**
  57069. * Gets the right operand input component
  57070. */
  57071. get right(): NodeMaterialConnectionPoint;
  57072. /**
  57073. * Gets the output component
  57074. */
  57075. get output(): NodeMaterialConnectionPoint;
  57076. protected _buildBlock(state: NodeMaterialBuildState): this;
  57077. }
  57078. }
  57079. declare module BABYLON {
  57080. /**
  57081. * Block used to apply a dot product between 2 vectors
  57082. */
  57083. export class DotBlock extends NodeMaterialBlock {
  57084. /**
  57085. * Creates a new DotBlock
  57086. * @param name defines the block name
  57087. */
  57088. constructor(name: string);
  57089. /**
  57090. * Gets the current class name
  57091. * @returns the class name
  57092. */
  57093. getClassName(): string;
  57094. /**
  57095. * Gets the left operand input component
  57096. */
  57097. get left(): NodeMaterialConnectionPoint;
  57098. /**
  57099. * Gets the right operand input component
  57100. */
  57101. get right(): NodeMaterialConnectionPoint;
  57102. /**
  57103. * Gets the output component
  57104. */
  57105. get output(): NodeMaterialConnectionPoint;
  57106. protected _buildBlock(state: NodeMaterialBuildState): this;
  57107. }
  57108. }
  57109. declare module BABYLON {
  57110. /**
  57111. * Block used to remap a float from a range to a new one
  57112. */
  57113. export class RemapBlock extends NodeMaterialBlock {
  57114. /**
  57115. * Gets or sets the source range
  57116. */
  57117. sourceRange: Vector2;
  57118. /**
  57119. * Gets or sets the target range
  57120. */
  57121. targetRange: Vector2;
  57122. /**
  57123. * Creates a new RemapBlock
  57124. * @param name defines the block name
  57125. */
  57126. constructor(name: string);
  57127. /**
  57128. * Gets the current class name
  57129. * @returns the class name
  57130. */
  57131. getClassName(): string;
  57132. /**
  57133. * Gets the input component
  57134. */
  57135. get input(): NodeMaterialConnectionPoint;
  57136. /**
  57137. * Gets the source min input component
  57138. */
  57139. get sourceMin(): NodeMaterialConnectionPoint;
  57140. /**
  57141. * Gets the source max input component
  57142. */
  57143. get sourceMax(): NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the target min input component
  57146. */
  57147. get targetMin(): NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the target max input component
  57150. */
  57151. get targetMax(): NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the output component
  57154. */
  57155. get output(): NodeMaterialConnectionPoint;
  57156. protected _buildBlock(state: NodeMaterialBuildState): this;
  57157. protected _dumpPropertiesCode(): string;
  57158. serialize(): any;
  57159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57160. }
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * Block used to normalize a vector
  57165. */
  57166. export class NormalizeBlock extends NodeMaterialBlock {
  57167. /**
  57168. * Creates a new NormalizeBlock
  57169. * @param name defines the block name
  57170. */
  57171. constructor(name: string);
  57172. /**
  57173. * Gets the current class name
  57174. * @returns the class name
  57175. */
  57176. getClassName(): string;
  57177. /**
  57178. * Gets the input component
  57179. */
  57180. get input(): NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the output component
  57183. */
  57184. get output(): NodeMaterialConnectionPoint;
  57185. protected _buildBlock(state: NodeMaterialBuildState): this;
  57186. }
  57187. }
  57188. declare module BABYLON {
  57189. /**
  57190. * Operations supported by the Trigonometry block
  57191. */
  57192. export enum TrigonometryBlockOperations {
  57193. /** Cos */
  57194. Cos = 0,
  57195. /** Sin */
  57196. Sin = 1,
  57197. /** Abs */
  57198. Abs = 2,
  57199. /** Exp */
  57200. Exp = 3,
  57201. /** Exp2 */
  57202. Exp2 = 4,
  57203. /** Round */
  57204. Round = 5,
  57205. /** Floor */
  57206. Floor = 6,
  57207. /** Ceiling */
  57208. Ceiling = 7,
  57209. /** Square root */
  57210. Sqrt = 8,
  57211. /** Log */
  57212. Log = 9,
  57213. /** Tangent */
  57214. Tan = 10,
  57215. /** Arc tangent */
  57216. ArcTan = 11,
  57217. /** Arc cosinus */
  57218. ArcCos = 12,
  57219. /** Arc sinus */
  57220. ArcSin = 13,
  57221. /** Fraction */
  57222. Fract = 14,
  57223. /** Sign */
  57224. Sign = 15,
  57225. /** To radians (from degrees) */
  57226. Radians = 16,
  57227. /** To degrees (from radians) */
  57228. Degrees = 17
  57229. }
  57230. /**
  57231. * Block used to apply trigonometry operation to floats
  57232. */
  57233. export class TrigonometryBlock extends NodeMaterialBlock {
  57234. /**
  57235. * Gets or sets the operation applied by the block
  57236. */
  57237. operation: TrigonometryBlockOperations;
  57238. /**
  57239. * Creates a new TrigonometryBlock
  57240. * @param name defines the block name
  57241. */
  57242. constructor(name: string);
  57243. /**
  57244. * Gets the current class name
  57245. * @returns the class name
  57246. */
  57247. getClassName(): string;
  57248. /**
  57249. * Gets the input component
  57250. */
  57251. get input(): NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the output component
  57254. */
  57255. get output(): NodeMaterialConnectionPoint;
  57256. protected _buildBlock(state: NodeMaterialBuildState): this;
  57257. serialize(): any;
  57258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57259. protected _dumpPropertiesCode(): string;
  57260. }
  57261. }
  57262. declare module BABYLON {
  57263. /**
  57264. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57265. */
  57266. export class ColorMergerBlock extends NodeMaterialBlock {
  57267. /**
  57268. * Create a new ColorMergerBlock
  57269. * @param name defines the block name
  57270. */
  57271. constructor(name: string);
  57272. /**
  57273. * Gets the current class name
  57274. * @returns the class name
  57275. */
  57276. getClassName(): string;
  57277. /**
  57278. * Gets the rgb component (input)
  57279. */
  57280. get rgbIn(): NodeMaterialConnectionPoint;
  57281. /**
  57282. * Gets the r component (input)
  57283. */
  57284. get r(): NodeMaterialConnectionPoint;
  57285. /**
  57286. * Gets the g component (input)
  57287. */
  57288. get g(): NodeMaterialConnectionPoint;
  57289. /**
  57290. * Gets the b component (input)
  57291. */
  57292. get b(): NodeMaterialConnectionPoint;
  57293. /**
  57294. * Gets the a component (input)
  57295. */
  57296. get a(): NodeMaterialConnectionPoint;
  57297. /**
  57298. * Gets the rgba component (output)
  57299. */
  57300. get rgba(): NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the rgb component (output)
  57303. */
  57304. get rgbOut(): NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the rgb component (output)
  57307. * @deprecated Please use rgbOut instead.
  57308. */
  57309. get rgb(): NodeMaterialConnectionPoint;
  57310. protected _buildBlock(state: NodeMaterialBuildState): this;
  57311. }
  57312. }
  57313. declare module BABYLON {
  57314. /**
  57315. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57316. */
  57317. export class VectorMergerBlock extends NodeMaterialBlock {
  57318. /**
  57319. * Create a new VectorMergerBlock
  57320. * @param name defines the block name
  57321. */
  57322. constructor(name: string);
  57323. /**
  57324. * Gets the current class name
  57325. * @returns the class name
  57326. */
  57327. getClassName(): string;
  57328. /**
  57329. * Gets the xyz component (input)
  57330. */
  57331. get xyzIn(): NodeMaterialConnectionPoint;
  57332. /**
  57333. * Gets the xy component (input)
  57334. */
  57335. get xyIn(): NodeMaterialConnectionPoint;
  57336. /**
  57337. * Gets the x component (input)
  57338. */
  57339. get x(): NodeMaterialConnectionPoint;
  57340. /**
  57341. * Gets the y component (input)
  57342. */
  57343. get y(): NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the z component (input)
  57346. */
  57347. get z(): NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the w component (input)
  57350. */
  57351. get w(): NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the xyzw component (output)
  57354. */
  57355. get xyzw(): NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the xyz component (output)
  57358. */
  57359. get xyzOut(): NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the xy component (output)
  57362. */
  57363. get xyOut(): NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the xy component (output)
  57366. * @deprecated Please use xyOut instead.
  57367. */
  57368. get xy(): NodeMaterialConnectionPoint;
  57369. /**
  57370. * Gets the xyz component (output)
  57371. * @deprecated Please use xyzOut instead.
  57372. */
  57373. get xyz(): NodeMaterialConnectionPoint;
  57374. protected _buildBlock(state: NodeMaterialBuildState): this;
  57375. }
  57376. }
  57377. declare module BABYLON {
  57378. /**
  57379. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57380. */
  57381. export class ColorSplitterBlock extends NodeMaterialBlock {
  57382. /**
  57383. * Create a new ColorSplitterBlock
  57384. * @param name defines the block name
  57385. */
  57386. constructor(name: string);
  57387. /**
  57388. * Gets the current class name
  57389. * @returns the class name
  57390. */
  57391. getClassName(): string;
  57392. /**
  57393. * Gets the rgba component (input)
  57394. */
  57395. get rgba(): NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the rgb component (input)
  57398. */
  57399. get rgbIn(): NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the rgb component (output)
  57402. */
  57403. get rgbOut(): NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the r component (output)
  57406. */
  57407. get r(): NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the g component (output)
  57410. */
  57411. get g(): NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the b component (output)
  57414. */
  57415. get b(): NodeMaterialConnectionPoint;
  57416. /**
  57417. * Gets the a component (output)
  57418. */
  57419. get a(): NodeMaterialConnectionPoint;
  57420. protected _inputRename(name: string): string;
  57421. protected _outputRename(name: string): string;
  57422. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57423. }
  57424. }
  57425. declare module BABYLON {
  57426. /**
  57427. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57428. */
  57429. export class VectorSplitterBlock extends NodeMaterialBlock {
  57430. /**
  57431. * Create a new VectorSplitterBlock
  57432. * @param name defines the block name
  57433. */
  57434. constructor(name: string);
  57435. /**
  57436. * Gets the current class name
  57437. * @returns the class name
  57438. */
  57439. getClassName(): string;
  57440. /**
  57441. * Gets the xyzw component (input)
  57442. */
  57443. get xyzw(): NodeMaterialConnectionPoint;
  57444. /**
  57445. * Gets the xyz component (input)
  57446. */
  57447. get xyzIn(): NodeMaterialConnectionPoint;
  57448. /**
  57449. * Gets the xy component (input)
  57450. */
  57451. get xyIn(): NodeMaterialConnectionPoint;
  57452. /**
  57453. * Gets the xyz component (output)
  57454. */
  57455. get xyzOut(): NodeMaterialConnectionPoint;
  57456. /**
  57457. * Gets the xy component (output)
  57458. */
  57459. get xyOut(): NodeMaterialConnectionPoint;
  57460. /**
  57461. * Gets the x component (output)
  57462. */
  57463. get x(): NodeMaterialConnectionPoint;
  57464. /**
  57465. * Gets the y component (output)
  57466. */
  57467. get y(): NodeMaterialConnectionPoint;
  57468. /**
  57469. * Gets the z component (output)
  57470. */
  57471. get z(): NodeMaterialConnectionPoint;
  57472. /**
  57473. * Gets the w component (output)
  57474. */
  57475. get w(): NodeMaterialConnectionPoint;
  57476. protected _inputRename(name: string): string;
  57477. protected _outputRename(name: string): string;
  57478. protected _buildBlock(state: NodeMaterialBuildState): this;
  57479. }
  57480. }
  57481. declare module BABYLON {
  57482. /**
  57483. * Block used to lerp between 2 values
  57484. */
  57485. export class LerpBlock extends NodeMaterialBlock {
  57486. /**
  57487. * Creates a new LerpBlock
  57488. * @param name defines the block name
  57489. */
  57490. constructor(name: string);
  57491. /**
  57492. * Gets the current class name
  57493. * @returns the class name
  57494. */
  57495. getClassName(): string;
  57496. /**
  57497. * Gets the left operand input component
  57498. */
  57499. get left(): NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the right operand input component
  57502. */
  57503. get right(): NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the gradient operand input component
  57506. */
  57507. get gradient(): NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the output component
  57510. */
  57511. get output(): NodeMaterialConnectionPoint;
  57512. protected _buildBlock(state: NodeMaterialBuildState): this;
  57513. }
  57514. }
  57515. declare module BABYLON {
  57516. /**
  57517. * Block used to divide 2 vectors
  57518. */
  57519. export class DivideBlock extends NodeMaterialBlock {
  57520. /**
  57521. * Creates a new DivideBlock
  57522. * @param name defines the block name
  57523. */
  57524. constructor(name: string);
  57525. /**
  57526. * Gets the current class name
  57527. * @returns the class name
  57528. */
  57529. getClassName(): string;
  57530. /**
  57531. * Gets the left operand input component
  57532. */
  57533. get left(): NodeMaterialConnectionPoint;
  57534. /**
  57535. * Gets the right operand input component
  57536. */
  57537. get right(): NodeMaterialConnectionPoint;
  57538. /**
  57539. * Gets the output component
  57540. */
  57541. get output(): NodeMaterialConnectionPoint;
  57542. protected _buildBlock(state: NodeMaterialBuildState): this;
  57543. }
  57544. }
  57545. declare module BABYLON {
  57546. /**
  57547. * Block used to subtract 2 vectors
  57548. */
  57549. export class SubtractBlock extends NodeMaterialBlock {
  57550. /**
  57551. * Creates a new SubtractBlock
  57552. * @param name defines the block name
  57553. */
  57554. constructor(name: string);
  57555. /**
  57556. * Gets the current class name
  57557. * @returns the class name
  57558. */
  57559. getClassName(): string;
  57560. /**
  57561. * Gets the left operand input component
  57562. */
  57563. get left(): NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the right operand input component
  57566. */
  57567. get right(): NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the output component
  57570. */
  57571. get output(): NodeMaterialConnectionPoint;
  57572. protected _buildBlock(state: NodeMaterialBuildState): this;
  57573. }
  57574. }
  57575. declare module BABYLON {
  57576. /**
  57577. * Block used to step a value
  57578. */
  57579. export class StepBlock extends NodeMaterialBlock {
  57580. /**
  57581. * Creates a new StepBlock
  57582. * @param name defines the block name
  57583. */
  57584. constructor(name: string);
  57585. /**
  57586. * Gets the current class name
  57587. * @returns the class name
  57588. */
  57589. getClassName(): string;
  57590. /**
  57591. * Gets the value operand input component
  57592. */
  57593. get value(): NodeMaterialConnectionPoint;
  57594. /**
  57595. * Gets the edge operand input component
  57596. */
  57597. get edge(): NodeMaterialConnectionPoint;
  57598. /**
  57599. * Gets the output component
  57600. */
  57601. get output(): NodeMaterialConnectionPoint;
  57602. protected _buildBlock(state: NodeMaterialBuildState): this;
  57603. }
  57604. }
  57605. declare module BABYLON {
  57606. /**
  57607. * Block used to get the opposite (1 - x) of a value
  57608. */
  57609. export class OneMinusBlock extends NodeMaterialBlock {
  57610. /**
  57611. * Creates a new OneMinusBlock
  57612. * @param name defines the block name
  57613. */
  57614. constructor(name: string);
  57615. /**
  57616. * Gets the current class name
  57617. * @returns the class name
  57618. */
  57619. getClassName(): string;
  57620. /**
  57621. * Gets the input component
  57622. */
  57623. get input(): NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the output component
  57626. */
  57627. get output(): NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. }
  57630. }
  57631. declare module BABYLON {
  57632. /**
  57633. * Block used to get the view direction
  57634. */
  57635. export class ViewDirectionBlock extends NodeMaterialBlock {
  57636. /**
  57637. * Creates a new ViewDirectionBlock
  57638. * @param name defines the block name
  57639. */
  57640. constructor(name: string);
  57641. /**
  57642. * Gets the current class name
  57643. * @returns the class name
  57644. */
  57645. getClassName(): string;
  57646. /**
  57647. * Gets the world position component
  57648. */
  57649. get worldPosition(): NodeMaterialConnectionPoint;
  57650. /**
  57651. * Gets the camera position component
  57652. */
  57653. get cameraPosition(): NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the output component
  57656. */
  57657. get output(): NodeMaterialConnectionPoint;
  57658. autoConfigure(material: NodeMaterial): void;
  57659. protected _buildBlock(state: NodeMaterialBuildState): this;
  57660. }
  57661. }
  57662. declare module BABYLON {
  57663. /**
  57664. * Block used to compute fresnel value
  57665. */
  57666. export class FresnelBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Create a new FresnelBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the world normal input component
  57679. */
  57680. get worldNormal(): NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the view direction input component
  57683. */
  57684. get viewDirection(): NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the bias input component
  57687. */
  57688. get bias(): NodeMaterialConnectionPoint;
  57689. /**
  57690. * Gets the camera (or eye) position component
  57691. */
  57692. get power(): NodeMaterialConnectionPoint;
  57693. /**
  57694. * Gets the fresnel output component
  57695. */
  57696. get fresnel(): NodeMaterialConnectionPoint;
  57697. autoConfigure(material: NodeMaterial): void;
  57698. protected _buildBlock(state: NodeMaterialBuildState): this;
  57699. }
  57700. }
  57701. declare module BABYLON {
  57702. /**
  57703. * Block used to get the max of 2 values
  57704. */
  57705. export class MaxBlock extends NodeMaterialBlock {
  57706. /**
  57707. * Creates a new MaxBlock
  57708. * @param name defines the block name
  57709. */
  57710. constructor(name: string);
  57711. /**
  57712. * Gets the current class name
  57713. * @returns the class name
  57714. */
  57715. getClassName(): string;
  57716. /**
  57717. * Gets the left operand input component
  57718. */
  57719. get left(): NodeMaterialConnectionPoint;
  57720. /**
  57721. * Gets the right operand input component
  57722. */
  57723. get right(): NodeMaterialConnectionPoint;
  57724. /**
  57725. * Gets the output component
  57726. */
  57727. get output(): NodeMaterialConnectionPoint;
  57728. protected _buildBlock(state: NodeMaterialBuildState): this;
  57729. }
  57730. }
  57731. declare module BABYLON {
  57732. /**
  57733. * Block used to get the min of 2 values
  57734. */
  57735. export class MinBlock extends NodeMaterialBlock {
  57736. /**
  57737. * Creates a new MinBlock
  57738. * @param name defines the block name
  57739. */
  57740. constructor(name: string);
  57741. /**
  57742. * Gets the current class name
  57743. * @returns the class name
  57744. */
  57745. getClassName(): string;
  57746. /**
  57747. * Gets the left operand input component
  57748. */
  57749. get left(): NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the right operand input component
  57752. */
  57753. get right(): NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the output component
  57756. */
  57757. get output(): NodeMaterialConnectionPoint;
  57758. protected _buildBlock(state: NodeMaterialBuildState): this;
  57759. }
  57760. }
  57761. declare module BABYLON {
  57762. /**
  57763. * Block used to get the distance between 2 values
  57764. */
  57765. export class DistanceBlock extends NodeMaterialBlock {
  57766. /**
  57767. * Creates a new DistanceBlock
  57768. * @param name defines the block name
  57769. */
  57770. constructor(name: string);
  57771. /**
  57772. * Gets the current class name
  57773. * @returns the class name
  57774. */
  57775. getClassName(): string;
  57776. /**
  57777. * Gets the left operand input component
  57778. */
  57779. get left(): NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the right operand input component
  57782. */
  57783. get right(): NodeMaterialConnectionPoint;
  57784. /**
  57785. * Gets the output component
  57786. */
  57787. get output(): NodeMaterialConnectionPoint;
  57788. protected _buildBlock(state: NodeMaterialBuildState): this;
  57789. }
  57790. }
  57791. declare module BABYLON {
  57792. /**
  57793. * Block used to get the length of a vector
  57794. */
  57795. export class LengthBlock extends NodeMaterialBlock {
  57796. /**
  57797. * Creates a new LengthBlock
  57798. * @param name defines the block name
  57799. */
  57800. constructor(name: string);
  57801. /**
  57802. * Gets the current class name
  57803. * @returns the class name
  57804. */
  57805. getClassName(): string;
  57806. /**
  57807. * Gets the value input component
  57808. */
  57809. get value(): NodeMaterialConnectionPoint;
  57810. /**
  57811. * Gets the output component
  57812. */
  57813. get output(): NodeMaterialConnectionPoint;
  57814. protected _buildBlock(state: NodeMaterialBuildState): this;
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * Block used to get negative version of a value (i.e. x * -1)
  57820. */
  57821. export class NegateBlock extends NodeMaterialBlock {
  57822. /**
  57823. * Creates a new NegateBlock
  57824. * @param name defines the block name
  57825. */
  57826. constructor(name: string);
  57827. /**
  57828. * Gets the current class name
  57829. * @returns the class name
  57830. */
  57831. getClassName(): string;
  57832. /**
  57833. * Gets the value input component
  57834. */
  57835. get value(): NodeMaterialConnectionPoint;
  57836. /**
  57837. * Gets the output component
  57838. */
  57839. get output(): NodeMaterialConnectionPoint;
  57840. protected _buildBlock(state: NodeMaterialBuildState): this;
  57841. }
  57842. }
  57843. declare module BABYLON {
  57844. /**
  57845. * Block used to get the value of the first parameter raised to the power of the second
  57846. */
  57847. export class PowBlock extends NodeMaterialBlock {
  57848. /**
  57849. * Creates a new PowBlock
  57850. * @param name defines the block name
  57851. */
  57852. constructor(name: string);
  57853. /**
  57854. * Gets the current class name
  57855. * @returns the class name
  57856. */
  57857. getClassName(): string;
  57858. /**
  57859. * Gets the value operand input component
  57860. */
  57861. get value(): NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the power operand input component
  57864. */
  57865. get power(): NodeMaterialConnectionPoint;
  57866. /**
  57867. * Gets the output component
  57868. */
  57869. get output(): NodeMaterialConnectionPoint;
  57870. protected _buildBlock(state: NodeMaterialBuildState): this;
  57871. }
  57872. }
  57873. declare module BABYLON {
  57874. /**
  57875. * Block used to get a random number
  57876. */
  57877. export class RandomNumberBlock extends NodeMaterialBlock {
  57878. /**
  57879. * Creates a new RandomNumberBlock
  57880. * @param name defines the block name
  57881. */
  57882. constructor(name: string);
  57883. /**
  57884. * Gets the current class name
  57885. * @returns the class name
  57886. */
  57887. getClassName(): string;
  57888. /**
  57889. * Gets the seed input component
  57890. */
  57891. get seed(): NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the output component
  57894. */
  57895. get output(): NodeMaterialConnectionPoint;
  57896. protected _buildBlock(state: NodeMaterialBuildState): this;
  57897. }
  57898. }
  57899. declare module BABYLON {
  57900. /**
  57901. * Block used to compute arc tangent of 2 values
  57902. */
  57903. export class ArcTan2Block extends NodeMaterialBlock {
  57904. /**
  57905. * Creates a new ArcTan2Block
  57906. * @param name defines the block name
  57907. */
  57908. constructor(name: string);
  57909. /**
  57910. * Gets the current class name
  57911. * @returns the class name
  57912. */
  57913. getClassName(): string;
  57914. /**
  57915. * Gets the x operand input component
  57916. */
  57917. get x(): NodeMaterialConnectionPoint;
  57918. /**
  57919. * Gets the y operand input component
  57920. */
  57921. get y(): NodeMaterialConnectionPoint;
  57922. /**
  57923. * Gets the output component
  57924. */
  57925. get output(): NodeMaterialConnectionPoint;
  57926. protected _buildBlock(state: NodeMaterialBuildState): this;
  57927. }
  57928. }
  57929. declare module BABYLON {
  57930. /**
  57931. * Block used to smooth step a value
  57932. */
  57933. export class SmoothStepBlock extends NodeMaterialBlock {
  57934. /**
  57935. * Creates a new SmoothStepBlock
  57936. * @param name defines the block name
  57937. */
  57938. constructor(name: string);
  57939. /**
  57940. * Gets the current class name
  57941. * @returns the class name
  57942. */
  57943. getClassName(): string;
  57944. /**
  57945. * Gets the value operand input component
  57946. */
  57947. get value(): NodeMaterialConnectionPoint;
  57948. /**
  57949. * Gets the first edge operand input component
  57950. */
  57951. get edge0(): NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the second edge operand input component
  57954. */
  57955. get edge1(): NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the output component
  57958. */
  57959. get output(): NodeMaterialConnectionPoint;
  57960. protected _buildBlock(state: NodeMaterialBuildState): this;
  57961. }
  57962. }
  57963. declare module BABYLON {
  57964. /**
  57965. * Block used to get the reciprocal (1 / x) of a value
  57966. */
  57967. export class ReciprocalBlock extends NodeMaterialBlock {
  57968. /**
  57969. * Creates a new ReciprocalBlock
  57970. * @param name defines the block name
  57971. */
  57972. constructor(name: string);
  57973. /**
  57974. * Gets the current class name
  57975. * @returns the class name
  57976. */
  57977. getClassName(): string;
  57978. /**
  57979. * Gets the input component
  57980. */
  57981. get input(): NodeMaterialConnectionPoint;
  57982. /**
  57983. * Gets the output component
  57984. */
  57985. get output(): NodeMaterialConnectionPoint;
  57986. protected _buildBlock(state: NodeMaterialBuildState): this;
  57987. }
  57988. }
  57989. declare module BABYLON {
  57990. /**
  57991. * Block used to replace a color by another one
  57992. */
  57993. export class ReplaceColorBlock extends NodeMaterialBlock {
  57994. /**
  57995. * Creates a new ReplaceColorBlock
  57996. * @param name defines the block name
  57997. */
  57998. constructor(name: string);
  57999. /**
  58000. * Gets the current class name
  58001. * @returns the class name
  58002. */
  58003. getClassName(): string;
  58004. /**
  58005. * Gets the value input component
  58006. */
  58007. get value(): NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the reference input component
  58010. */
  58011. get reference(): NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the distance input component
  58014. */
  58015. get distance(): NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the replacement input component
  58018. */
  58019. get replacement(): NodeMaterialConnectionPoint;
  58020. /**
  58021. * Gets the output component
  58022. */
  58023. get output(): NodeMaterialConnectionPoint;
  58024. protected _buildBlock(state: NodeMaterialBuildState): this;
  58025. }
  58026. }
  58027. declare module BABYLON {
  58028. /**
  58029. * Block used to posterize a value
  58030. * @see https://en.wikipedia.org/wiki/Posterization
  58031. */
  58032. export class PosterizeBlock extends NodeMaterialBlock {
  58033. /**
  58034. * Creates a new PosterizeBlock
  58035. * @param name defines the block name
  58036. */
  58037. constructor(name: string);
  58038. /**
  58039. * Gets the current class name
  58040. * @returns the class name
  58041. */
  58042. getClassName(): string;
  58043. /**
  58044. * Gets the value input component
  58045. */
  58046. get value(): NodeMaterialConnectionPoint;
  58047. /**
  58048. * Gets the steps input component
  58049. */
  58050. get steps(): NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the output component
  58053. */
  58054. get output(): NodeMaterialConnectionPoint;
  58055. protected _buildBlock(state: NodeMaterialBuildState): this;
  58056. }
  58057. }
  58058. declare module BABYLON {
  58059. /**
  58060. * Operations supported by the Wave block
  58061. */
  58062. export enum WaveBlockKind {
  58063. /** SawTooth */
  58064. SawTooth = 0,
  58065. /** Square */
  58066. Square = 1,
  58067. /** Triangle */
  58068. Triangle = 2
  58069. }
  58070. /**
  58071. * Block used to apply wave operation to floats
  58072. */
  58073. export class WaveBlock extends NodeMaterialBlock {
  58074. /**
  58075. * Gets or sets the kibnd of wave to be applied by the block
  58076. */
  58077. kind: WaveBlockKind;
  58078. /**
  58079. * Creates a new WaveBlock
  58080. * @param name defines the block name
  58081. */
  58082. constructor(name: string);
  58083. /**
  58084. * Gets the current class name
  58085. * @returns the class name
  58086. */
  58087. getClassName(): string;
  58088. /**
  58089. * Gets the input component
  58090. */
  58091. get input(): NodeMaterialConnectionPoint;
  58092. /**
  58093. * Gets the output component
  58094. */
  58095. get output(): NodeMaterialConnectionPoint;
  58096. protected _buildBlock(state: NodeMaterialBuildState): this;
  58097. serialize(): any;
  58098. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58099. }
  58100. }
  58101. declare module BABYLON {
  58102. /**
  58103. * Class used to store a color step for the GradientBlock
  58104. */
  58105. export class GradientBlockColorStep {
  58106. /**
  58107. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58108. */
  58109. step: number;
  58110. /**
  58111. * Gets or sets the color associated with this step
  58112. */
  58113. color: Color3;
  58114. /**
  58115. * Creates a new GradientBlockColorStep
  58116. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58117. * @param color defines the color associated with this step
  58118. */
  58119. constructor(
  58120. /**
  58121. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58122. */
  58123. step: number,
  58124. /**
  58125. * Gets or sets the color associated with this step
  58126. */
  58127. color: Color3);
  58128. }
  58129. /**
  58130. * Block used to return a color from a gradient based on an input value between 0 and 1
  58131. */
  58132. export class GradientBlock extends NodeMaterialBlock {
  58133. /**
  58134. * Gets or sets the list of color steps
  58135. */
  58136. colorSteps: GradientBlockColorStep[];
  58137. /**
  58138. * Creates a new GradientBlock
  58139. * @param name defines the block name
  58140. */
  58141. constructor(name: string);
  58142. /**
  58143. * Gets the current class name
  58144. * @returns the class name
  58145. */
  58146. getClassName(): string;
  58147. /**
  58148. * Gets the gradient input component
  58149. */
  58150. get gradient(): NodeMaterialConnectionPoint;
  58151. /**
  58152. * Gets the output component
  58153. */
  58154. get output(): NodeMaterialConnectionPoint;
  58155. private _writeColorConstant;
  58156. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58157. serialize(): any;
  58158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58159. protected _dumpPropertiesCode(): string;
  58160. }
  58161. }
  58162. declare module BABYLON {
  58163. /**
  58164. * Block used to normalize lerp between 2 values
  58165. */
  58166. export class NLerpBlock extends NodeMaterialBlock {
  58167. /**
  58168. * Creates a new NLerpBlock
  58169. * @param name defines the block name
  58170. */
  58171. constructor(name: string);
  58172. /**
  58173. * Gets the current class name
  58174. * @returns the class name
  58175. */
  58176. getClassName(): string;
  58177. /**
  58178. * Gets the left operand input component
  58179. */
  58180. get left(): NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the right operand input component
  58183. */
  58184. get right(): NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the gradient operand input component
  58187. */
  58188. get gradient(): NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the output component
  58191. */
  58192. get output(): NodeMaterialConnectionPoint;
  58193. protected _buildBlock(state: NodeMaterialBuildState): this;
  58194. }
  58195. }
  58196. declare module BABYLON {
  58197. /**
  58198. * block used to Generate a Worley Noise 3D Noise Pattern
  58199. */
  58200. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58201. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58202. manhattanDistance: boolean;
  58203. /**
  58204. * Creates a new WorleyNoise3DBlock
  58205. * @param name defines the block name
  58206. */
  58207. constructor(name: string);
  58208. /**
  58209. * Gets the current class name
  58210. * @returns the class name
  58211. */
  58212. getClassName(): string;
  58213. /**
  58214. * Gets the seed input component
  58215. */
  58216. get seed(): NodeMaterialConnectionPoint;
  58217. /**
  58218. * Gets the jitter input component
  58219. */
  58220. get jitter(): NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the output component
  58223. */
  58224. get output(): NodeMaterialConnectionPoint;
  58225. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58226. /**
  58227. * Exposes the properties to the UI?
  58228. */
  58229. protected _dumpPropertiesCode(): string;
  58230. /**
  58231. * Exposes the properties to the Seralize?
  58232. */
  58233. serialize(): any;
  58234. /**
  58235. * Exposes the properties to the deseralize?
  58236. */
  58237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /**
  58242. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58243. */
  58244. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58245. /**
  58246. * Creates a new SimplexPerlin3DBlock
  58247. * @param name defines the block name
  58248. */
  58249. constructor(name: string);
  58250. /**
  58251. * Gets the current class name
  58252. * @returns the class name
  58253. */
  58254. getClassName(): string;
  58255. /**
  58256. * Gets the seed operand input component
  58257. */
  58258. get seed(): NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the output component
  58261. */
  58262. get output(): NodeMaterialConnectionPoint;
  58263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58264. }
  58265. }
  58266. declare module BABYLON {
  58267. /**
  58268. * Block used to blend normals
  58269. */
  58270. export class NormalBlendBlock extends NodeMaterialBlock {
  58271. /**
  58272. * Creates a new NormalBlendBlock
  58273. * @param name defines the block name
  58274. */
  58275. constructor(name: string);
  58276. /**
  58277. * Gets the current class name
  58278. * @returns the class name
  58279. */
  58280. getClassName(): string;
  58281. /**
  58282. * Gets the first input component
  58283. */
  58284. get normalMap0(): NodeMaterialConnectionPoint;
  58285. /**
  58286. * Gets the second input component
  58287. */
  58288. get normalMap1(): NodeMaterialConnectionPoint;
  58289. /**
  58290. * Gets the output component
  58291. */
  58292. get output(): NodeMaterialConnectionPoint;
  58293. protected _buildBlock(state: NodeMaterialBuildState): this;
  58294. }
  58295. }
  58296. declare module BABYLON {
  58297. /**
  58298. * Block used to rotate a 2d vector by a given angle
  58299. */
  58300. export class Rotate2dBlock extends NodeMaterialBlock {
  58301. /**
  58302. * Creates a new Rotate2dBlock
  58303. * @param name defines the block name
  58304. */
  58305. constructor(name: string);
  58306. /**
  58307. * Gets the current class name
  58308. * @returns the class name
  58309. */
  58310. getClassName(): string;
  58311. /**
  58312. * Gets the input vector
  58313. */
  58314. get input(): NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the input angle
  58317. */
  58318. get angle(): NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the output component
  58321. */
  58322. get output(): NodeMaterialConnectionPoint;
  58323. autoConfigure(material: NodeMaterial): void;
  58324. protected _buildBlock(state: NodeMaterialBuildState): this;
  58325. }
  58326. }
  58327. declare module BABYLON {
  58328. /**
  58329. * Block used to get the reflected vector from a direction and a normal
  58330. */
  58331. export class ReflectBlock extends NodeMaterialBlock {
  58332. /**
  58333. * Creates a new ReflectBlock
  58334. * @param name defines the block name
  58335. */
  58336. constructor(name: string);
  58337. /**
  58338. * Gets the current class name
  58339. * @returns the class name
  58340. */
  58341. getClassName(): string;
  58342. /**
  58343. * Gets the incident component
  58344. */
  58345. get incident(): NodeMaterialConnectionPoint;
  58346. /**
  58347. * Gets the normal component
  58348. */
  58349. get normal(): NodeMaterialConnectionPoint;
  58350. /**
  58351. * Gets the output component
  58352. */
  58353. get output(): NodeMaterialConnectionPoint;
  58354. protected _buildBlock(state: NodeMaterialBuildState): this;
  58355. }
  58356. }
  58357. declare module BABYLON {
  58358. /**
  58359. * Block used to get the refracted vector from a direction and a normal
  58360. */
  58361. export class RefractBlock extends NodeMaterialBlock {
  58362. /**
  58363. * Creates a new RefractBlock
  58364. * @param name defines the block name
  58365. */
  58366. constructor(name: string);
  58367. /**
  58368. * Gets the current class name
  58369. * @returns the class name
  58370. */
  58371. getClassName(): string;
  58372. /**
  58373. * Gets the incident component
  58374. */
  58375. get incident(): NodeMaterialConnectionPoint;
  58376. /**
  58377. * Gets the normal component
  58378. */
  58379. get normal(): NodeMaterialConnectionPoint;
  58380. /**
  58381. * Gets the index of refraction component
  58382. */
  58383. get ior(): NodeMaterialConnectionPoint;
  58384. /**
  58385. * Gets the output component
  58386. */
  58387. get output(): NodeMaterialConnectionPoint;
  58388. protected _buildBlock(state: NodeMaterialBuildState): this;
  58389. }
  58390. }
  58391. declare module BABYLON {
  58392. /**
  58393. * Block used to desaturate a color
  58394. */
  58395. export class DesaturateBlock extends NodeMaterialBlock {
  58396. /**
  58397. * Creates a new DesaturateBlock
  58398. * @param name defines the block name
  58399. */
  58400. constructor(name: string);
  58401. /**
  58402. * Gets the current class name
  58403. * @returns the class name
  58404. */
  58405. getClassName(): string;
  58406. /**
  58407. * Gets the color operand input component
  58408. */
  58409. get color(): NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the level operand input component
  58412. */
  58413. get level(): NodeMaterialConnectionPoint;
  58414. /**
  58415. * Gets the output component
  58416. */
  58417. get output(): NodeMaterialConnectionPoint;
  58418. protected _buildBlock(state: NodeMaterialBuildState): this;
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. /**
  58423. * Effect Render Options
  58424. */
  58425. export interface IEffectRendererOptions {
  58426. /**
  58427. * Defines the vertices positions.
  58428. */
  58429. positions?: number[];
  58430. /**
  58431. * Defines the indices.
  58432. */
  58433. indices?: number[];
  58434. }
  58435. /**
  58436. * Helper class to render one or more effects
  58437. */
  58438. export class EffectRenderer {
  58439. private engine;
  58440. private static _DefaultOptions;
  58441. private _vertexBuffers;
  58442. private _indexBuffer;
  58443. private _ringBufferIndex;
  58444. private _ringScreenBuffer;
  58445. private _fullscreenViewport;
  58446. private _getNextFrameBuffer;
  58447. /**
  58448. * Creates an effect renderer
  58449. * @param engine the engine to use for rendering
  58450. * @param options defines the options of the effect renderer
  58451. */
  58452. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58453. /**
  58454. * Sets the current viewport in normalized coordinates 0-1
  58455. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58456. */
  58457. setViewport(viewport?: Viewport): void;
  58458. /**
  58459. * Binds the embedded attributes buffer to the effect.
  58460. * @param effect Defines the effect to bind the attributes for
  58461. */
  58462. bindBuffers(effect: Effect): void;
  58463. /**
  58464. * Sets the current effect wrapper to use during draw.
  58465. * The effect needs to be ready before calling this api.
  58466. * This also sets the default full screen position attribute.
  58467. * @param effectWrapper Defines the effect to draw with
  58468. */
  58469. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58470. /**
  58471. * Draws a full screen quad.
  58472. */
  58473. draw(): void;
  58474. /**
  58475. * renders one or more effects to a specified texture
  58476. * @param effectWrappers list of effects to renderer
  58477. * @param outputTexture texture to draw to, if null it will render to the screen
  58478. */
  58479. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58480. /**
  58481. * Disposes of the effect renderer
  58482. */
  58483. dispose(): void;
  58484. }
  58485. /**
  58486. * Options to create an EffectWrapper
  58487. */
  58488. interface EffectWrapperCreationOptions {
  58489. /**
  58490. * Engine to use to create the effect
  58491. */
  58492. engine: ThinEngine;
  58493. /**
  58494. * Fragment shader for the effect
  58495. */
  58496. fragmentShader: string;
  58497. /**
  58498. * Vertex shader for the effect
  58499. */
  58500. vertexShader?: string;
  58501. /**
  58502. * Attributes to use in the shader
  58503. */
  58504. attributeNames?: Array<string>;
  58505. /**
  58506. * Uniforms to use in the shader
  58507. */
  58508. uniformNames?: Array<string>;
  58509. /**
  58510. * Texture sampler names to use in the shader
  58511. */
  58512. samplerNames?: Array<string>;
  58513. /**
  58514. * The friendly name of the effect displayed in Spector.
  58515. */
  58516. name?: string;
  58517. }
  58518. /**
  58519. * Wraps an effect to be used for rendering
  58520. */
  58521. export class EffectWrapper {
  58522. /**
  58523. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58524. */
  58525. onApplyObservable: Observable<{}>;
  58526. /**
  58527. * The underlying effect
  58528. */
  58529. effect: Effect;
  58530. /**
  58531. * Creates an effect to be renderer
  58532. * @param creationOptions options to create the effect
  58533. */
  58534. constructor(creationOptions: EffectWrapperCreationOptions);
  58535. /**
  58536. * Disposes of the effect wrapper
  58537. */
  58538. dispose(): void;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /**
  58543. * Helper class to push actions to a pool of workers.
  58544. */
  58545. export class WorkerPool implements IDisposable {
  58546. private _workerInfos;
  58547. private _pendingActions;
  58548. /**
  58549. * Constructor
  58550. * @param workers Array of workers to use for actions
  58551. */
  58552. constructor(workers: Array<Worker>);
  58553. /**
  58554. * Terminates all workers and clears any pending actions.
  58555. */
  58556. dispose(): void;
  58557. /**
  58558. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58559. * pended until a worker has completed its action.
  58560. * @param action The action to perform. Call onComplete when the action is complete.
  58561. */
  58562. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58563. private _execute;
  58564. }
  58565. }
  58566. declare module BABYLON {
  58567. /**
  58568. * Configuration for Draco compression
  58569. */
  58570. export interface IDracoCompressionConfiguration {
  58571. /**
  58572. * Configuration for the decoder.
  58573. */
  58574. decoder: {
  58575. /**
  58576. * The url to the WebAssembly module.
  58577. */
  58578. wasmUrl?: string;
  58579. /**
  58580. * The url to the WebAssembly binary.
  58581. */
  58582. wasmBinaryUrl?: string;
  58583. /**
  58584. * The url to the fallback JavaScript module.
  58585. */
  58586. fallbackUrl?: string;
  58587. };
  58588. }
  58589. /**
  58590. * Draco compression (https://google.github.io/draco/)
  58591. *
  58592. * This class wraps the Draco module.
  58593. *
  58594. * **Encoder**
  58595. *
  58596. * The encoder is not currently implemented.
  58597. *
  58598. * **Decoder**
  58599. *
  58600. * 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.
  58601. *
  58602. * To update the configuration, use the following code:
  58603. * ```javascript
  58604. * DracoCompression.Configuration = {
  58605. * decoder: {
  58606. * wasmUrl: "<url to the WebAssembly library>",
  58607. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58608. * fallbackUrl: "<url to the fallback JavaScript library>",
  58609. * }
  58610. * };
  58611. * ```
  58612. *
  58613. * 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.
  58614. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58615. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58616. *
  58617. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58618. * ```javascript
  58619. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58620. * ```
  58621. *
  58622. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58623. */
  58624. export class DracoCompression implements IDisposable {
  58625. private _workerPoolPromise?;
  58626. private _decoderModulePromise?;
  58627. /**
  58628. * The configuration. Defaults to the following urls:
  58629. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58630. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58631. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58632. */
  58633. static Configuration: IDracoCompressionConfiguration;
  58634. /**
  58635. * Returns true if the decoder configuration is available.
  58636. */
  58637. static get DecoderAvailable(): boolean;
  58638. /**
  58639. * Default number of workers to create when creating the draco compression object.
  58640. */
  58641. static DefaultNumWorkers: number;
  58642. private static GetDefaultNumWorkers;
  58643. private static _Default;
  58644. /**
  58645. * Default instance for the draco compression object.
  58646. */
  58647. static get Default(): DracoCompression;
  58648. /**
  58649. * Constructor
  58650. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58651. */
  58652. constructor(numWorkers?: number);
  58653. /**
  58654. * Stop all async operations and release resources.
  58655. */
  58656. dispose(): void;
  58657. /**
  58658. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58659. * @returns a promise that resolves when ready
  58660. */
  58661. whenReadyAsync(): Promise<void>;
  58662. /**
  58663. * Decode Draco compressed mesh data to vertex data.
  58664. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58665. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58666. * @returns A promise that resolves with the decoded vertex data
  58667. */
  58668. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58669. [kind: string]: number;
  58670. }): Promise<VertexData>;
  58671. }
  58672. }
  58673. declare module BABYLON {
  58674. /**
  58675. * Class for building Constructive Solid Geometry
  58676. */
  58677. export class CSG {
  58678. private polygons;
  58679. /**
  58680. * The world matrix
  58681. */
  58682. matrix: Matrix;
  58683. /**
  58684. * Stores the position
  58685. */
  58686. position: Vector3;
  58687. /**
  58688. * Stores the rotation
  58689. */
  58690. rotation: Vector3;
  58691. /**
  58692. * Stores the rotation quaternion
  58693. */
  58694. rotationQuaternion: Nullable<Quaternion>;
  58695. /**
  58696. * Stores the scaling vector
  58697. */
  58698. scaling: Vector3;
  58699. /**
  58700. * Convert the Mesh to CSG
  58701. * @param mesh The Mesh to convert to CSG
  58702. * @returns A new CSG from the Mesh
  58703. */
  58704. static FromMesh(mesh: Mesh): CSG;
  58705. /**
  58706. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58707. * @param polygons Polygons used to construct a CSG solid
  58708. */
  58709. private static FromPolygons;
  58710. /**
  58711. * Clones, or makes a deep copy, of the CSG
  58712. * @returns A new CSG
  58713. */
  58714. clone(): CSG;
  58715. /**
  58716. * Unions this CSG with another CSG
  58717. * @param csg The CSG to union against this CSG
  58718. * @returns The unioned CSG
  58719. */
  58720. union(csg: CSG): CSG;
  58721. /**
  58722. * Unions this CSG with another CSG in place
  58723. * @param csg The CSG to union against this CSG
  58724. */
  58725. unionInPlace(csg: CSG): void;
  58726. /**
  58727. * Subtracts this CSG with another CSG
  58728. * @param csg The CSG to subtract against this CSG
  58729. * @returns A new CSG
  58730. */
  58731. subtract(csg: CSG): CSG;
  58732. /**
  58733. * Subtracts this CSG with another CSG in place
  58734. * @param csg The CSG to subtact against this CSG
  58735. */
  58736. subtractInPlace(csg: CSG): void;
  58737. /**
  58738. * Intersect this CSG with another CSG
  58739. * @param csg The CSG to intersect against this CSG
  58740. * @returns A new CSG
  58741. */
  58742. intersect(csg: CSG): CSG;
  58743. /**
  58744. * Intersects this CSG with another CSG in place
  58745. * @param csg The CSG to intersect against this CSG
  58746. */
  58747. intersectInPlace(csg: CSG): void;
  58748. /**
  58749. * Return a new CSG solid with solid and empty space switched. This solid is
  58750. * not modified.
  58751. * @returns A new CSG solid with solid and empty space switched
  58752. */
  58753. inverse(): CSG;
  58754. /**
  58755. * Inverses the CSG in place
  58756. */
  58757. inverseInPlace(): void;
  58758. /**
  58759. * This is used to keep meshes transformations so they can be restored
  58760. * when we build back a Babylon Mesh
  58761. * NB : All CSG operations are performed in world coordinates
  58762. * @param csg The CSG to copy the transform attributes from
  58763. * @returns This CSG
  58764. */
  58765. copyTransformAttributes(csg: CSG): CSG;
  58766. /**
  58767. * Build Raw mesh from CSG
  58768. * Coordinates here are in world space
  58769. * @param name The name of the mesh geometry
  58770. * @param scene The Scene
  58771. * @param keepSubMeshes Specifies if the submeshes should be kept
  58772. * @returns A new Mesh
  58773. */
  58774. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58775. /**
  58776. * Build Mesh from CSG taking material and transforms into account
  58777. * @param name The name of the Mesh
  58778. * @param material The material of the Mesh
  58779. * @param scene The Scene
  58780. * @param keepSubMeshes Specifies if submeshes should be kept
  58781. * @returns The new Mesh
  58782. */
  58783. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58784. }
  58785. }
  58786. declare module BABYLON {
  58787. /**
  58788. * Class used to create a trail following a mesh
  58789. */
  58790. export class TrailMesh extends Mesh {
  58791. private _generator;
  58792. private _autoStart;
  58793. private _running;
  58794. private _diameter;
  58795. private _length;
  58796. private _sectionPolygonPointsCount;
  58797. private _sectionVectors;
  58798. private _sectionNormalVectors;
  58799. private _beforeRenderObserver;
  58800. /**
  58801. * @constructor
  58802. * @param name The value used by scene.getMeshByName() to do a lookup.
  58803. * @param generator The mesh to generate a trail.
  58804. * @param scene The scene to add this mesh to.
  58805. * @param diameter Diameter of trailing mesh. Default is 1.
  58806. * @param length Length of trailing mesh. Default is 60.
  58807. * @param autoStart Automatically start trailing mesh. Default true.
  58808. */
  58809. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58810. /**
  58811. * "TrailMesh"
  58812. * @returns "TrailMesh"
  58813. */
  58814. getClassName(): string;
  58815. private _createMesh;
  58816. /**
  58817. * Start trailing mesh.
  58818. */
  58819. start(): void;
  58820. /**
  58821. * Stop trailing mesh.
  58822. */
  58823. stop(): void;
  58824. /**
  58825. * Update trailing mesh geometry.
  58826. */
  58827. update(): void;
  58828. /**
  58829. * Returns a new TrailMesh object.
  58830. * @param name is a string, the name given to the new mesh
  58831. * @param newGenerator use new generator object for cloned trail mesh
  58832. * @returns a new mesh
  58833. */
  58834. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58835. /**
  58836. * Serializes this trail mesh
  58837. * @param serializationObject object to write serialization to
  58838. */
  58839. serialize(serializationObject: any): void;
  58840. /**
  58841. * Parses a serialized trail mesh
  58842. * @param parsedMesh the serialized mesh
  58843. * @param scene the scene to create the trail mesh in
  58844. * @returns the created trail mesh
  58845. */
  58846. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58847. }
  58848. }
  58849. declare module BABYLON {
  58850. /**
  58851. * Class containing static functions to help procedurally build meshes
  58852. */
  58853. export class TiledBoxBuilder {
  58854. /**
  58855. * Creates a box mesh
  58856. * 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)
  58857. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58859. * * 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
  58860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58861. * @param name defines the name of the mesh
  58862. * @param options defines the options used to create the mesh
  58863. * @param scene defines the hosting scene
  58864. * @returns the box mesh
  58865. */
  58866. static CreateTiledBox(name: string, options: {
  58867. pattern?: number;
  58868. width?: number;
  58869. height?: number;
  58870. depth?: number;
  58871. tileSize?: number;
  58872. tileWidth?: number;
  58873. tileHeight?: number;
  58874. alignHorizontal?: number;
  58875. alignVertical?: number;
  58876. faceUV?: Vector4[];
  58877. faceColors?: Color4[];
  58878. sideOrientation?: number;
  58879. updatable?: boolean;
  58880. }, scene?: Nullable<Scene>): Mesh;
  58881. }
  58882. }
  58883. declare module BABYLON {
  58884. /**
  58885. * Class containing static functions to help procedurally build meshes
  58886. */
  58887. export class TorusKnotBuilder {
  58888. /**
  58889. * Creates a torus knot mesh
  58890. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58891. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58892. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58893. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58895. * * 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
  58896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58897. * @param name defines the name of the mesh
  58898. * @param options defines the options used to create the mesh
  58899. * @param scene defines the hosting scene
  58900. * @returns the torus knot mesh
  58901. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58902. */
  58903. static CreateTorusKnot(name: string, options: {
  58904. radius?: number;
  58905. tube?: number;
  58906. radialSegments?: number;
  58907. tubularSegments?: number;
  58908. p?: number;
  58909. q?: number;
  58910. updatable?: boolean;
  58911. sideOrientation?: number;
  58912. frontUVs?: Vector4;
  58913. backUVs?: Vector4;
  58914. }, scene: any): Mesh;
  58915. }
  58916. }
  58917. declare module BABYLON {
  58918. /**
  58919. * Polygon
  58920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58921. */
  58922. export class Polygon {
  58923. /**
  58924. * Creates a rectangle
  58925. * @param xmin bottom X coord
  58926. * @param ymin bottom Y coord
  58927. * @param xmax top X coord
  58928. * @param ymax top Y coord
  58929. * @returns points that make the resulting rectation
  58930. */
  58931. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58932. /**
  58933. * Creates a circle
  58934. * @param radius radius of circle
  58935. * @param cx scale in x
  58936. * @param cy scale in y
  58937. * @param numberOfSides number of sides that make up the circle
  58938. * @returns points that make the resulting circle
  58939. */
  58940. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58941. /**
  58942. * Creates a polygon from input string
  58943. * @param input Input polygon data
  58944. * @returns the parsed points
  58945. */
  58946. static Parse(input: string): Vector2[];
  58947. /**
  58948. * Starts building a polygon from x and y coordinates
  58949. * @param x x coordinate
  58950. * @param y y coordinate
  58951. * @returns the started path2
  58952. */
  58953. static StartingAt(x: number, y: number): Path2;
  58954. }
  58955. /**
  58956. * Builds a polygon
  58957. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58958. */
  58959. export class PolygonMeshBuilder {
  58960. private _points;
  58961. private _outlinepoints;
  58962. private _holes;
  58963. private _name;
  58964. private _scene;
  58965. private _epoints;
  58966. private _eholes;
  58967. private _addToepoint;
  58968. /**
  58969. * Babylon reference to the earcut plugin.
  58970. */
  58971. bjsEarcut: any;
  58972. /**
  58973. * Creates a PolygonMeshBuilder
  58974. * @param name name of the builder
  58975. * @param contours Path of the polygon
  58976. * @param scene scene to add to when creating the mesh
  58977. * @param earcutInjection can be used to inject your own earcut reference
  58978. */
  58979. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58980. /**
  58981. * Adds a whole within the polygon
  58982. * @param hole Array of points defining the hole
  58983. * @returns this
  58984. */
  58985. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58986. /**
  58987. * Creates the polygon
  58988. * @param updatable If the mesh should be updatable
  58989. * @param depth The depth of the mesh created
  58990. * @returns the created mesh
  58991. */
  58992. build(updatable?: boolean, depth?: number): Mesh;
  58993. /**
  58994. * Creates the polygon
  58995. * @param depth The depth of the mesh created
  58996. * @returns the created VertexData
  58997. */
  58998. buildVertexData(depth?: number): VertexData;
  58999. /**
  59000. * Adds a side to the polygon
  59001. * @param positions points that make the polygon
  59002. * @param normals normals of the polygon
  59003. * @param uvs uvs of the polygon
  59004. * @param indices indices of the polygon
  59005. * @param bounds bounds of the polygon
  59006. * @param points points of the polygon
  59007. * @param depth depth of the polygon
  59008. * @param flip flip of the polygon
  59009. */
  59010. private addSide;
  59011. }
  59012. }
  59013. declare module BABYLON {
  59014. /**
  59015. * Class containing static functions to help procedurally build meshes
  59016. */
  59017. export class PolygonBuilder {
  59018. /**
  59019. * Creates a polygon mesh
  59020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59021. * * 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
  59022. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59024. * * 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)
  59025. * * Remember you can only change the shape positions, not their number when updating a polygon
  59026. * @param name defines the name of the mesh
  59027. * @param options defines the options used to create the mesh
  59028. * @param scene defines the hosting scene
  59029. * @param earcutInjection can be used to inject your own earcut reference
  59030. * @returns the polygon mesh
  59031. */
  59032. static CreatePolygon(name: string, options: {
  59033. shape: Vector3[];
  59034. holes?: Vector3[][];
  59035. depth?: number;
  59036. faceUV?: Vector4[];
  59037. faceColors?: Color4[];
  59038. updatable?: boolean;
  59039. sideOrientation?: number;
  59040. frontUVs?: Vector4;
  59041. backUVs?: Vector4;
  59042. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59043. /**
  59044. * Creates an extruded polygon mesh, with depth in the Y direction.
  59045. * * 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)
  59046. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59047. * @param name defines the name of the mesh
  59048. * @param options defines the options used to create the mesh
  59049. * @param scene defines the hosting scene
  59050. * @param earcutInjection can be used to inject your own earcut reference
  59051. * @returns the polygon mesh
  59052. */
  59053. static ExtrudePolygon(name: string, options: {
  59054. shape: Vector3[];
  59055. holes?: Vector3[][];
  59056. depth?: number;
  59057. faceUV?: Vector4[];
  59058. faceColors?: Color4[];
  59059. updatable?: boolean;
  59060. sideOrientation?: number;
  59061. frontUVs?: Vector4;
  59062. backUVs?: Vector4;
  59063. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59064. }
  59065. }
  59066. declare module BABYLON {
  59067. /**
  59068. * Class containing static functions to help procedurally build meshes
  59069. */
  59070. export class LatheBuilder {
  59071. /**
  59072. * Creates lathe mesh.
  59073. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59074. * * 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
  59075. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59076. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59077. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59078. * * 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
  59079. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59080. * * 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
  59081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59082. * * 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
  59083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59085. * @param name defines the name of the mesh
  59086. * @param options defines the options used to create the mesh
  59087. * @param scene defines the hosting scene
  59088. * @returns the lathe mesh
  59089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59090. */
  59091. static CreateLathe(name: string, options: {
  59092. shape: Vector3[];
  59093. radius?: number;
  59094. tessellation?: number;
  59095. clip?: number;
  59096. arc?: number;
  59097. closed?: boolean;
  59098. updatable?: boolean;
  59099. sideOrientation?: number;
  59100. frontUVs?: Vector4;
  59101. backUVs?: Vector4;
  59102. cap?: number;
  59103. invertUV?: boolean;
  59104. }, scene?: Nullable<Scene>): Mesh;
  59105. }
  59106. }
  59107. declare module BABYLON {
  59108. /**
  59109. * Class containing static functions to help procedurally build meshes
  59110. */
  59111. export class TiledPlaneBuilder {
  59112. /**
  59113. * Creates a tiled plane mesh
  59114. * * The parameter `pattern` will, depending on value, do nothing or
  59115. * * * flip (reflect about central vertical) alternate tiles across and up
  59116. * * * flip every tile on alternate rows
  59117. * * * rotate (180 degs) alternate tiles across and up
  59118. * * * rotate every tile on alternate rows
  59119. * * * flip and rotate alternate tiles across and up
  59120. * * * flip and rotate every tile on alternate rows
  59121. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59122. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59123. * * 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
  59124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59125. * * 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)
  59126. * * 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)
  59127. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59128. * @param name defines the name of the mesh
  59129. * @param options defines the options used to create the mesh
  59130. * @param scene defines the hosting scene
  59131. * @returns the box mesh
  59132. */
  59133. static CreateTiledPlane(name: string, options: {
  59134. pattern?: number;
  59135. tileSize?: number;
  59136. tileWidth?: number;
  59137. tileHeight?: number;
  59138. size?: number;
  59139. width?: number;
  59140. height?: number;
  59141. alignHorizontal?: number;
  59142. alignVertical?: number;
  59143. sideOrientation?: number;
  59144. frontUVs?: Vector4;
  59145. backUVs?: Vector4;
  59146. updatable?: boolean;
  59147. }, scene?: Nullable<Scene>): Mesh;
  59148. }
  59149. }
  59150. declare module BABYLON {
  59151. /**
  59152. * Class containing static functions to help procedurally build meshes
  59153. */
  59154. export class TubeBuilder {
  59155. /**
  59156. * Creates a tube mesh.
  59157. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59158. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59159. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59160. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59161. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59162. * * 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)
  59163. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59164. * * 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
  59165. * * 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
  59166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59167. * * 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
  59168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59170. * @param name defines the name of the mesh
  59171. * @param options defines the options used to create the mesh
  59172. * @param scene defines the hosting scene
  59173. * @returns the tube mesh
  59174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59175. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59176. */
  59177. static CreateTube(name: string, options: {
  59178. path: Vector3[];
  59179. radius?: number;
  59180. tessellation?: number;
  59181. radiusFunction?: {
  59182. (i: number, distance: number): number;
  59183. };
  59184. cap?: number;
  59185. arc?: number;
  59186. updatable?: boolean;
  59187. sideOrientation?: number;
  59188. frontUVs?: Vector4;
  59189. backUVs?: Vector4;
  59190. instance?: Mesh;
  59191. invertUV?: boolean;
  59192. }, scene?: Nullable<Scene>): Mesh;
  59193. }
  59194. }
  59195. declare module BABYLON {
  59196. /**
  59197. * Class containing static functions to help procedurally build meshes
  59198. */
  59199. export class IcoSphereBuilder {
  59200. /**
  59201. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59202. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59203. * * 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`)
  59204. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59205. * * 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
  59206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59207. * * 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
  59208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59209. * @param name defines the name of the mesh
  59210. * @param options defines the options used to create the mesh
  59211. * @param scene defines the hosting scene
  59212. * @returns the icosahedron mesh
  59213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59214. */
  59215. static CreateIcoSphere(name: string, options: {
  59216. radius?: number;
  59217. radiusX?: number;
  59218. radiusY?: number;
  59219. radiusZ?: number;
  59220. flat?: boolean;
  59221. subdivisions?: number;
  59222. sideOrientation?: number;
  59223. frontUVs?: Vector4;
  59224. backUVs?: Vector4;
  59225. updatable?: boolean;
  59226. }, scene?: Nullable<Scene>): Mesh;
  59227. }
  59228. }
  59229. declare module BABYLON {
  59230. /**
  59231. * Class containing static functions to help procedurally build meshes
  59232. */
  59233. export class DecalBuilder {
  59234. /**
  59235. * Creates a decal mesh.
  59236. * 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
  59237. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59238. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59239. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59240. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59241. * @param name defines the name of the mesh
  59242. * @param sourceMesh defines the mesh where the decal must be applied
  59243. * @param options defines the options used to create the mesh
  59244. * @param scene defines the hosting scene
  59245. * @returns the decal mesh
  59246. * @see https://doc.babylonjs.com/how_to/decals
  59247. */
  59248. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59249. position?: Vector3;
  59250. normal?: Vector3;
  59251. size?: Vector3;
  59252. angle?: number;
  59253. }): Mesh;
  59254. }
  59255. }
  59256. declare module BABYLON {
  59257. /**
  59258. * Class containing static functions to help procedurally build meshes
  59259. */
  59260. export class MeshBuilder {
  59261. /**
  59262. * Creates a box mesh
  59263. * * The parameter `size` sets the size (float) of each box side (default 1)
  59264. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59265. * * 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)
  59266. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59268. * * 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
  59269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59270. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59271. * @param name defines the name of the mesh
  59272. * @param options defines the options used to create the mesh
  59273. * @param scene defines the hosting scene
  59274. * @returns the box mesh
  59275. */
  59276. static CreateBox(name: string, options: {
  59277. size?: number;
  59278. width?: number;
  59279. height?: number;
  59280. depth?: number;
  59281. faceUV?: Vector4[];
  59282. faceColors?: Color4[];
  59283. sideOrientation?: number;
  59284. frontUVs?: Vector4;
  59285. backUVs?: Vector4;
  59286. updatable?: boolean;
  59287. }, scene?: Nullable<Scene>): Mesh;
  59288. /**
  59289. * Creates a tiled box mesh
  59290. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59292. * @param name defines the name of the mesh
  59293. * @param options defines the options used to create the mesh
  59294. * @param scene defines the hosting scene
  59295. * @returns the tiled box mesh
  59296. */
  59297. static CreateTiledBox(name: string, options: {
  59298. pattern?: number;
  59299. size?: number;
  59300. width?: number;
  59301. height?: number;
  59302. depth: number;
  59303. tileSize?: number;
  59304. tileWidth?: number;
  59305. tileHeight?: number;
  59306. faceUV?: Vector4[];
  59307. faceColors?: Color4[];
  59308. alignHorizontal?: number;
  59309. alignVertical?: number;
  59310. sideOrientation?: number;
  59311. updatable?: boolean;
  59312. }, scene?: Nullable<Scene>): Mesh;
  59313. /**
  59314. * Creates a sphere mesh
  59315. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59316. * * 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`)
  59317. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59318. * * 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
  59319. * * 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)
  59320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59321. * * 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
  59322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59323. * @param name defines the name of the mesh
  59324. * @param options defines the options used to create the mesh
  59325. * @param scene defines the hosting scene
  59326. * @returns the sphere mesh
  59327. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59328. */
  59329. static CreateSphere(name: string, options: {
  59330. segments?: number;
  59331. diameter?: number;
  59332. diameterX?: number;
  59333. diameterY?: number;
  59334. diameterZ?: number;
  59335. arc?: number;
  59336. slice?: number;
  59337. sideOrientation?: number;
  59338. frontUVs?: Vector4;
  59339. backUVs?: Vector4;
  59340. updatable?: boolean;
  59341. }, scene?: Nullable<Scene>): Mesh;
  59342. /**
  59343. * Creates a plane polygonal mesh. By default, this is a disc
  59344. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59345. * * 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
  59346. * * 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
  59347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59348. * * 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
  59349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59350. * @param name defines the name of the mesh
  59351. * @param options defines the options used to create the mesh
  59352. * @param scene defines the hosting scene
  59353. * @returns the plane polygonal mesh
  59354. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59355. */
  59356. static CreateDisc(name: string, options: {
  59357. radius?: number;
  59358. tessellation?: number;
  59359. arc?: number;
  59360. updatable?: boolean;
  59361. sideOrientation?: number;
  59362. frontUVs?: Vector4;
  59363. backUVs?: Vector4;
  59364. }, scene?: Nullable<Scene>): Mesh;
  59365. /**
  59366. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59367. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59368. * * 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`)
  59369. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59370. * * 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
  59371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59372. * * 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
  59373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59374. * @param name defines the name of the mesh
  59375. * @param options defines the options used to create the mesh
  59376. * @param scene defines the hosting scene
  59377. * @returns the icosahedron mesh
  59378. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59379. */
  59380. static CreateIcoSphere(name: string, options: {
  59381. radius?: number;
  59382. radiusX?: number;
  59383. radiusY?: number;
  59384. radiusZ?: number;
  59385. flat?: boolean;
  59386. subdivisions?: number;
  59387. sideOrientation?: number;
  59388. frontUVs?: Vector4;
  59389. backUVs?: Vector4;
  59390. updatable?: boolean;
  59391. }, scene?: Nullable<Scene>): Mesh;
  59392. /**
  59393. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59394. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59395. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59396. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59397. * * 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
  59398. * * 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
  59399. * * 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
  59400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59401. * * 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
  59402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59403. * * 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
  59404. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59405. * * 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
  59406. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59408. * @param name defines the name of the mesh
  59409. * @param options defines the options used to create the mesh
  59410. * @param scene defines the hosting scene
  59411. * @returns the ribbon mesh
  59412. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59414. */
  59415. static CreateRibbon(name: string, options: {
  59416. pathArray: Vector3[][];
  59417. closeArray?: boolean;
  59418. closePath?: boolean;
  59419. offset?: number;
  59420. updatable?: boolean;
  59421. sideOrientation?: number;
  59422. frontUVs?: Vector4;
  59423. backUVs?: Vector4;
  59424. instance?: Mesh;
  59425. invertUV?: boolean;
  59426. uvs?: Vector2[];
  59427. colors?: Color4[];
  59428. }, scene?: Nullable<Scene>): Mesh;
  59429. /**
  59430. * Creates a cylinder or a cone mesh
  59431. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59432. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59433. * * 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.
  59434. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59435. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59436. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59437. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59438. * * 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).
  59439. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59440. * * 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).
  59441. * * 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
  59442. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59443. * * 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
  59444. * * 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.
  59445. * * If `enclose` is false, a ring surface is one element.
  59446. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59447. * * 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
  59448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59449. * * 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
  59450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59451. * @param name defines the name of the mesh
  59452. * @param options defines the options used to create the mesh
  59453. * @param scene defines the hosting scene
  59454. * @returns the cylinder mesh
  59455. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59456. */
  59457. static CreateCylinder(name: string, options: {
  59458. height?: number;
  59459. diameterTop?: number;
  59460. diameterBottom?: number;
  59461. diameter?: number;
  59462. tessellation?: number;
  59463. subdivisions?: number;
  59464. arc?: number;
  59465. faceColors?: Color4[];
  59466. faceUV?: Vector4[];
  59467. updatable?: boolean;
  59468. hasRings?: boolean;
  59469. enclose?: boolean;
  59470. cap?: number;
  59471. sideOrientation?: number;
  59472. frontUVs?: Vector4;
  59473. backUVs?: Vector4;
  59474. }, scene?: Nullable<Scene>): Mesh;
  59475. /**
  59476. * Creates a torus mesh
  59477. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59478. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59479. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59481. * * 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
  59482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59483. * @param name defines the name of the mesh
  59484. * @param options defines the options used to create the mesh
  59485. * @param scene defines the hosting scene
  59486. * @returns the torus mesh
  59487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59488. */
  59489. static CreateTorus(name: string, options: {
  59490. diameter?: number;
  59491. thickness?: number;
  59492. tessellation?: number;
  59493. updatable?: boolean;
  59494. sideOrientation?: number;
  59495. frontUVs?: Vector4;
  59496. backUVs?: Vector4;
  59497. }, scene?: Nullable<Scene>): Mesh;
  59498. /**
  59499. * Creates a torus knot mesh
  59500. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59501. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59502. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59503. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59505. * * 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
  59506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59507. * @param name defines the name of the mesh
  59508. * @param options defines the options used to create the mesh
  59509. * @param scene defines the hosting scene
  59510. * @returns the torus knot mesh
  59511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59512. */
  59513. static CreateTorusKnot(name: string, options: {
  59514. radius?: number;
  59515. tube?: number;
  59516. radialSegments?: number;
  59517. tubularSegments?: number;
  59518. p?: number;
  59519. q?: number;
  59520. updatable?: boolean;
  59521. sideOrientation?: number;
  59522. frontUVs?: Vector4;
  59523. backUVs?: Vector4;
  59524. }, scene?: Nullable<Scene>): Mesh;
  59525. /**
  59526. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59527. * * 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
  59528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59529. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59530. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59531. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59533. * * 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
  59534. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59537. * @param name defines the name of the new line system
  59538. * @param options defines the options used to create the line system
  59539. * @param scene defines the hosting scene
  59540. * @returns a new line system mesh
  59541. */
  59542. static CreateLineSystem(name: string, options: {
  59543. lines: Vector3[][];
  59544. updatable?: boolean;
  59545. instance?: Nullable<LinesMesh>;
  59546. colors?: Nullable<Color4[][]>;
  59547. useVertexAlpha?: boolean;
  59548. }, scene: Nullable<Scene>): LinesMesh;
  59549. /**
  59550. * Creates a line mesh
  59551. * 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
  59552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59553. * * The parameter `points` is an array successive Vector3
  59554. * * 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
  59555. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59556. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59557. * * When updating an instance, remember that only point positions can change, not the number of points
  59558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59560. * @param name defines the name of the new line system
  59561. * @param options defines the options used to create the line system
  59562. * @param scene defines the hosting scene
  59563. * @returns a new line mesh
  59564. */
  59565. static CreateLines(name: string, options: {
  59566. points: Vector3[];
  59567. updatable?: boolean;
  59568. instance?: Nullable<LinesMesh>;
  59569. colors?: Color4[];
  59570. useVertexAlpha?: boolean;
  59571. }, scene?: Nullable<Scene>): LinesMesh;
  59572. /**
  59573. * Creates a dashed line mesh
  59574. * * 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
  59575. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59576. * * The parameter `points` is an array successive Vector3
  59577. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59578. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59579. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59580. * * 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
  59581. * * When updating an instance, remember that only point positions can change, not the number of points
  59582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59583. * @param name defines the name of the mesh
  59584. * @param options defines the options used to create the mesh
  59585. * @param scene defines the hosting scene
  59586. * @returns the dashed line mesh
  59587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59588. */
  59589. static CreateDashedLines(name: string, options: {
  59590. points: Vector3[];
  59591. dashSize?: number;
  59592. gapSize?: number;
  59593. dashNb?: number;
  59594. updatable?: boolean;
  59595. instance?: LinesMesh;
  59596. }, scene?: Nullable<Scene>): LinesMesh;
  59597. /**
  59598. * 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.
  59599. * * 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.
  59600. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59601. * * 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.
  59602. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59603. * * 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
  59604. * * 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
  59605. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59607. * * 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
  59608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59610. * @param name defines the name of the mesh
  59611. * @param options defines the options used to create the mesh
  59612. * @param scene defines the hosting scene
  59613. * @returns the extruded shape mesh
  59614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59616. */
  59617. static ExtrudeShape(name: string, options: {
  59618. shape: Vector3[];
  59619. path: Vector3[];
  59620. scale?: number;
  59621. rotation?: number;
  59622. cap?: number;
  59623. updatable?: boolean;
  59624. sideOrientation?: number;
  59625. frontUVs?: Vector4;
  59626. backUVs?: Vector4;
  59627. instance?: Mesh;
  59628. invertUV?: boolean;
  59629. }, scene?: Nullable<Scene>): Mesh;
  59630. /**
  59631. * Creates an custom extruded shape mesh.
  59632. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59633. * * 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.
  59634. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59635. * * 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
  59636. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59637. * * 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
  59638. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59639. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59640. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59641. * * 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
  59642. * * 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
  59643. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59645. * * 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
  59646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59648. * @param name defines the name of the mesh
  59649. * @param options defines the options used to create the mesh
  59650. * @param scene defines the hosting scene
  59651. * @returns the custom extruded shape mesh
  59652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59655. */
  59656. static ExtrudeShapeCustom(name: string, options: {
  59657. shape: Vector3[];
  59658. path: Vector3[];
  59659. scaleFunction?: any;
  59660. rotationFunction?: any;
  59661. ribbonCloseArray?: boolean;
  59662. ribbonClosePath?: boolean;
  59663. cap?: number;
  59664. updatable?: boolean;
  59665. sideOrientation?: number;
  59666. frontUVs?: Vector4;
  59667. backUVs?: Vector4;
  59668. instance?: Mesh;
  59669. invertUV?: boolean;
  59670. }, scene?: Nullable<Scene>): Mesh;
  59671. /**
  59672. * Creates lathe mesh.
  59673. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59674. * * 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
  59675. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59676. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59677. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59678. * * 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
  59679. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59680. * * 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
  59681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59682. * * 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
  59683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59685. * @param name defines the name of the mesh
  59686. * @param options defines the options used to create the mesh
  59687. * @param scene defines the hosting scene
  59688. * @returns the lathe mesh
  59689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59690. */
  59691. static CreateLathe(name: string, options: {
  59692. shape: Vector3[];
  59693. radius?: number;
  59694. tessellation?: number;
  59695. clip?: number;
  59696. arc?: number;
  59697. closed?: boolean;
  59698. updatable?: boolean;
  59699. sideOrientation?: number;
  59700. frontUVs?: Vector4;
  59701. backUVs?: Vector4;
  59702. cap?: number;
  59703. invertUV?: boolean;
  59704. }, scene?: Nullable<Scene>): Mesh;
  59705. /**
  59706. * Creates a tiled plane mesh
  59707. * * You can set a limited pattern arrangement with the tiles
  59708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59709. * * 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
  59710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59711. * @param name defines the name of the mesh
  59712. * @param options defines the options used to create the mesh
  59713. * @param scene defines the hosting scene
  59714. * @returns the plane mesh
  59715. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59716. */
  59717. static CreateTiledPlane(name: string, options: {
  59718. pattern?: number;
  59719. tileSize?: number;
  59720. tileWidth?: number;
  59721. tileHeight?: number;
  59722. size?: number;
  59723. width?: number;
  59724. height?: number;
  59725. alignHorizontal?: number;
  59726. alignVertical?: number;
  59727. sideOrientation?: number;
  59728. frontUVs?: Vector4;
  59729. backUVs?: Vector4;
  59730. updatable?: boolean;
  59731. }, scene?: Nullable<Scene>): Mesh;
  59732. /**
  59733. * Creates a plane mesh
  59734. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59735. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59736. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59738. * * 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
  59739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59740. * @param name defines the name of the mesh
  59741. * @param options defines the options used to create the mesh
  59742. * @param scene defines the hosting scene
  59743. * @returns the plane mesh
  59744. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59745. */
  59746. static CreatePlane(name: string, options: {
  59747. size?: number;
  59748. width?: number;
  59749. height?: number;
  59750. sideOrientation?: number;
  59751. frontUVs?: Vector4;
  59752. backUVs?: Vector4;
  59753. updatable?: boolean;
  59754. sourcePlane?: Plane;
  59755. }, scene?: Nullable<Scene>): Mesh;
  59756. /**
  59757. * Creates a ground mesh
  59758. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59759. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59761. * @param name defines the name of the mesh
  59762. * @param options defines the options used to create the mesh
  59763. * @param scene defines the hosting scene
  59764. * @returns the ground mesh
  59765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59766. */
  59767. static CreateGround(name: string, options: {
  59768. width?: number;
  59769. height?: number;
  59770. subdivisions?: number;
  59771. subdivisionsX?: number;
  59772. subdivisionsY?: number;
  59773. updatable?: boolean;
  59774. }, scene?: Nullable<Scene>): Mesh;
  59775. /**
  59776. * Creates a tiled ground mesh
  59777. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59778. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59779. * * 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
  59780. * * 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
  59781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59782. * @param name defines the name of the mesh
  59783. * @param options defines the options used to create the mesh
  59784. * @param scene defines the hosting scene
  59785. * @returns the tiled ground mesh
  59786. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59787. */
  59788. static CreateTiledGround(name: string, options: {
  59789. xmin: number;
  59790. zmin: number;
  59791. xmax: number;
  59792. zmax: number;
  59793. subdivisions?: {
  59794. w: number;
  59795. h: number;
  59796. };
  59797. precision?: {
  59798. w: number;
  59799. h: number;
  59800. };
  59801. updatable?: boolean;
  59802. }, scene?: Nullable<Scene>): Mesh;
  59803. /**
  59804. * Creates a ground mesh from a height map
  59805. * * The parameter `url` sets the URL of the height map image resource.
  59806. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59807. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59808. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59809. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59810. * * 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.
  59811. * * 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).
  59812. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59814. * @param name defines the name of the mesh
  59815. * @param url defines the url to the height map
  59816. * @param options defines the options used to create the mesh
  59817. * @param scene defines the hosting scene
  59818. * @returns the ground mesh
  59819. * @see https://doc.babylonjs.com/babylon101/height_map
  59820. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59821. */
  59822. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59823. width?: number;
  59824. height?: number;
  59825. subdivisions?: number;
  59826. minHeight?: number;
  59827. maxHeight?: number;
  59828. colorFilter?: Color3;
  59829. alphaFilter?: number;
  59830. updatable?: boolean;
  59831. onReady?: (mesh: GroundMesh) => void;
  59832. }, scene?: Nullable<Scene>): GroundMesh;
  59833. /**
  59834. * Creates a polygon mesh
  59835. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59836. * * 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
  59837. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59839. * * 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)
  59840. * * Remember you can only change the shape positions, not their number when updating a polygon
  59841. * @param name defines the name of the mesh
  59842. * @param options defines the options used to create the mesh
  59843. * @param scene defines the hosting scene
  59844. * @param earcutInjection can be used to inject your own earcut reference
  59845. * @returns the polygon mesh
  59846. */
  59847. static CreatePolygon(name: string, options: {
  59848. shape: Vector3[];
  59849. holes?: Vector3[][];
  59850. depth?: number;
  59851. faceUV?: Vector4[];
  59852. faceColors?: Color4[];
  59853. updatable?: boolean;
  59854. sideOrientation?: number;
  59855. frontUVs?: Vector4;
  59856. backUVs?: Vector4;
  59857. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59858. /**
  59859. * Creates an extruded polygon mesh, with depth in the Y direction.
  59860. * * 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)
  59861. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59862. * @param name defines the name of the mesh
  59863. * @param options defines the options used to create the mesh
  59864. * @param scene defines the hosting scene
  59865. * @param earcutInjection can be used to inject your own earcut reference
  59866. * @returns the polygon mesh
  59867. */
  59868. static ExtrudePolygon(name: string, options: {
  59869. shape: Vector3[];
  59870. holes?: Vector3[][];
  59871. depth?: number;
  59872. faceUV?: Vector4[];
  59873. faceColors?: Color4[];
  59874. updatable?: boolean;
  59875. sideOrientation?: number;
  59876. frontUVs?: Vector4;
  59877. backUVs?: Vector4;
  59878. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59879. /**
  59880. * Creates a tube mesh.
  59881. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59882. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59883. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59884. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59885. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59886. * * 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)
  59887. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59888. * * 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
  59889. * * 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
  59890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59891. * * 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
  59892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59894. * @param name defines the name of the mesh
  59895. * @param options defines the options used to create the mesh
  59896. * @param scene defines the hosting scene
  59897. * @returns the tube mesh
  59898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59899. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59900. */
  59901. static CreateTube(name: string, options: {
  59902. path: Vector3[];
  59903. radius?: number;
  59904. tessellation?: number;
  59905. radiusFunction?: {
  59906. (i: number, distance: number): number;
  59907. };
  59908. cap?: number;
  59909. arc?: number;
  59910. updatable?: boolean;
  59911. sideOrientation?: number;
  59912. frontUVs?: Vector4;
  59913. backUVs?: Vector4;
  59914. instance?: Mesh;
  59915. invertUV?: boolean;
  59916. }, scene?: Nullable<Scene>): Mesh;
  59917. /**
  59918. * Creates a polyhedron mesh
  59919. * * 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
  59920. * * The parameter `size` (positive float, default 1) sets the polygon size
  59921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59922. * * 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`
  59923. * * 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
  59924. * * 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)`)
  59925. * * 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
  59926. * * 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
  59927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59928. * * 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
  59929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59930. * @param name defines the name of the mesh
  59931. * @param options defines the options used to create the mesh
  59932. * @param scene defines the hosting scene
  59933. * @returns the polyhedron mesh
  59934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59935. */
  59936. static CreatePolyhedron(name: string, options: {
  59937. type?: number;
  59938. size?: number;
  59939. sizeX?: number;
  59940. sizeY?: number;
  59941. sizeZ?: number;
  59942. custom?: any;
  59943. faceUV?: Vector4[];
  59944. faceColors?: Color4[];
  59945. flat?: boolean;
  59946. updatable?: boolean;
  59947. sideOrientation?: number;
  59948. frontUVs?: Vector4;
  59949. backUVs?: Vector4;
  59950. }, scene?: Nullable<Scene>): Mesh;
  59951. /**
  59952. * Creates a decal mesh.
  59953. * 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
  59954. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59955. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59956. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59957. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59958. * @param name defines the name of the mesh
  59959. * @param sourceMesh defines the mesh where the decal must be applied
  59960. * @param options defines the options used to create the mesh
  59961. * @param scene defines the hosting scene
  59962. * @returns the decal mesh
  59963. * @see https://doc.babylonjs.com/how_to/decals
  59964. */
  59965. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59966. position?: Vector3;
  59967. normal?: Vector3;
  59968. size?: Vector3;
  59969. angle?: number;
  59970. }): Mesh;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * A simplifier interface for future simplification implementations
  59976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59977. */
  59978. export interface ISimplifier {
  59979. /**
  59980. * Simplification of a given mesh according to the given settings.
  59981. * Since this requires computation, it is assumed that the function runs async.
  59982. * @param settings The settings of the simplification, including quality and distance
  59983. * @param successCallback A callback that will be called after the mesh was simplified.
  59984. * @param errorCallback in case of an error, this callback will be called. optional.
  59985. */
  59986. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59987. }
  59988. /**
  59989. * Expected simplification settings.
  59990. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59992. */
  59993. export interface ISimplificationSettings {
  59994. /**
  59995. * Gets or sets the expected quality
  59996. */
  59997. quality: number;
  59998. /**
  59999. * Gets or sets the distance when this optimized version should be used
  60000. */
  60001. distance: number;
  60002. /**
  60003. * Gets an already optimized mesh
  60004. */
  60005. optimizeMesh?: boolean;
  60006. }
  60007. /**
  60008. * Class used to specify simplification options
  60009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60010. */
  60011. export class SimplificationSettings implements ISimplificationSettings {
  60012. /** expected quality */
  60013. quality: number;
  60014. /** distance when this optimized version should be used */
  60015. distance: number;
  60016. /** already optimized mesh */
  60017. optimizeMesh?: boolean | undefined;
  60018. /**
  60019. * Creates a SimplificationSettings
  60020. * @param quality expected quality
  60021. * @param distance distance when this optimized version should be used
  60022. * @param optimizeMesh already optimized mesh
  60023. */
  60024. constructor(
  60025. /** expected quality */
  60026. quality: number,
  60027. /** distance when this optimized version should be used */
  60028. distance: number,
  60029. /** already optimized mesh */
  60030. optimizeMesh?: boolean | undefined);
  60031. }
  60032. /**
  60033. * Interface used to define a simplification task
  60034. */
  60035. export interface ISimplificationTask {
  60036. /**
  60037. * Array of settings
  60038. */
  60039. settings: Array<ISimplificationSettings>;
  60040. /**
  60041. * Simplification type
  60042. */
  60043. simplificationType: SimplificationType;
  60044. /**
  60045. * Mesh to simplify
  60046. */
  60047. mesh: Mesh;
  60048. /**
  60049. * Callback called on success
  60050. */
  60051. successCallback?: () => void;
  60052. /**
  60053. * Defines if parallel processing can be used
  60054. */
  60055. parallelProcessing: boolean;
  60056. }
  60057. /**
  60058. * Queue used to order the simplification tasks
  60059. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60060. */
  60061. export class SimplificationQueue {
  60062. private _simplificationArray;
  60063. /**
  60064. * Gets a boolean indicating that the process is still running
  60065. */
  60066. running: boolean;
  60067. /**
  60068. * Creates a new queue
  60069. */
  60070. constructor();
  60071. /**
  60072. * Adds a new simplification task
  60073. * @param task defines a task to add
  60074. */
  60075. addTask(task: ISimplificationTask): void;
  60076. /**
  60077. * Execute next task
  60078. */
  60079. executeNext(): void;
  60080. /**
  60081. * Execute a simplification task
  60082. * @param task defines the task to run
  60083. */
  60084. runSimplification(task: ISimplificationTask): void;
  60085. private getSimplifier;
  60086. }
  60087. /**
  60088. * The implemented types of simplification
  60089. * At the moment only Quadratic Error Decimation is implemented
  60090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60091. */
  60092. export enum SimplificationType {
  60093. /** Quadratic error decimation */
  60094. QUADRATIC = 0
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. interface Scene {
  60099. /** @hidden (Backing field) */
  60100. _simplificationQueue: SimplificationQueue;
  60101. /**
  60102. * Gets or sets the simplification queue attached to the scene
  60103. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60104. */
  60105. simplificationQueue: SimplificationQueue;
  60106. }
  60107. interface Mesh {
  60108. /**
  60109. * Simplify the mesh according to the given array of settings.
  60110. * Function will return immediately and will simplify async
  60111. * @param settings a collection of simplification settings
  60112. * @param parallelProcessing should all levels calculate parallel or one after the other
  60113. * @param simplificationType the type of simplification to run
  60114. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60115. * @returns the current mesh
  60116. */
  60117. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60118. }
  60119. /**
  60120. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60121. * created in a scene
  60122. */
  60123. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60124. /**
  60125. * The component name helpfull to identify the component in the list of scene components.
  60126. */
  60127. readonly name: string;
  60128. /**
  60129. * The scene the component belongs to.
  60130. */
  60131. scene: Scene;
  60132. /**
  60133. * Creates a new instance of the component for the given scene
  60134. * @param scene Defines the scene to register the component in
  60135. */
  60136. constructor(scene: Scene);
  60137. /**
  60138. * Registers the component in a given scene
  60139. */
  60140. register(): void;
  60141. /**
  60142. * Rebuilds the elements related to this component in case of
  60143. * context lost for instance.
  60144. */
  60145. rebuild(): void;
  60146. /**
  60147. * Disposes the component and the associated ressources
  60148. */
  60149. dispose(): void;
  60150. private _beforeCameraUpdate;
  60151. }
  60152. }
  60153. declare module BABYLON {
  60154. /**
  60155. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60156. */
  60157. export interface INavigationEnginePlugin {
  60158. /**
  60159. * plugin name
  60160. */
  60161. name: string;
  60162. /**
  60163. * Creates a navigation mesh
  60164. * @param meshes array of all the geometry used to compute the navigatio mesh
  60165. * @param parameters bunch of parameters used to filter geometry
  60166. */
  60167. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60168. /**
  60169. * Create a navigation mesh debug mesh
  60170. * @param scene is where the mesh will be added
  60171. * @returns debug display mesh
  60172. */
  60173. createDebugNavMesh(scene: Scene): Mesh;
  60174. /**
  60175. * Get a navigation mesh constrained position, closest to the parameter position
  60176. * @param position world position
  60177. * @returns the closest point to position constrained by the navigation mesh
  60178. */
  60179. getClosestPoint(position: Vector3): Vector3;
  60180. /**
  60181. * Get a navigation mesh constrained position, within a particular radius
  60182. * @param position world position
  60183. * @param maxRadius the maximum distance to the constrained world position
  60184. * @returns the closest point to position constrained by the navigation mesh
  60185. */
  60186. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60187. /**
  60188. * Compute the final position from a segment made of destination-position
  60189. * @param position world position
  60190. * @param destination world position
  60191. * @returns the resulting point along the navmesh
  60192. */
  60193. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60194. /**
  60195. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60196. * @param start world position
  60197. * @param end world position
  60198. * @returns array containing world position composing the path
  60199. */
  60200. computePath(start: Vector3, end: Vector3): Vector3[];
  60201. /**
  60202. * If this plugin is supported
  60203. * @returns true if plugin is supported
  60204. */
  60205. isSupported(): boolean;
  60206. /**
  60207. * Create a new Crowd so you can add agents
  60208. * @param maxAgents the maximum agent count in the crowd
  60209. * @param maxAgentRadius the maximum radius an agent can have
  60210. * @param scene to attach the crowd to
  60211. * @returns the crowd you can add agents to
  60212. */
  60213. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60214. /**
  60215. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60216. * The queries will try to find a solution within those bounds
  60217. * default is (1,1,1)
  60218. * @param extent x,y,z value that define the extent around the queries point of reference
  60219. */
  60220. setDefaultQueryExtent(extent: Vector3): void;
  60221. /**
  60222. * Get the Bounding box extent specified by setDefaultQueryExtent
  60223. * @returns the box extent values
  60224. */
  60225. getDefaultQueryExtent(): Vector3;
  60226. /**
  60227. * Release all resources
  60228. */
  60229. dispose(): void;
  60230. }
  60231. /**
  60232. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60233. */
  60234. export interface ICrowd {
  60235. /**
  60236. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60237. * You can attach anything to that node. The node position is updated in the scene update tick.
  60238. * @param pos world position that will be constrained by the navigation mesh
  60239. * @param parameters agent parameters
  60240. * @param transform hooked to the agent that will be update by the scene
  60241. * @returns agent index
  60242. */
  60243. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60244. /**
  60245. * Returns the agent position in world space
  60246. * @param index agent index returned by addAgent
  60247. * @returns world space position
  60248. */
  60249. getAgentPosition(index: number): Vector3;
  60250. /**
  60251. * Gets the agent velocity in world space
  60252. * @param index agent index returned by addAgent
  60253. * @returns world space velocity
  60254. */
  60255. getAgentVelocity(index: number): Vector3;
  60256. /**
  60257. * remove a particular agent previously created
  60258. * @param index agent index returned by addAgent
  60259. */
  60260. removeAgent(index: number): void;
  60261. /**
  60262. * get the list of all agents attached to this crowd
  60263. * @returns list of agent indices
  60264. */
  60265. getAgents(): number[];
  60266. /**
  60267. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60268. * @param deltaTime in seconds
  60269. */
  60270. update(deltaTime: number): void;
  60271. /**
  60272. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60273. * @param index agent index returned by addAgent
  60274. * @param destination targeted world position
  60275. */
  60276. agentGoto(index: number, destination: Vector3): void;
  60277. /**
  60278. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60279. * The queries will try to find a solution within those bounds
  60280. * default is (1,1,1)
  60281. * @param extent x,y,z value that define the extent around the queries point of reference
  60282. */
  60283. setDefaultQueryExtent(extent: Vector3): void;
  60284. /**
  60285. * Get the Bounding box extent specified by setDefaultQueryExtent
  60286. * @returns the box extent values
  60287. */
  60288. getDefaultQueryExtent(): Vector3;
  60289. /**
  60290. * Release all resources
  60291. */
  60292. dispose(): void;
  60293. }
  60294. /**
  60295. * Configures an agent
  60296. */
  60297. export interface IAgentParameters {
  60298. /**
  60299. * Agent radius. [Limit: >= 0]
  60300. */
  60301. radius: number;
  60302. /**
  60303. * Agent height. [Limit: > 0]
  60304. */
  60305. height: number;
  60306. /**
  60307. * Maximum allowed acceleration. [Limit: >= 0]
  60308. */
  60309. maxAcceleration: number;
  60310. /**
  60311. * Maximum allowed speed. [Limit: >= 0]
  60312. */
  60313. maxSpeed: number;
  60314. /**
  60315. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60316. */
  60317. collisionQueryRange: number;
  60318. /**
  60319. * The path visibility optimization range. [Limit: > 0]
  60320. */
  60321. pathOptimizationRange: number;
  60322. /**
  60323. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60324. */
  60325. separationWeight: number;
  60326. }
  60327. /**
  60328. * Configures the navigation mesh creation
  60329. */
  60330. export interface INavMeshParameters {
  60331. /**
  60332. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60333. */
  60334. cs: number;
  60335. /**
  60336. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60337. */
  60338. ch: number;
  60339. /**
  60340. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60341. */
  60342. walkableSlopeAngle: number;
  60343. /**
  60344. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60345. * be considered walkable. [Limit: >= 3] [Units: vx]
  60346. */
  60347. walkableHeight: number;
  60348. /**
  60349. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60350. */
  60351. walkableClimb: number;
  60352. /**
  60353. * The distance to erode/shrink the walkable area of the heightfield away from
  60354. * obstructions. [Limit: >=0] [Units: vx]
  60355. */
  60356. walkableRadius: number;
  60357. /**
  60358. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60359. */
  60360. maxEdgeLen: number;
  60361. /**
  60362. * The maximum distance a simplfied contour's border edges should deviate
  60363. * the original raw contour. [Limit: >=0] [Units: vx]
  60364. */
  60365. maxSimplificationError: number;
  60366. /**
  60367. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60368. */
  60369. minRegionArea: number;
  60370. /**
  60371. * Any regions with a span count smaller than this value will, if possible,
  60372. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60373. */
  60374. mergeRegionArea: number;
  60375. /**
  60376. * The maximum number of vertices allowed for polygons generated during the
  60377. * contour to polygon conversion process. [Limit: >= 3]
  60378. */
  60379. maxVertsPerPoly: number;
  60380. /**
  60381. * Sets the sampling distance to use when generating the detail mesh.
  60382. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60383. */
  60384. detailSampleDist: number;
  60385. /**
  60386. * The maximum distance the detail mesh surface should deviate from heightfield
  60387. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60388. */
  60389. detailSampleMaxError: number;
  60390. }
  60391. }
  60392. declare module BABYLON {
  60393. /**
  60394. * RecastJS navigation plugin
  60395. */
  60396. export class RecastJSPlugin implements INavigationEnginePlugin {
  60397. /**
  60398. * Reference to the Recast library
  60399. */
  60400. bjsRECAST: any;
  60401. /**
  60402. * plugin name
  60403. */
  60404. name: string;
  60405. /**
  60406. * the first navmesh created. We might extend this to support multiple navmeshes
  60407. */
  60408. navMesh: any;
  60409. /**
  60410. * Initializes the recastJS plugin
  60411. * @param recastInjection can be used to inject your own recast reference
  60412. */
  60413. constructor(recastInjection?: any);
  60414. /**
  60415. * Creates a navigation mesh
  60416. * @param meshes array of all the geometry used to compute the navigatio mesh
  60417. * @param parameters bunch of parameters used to filter geometry
  60418. */
  60419. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60420. /**
  60421. * Create a navigation mesh debug mesh
  60422. * @param scene is where the mesh will be added
  60423. * @returns debug display mesh
  60424. */
  60425. createDebugNavMesh(scene: Scene): Mesh;
  60426. /**
  60427. * Get a navigation mesh constrained position, closest to the parameter position
  60428. * @param position world position
  60429. * @returns the closest point to position constrained by the navigation mesh
  60430. */
  60431. getClosestPoint(position: Vector3): Vector3;
  60432. /**
  60433. * Get a navigation mesh constrained position, within a particular radius
  60434. * @param position world position
  60435. * @param maxRadius the maximum distance to the constrained world position
  60436. * @returns the closest point to position constrained by the navigation mesh
  60437. */
  60438. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60439. /**
  60440. * Compute the final position from a segment made of destination-position
  60441. * @param position world position
  60442. * @param destination world position
  60443. * @returns the resulting point along the navmesh
  60444. */
  60445. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60446. /**
  60447. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60448. * @param start world position
  60449. * @param end world position
  60450. * @returns array containing world position composing the path
  60451. */
  60452. computePath(start: Vector3, end: Vector3): Vector3[];
  60453. /**
  60454. * Create a new Crowd so you can add agents
  60455. * @param maxAgents the maximum agent count in the crowd
  60456. * @param maxAgentRadius the maximum radius an agent can have
  60457. * @param scene to attach the crowd to
  60458. * @returns the crowd you can add agents to
  60459. */
  60460. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60461. /**
  60462. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60463. * The queries will try to find a solution within those bounds
  60464. * default is (1,1,1)
  60465. * @param extent x,y,z value that define the extent around the queries point of reference
  60466. */
  60467. setDefaultQueryExtent(extent: Vector3): void;
  60468. /**
  60469. * Get the Bounding box extent specified by setDefaultQueryExtent
  60470. * @returns the box extent values
  60471. */
  60472. getDefaultQueryExtent(): Vector3;
  60473. /**
  60474. * Disposes
  60475. */
  60476. dispose(): void;
  60477. /**
  60478. * If this plugin is supported
  60479. * @returns true if plugin is supported
  60480. */
  60481. isSupported(): boolean;
  60482. }
  60483. /**
  60484. * Recast detour crowd implementation
  60485. */
  60486. export class RecastJSCrowd implements ICrowd {
  60487. /**
  60488. * Recast/detour plugin
  60489. */
  60490. bjsRECASTPlugin: RecastJSPlugin;
  60491. /**
  60492. * Link to the detour crowd
  60493. */
  60494. recastCrowd: any;
  60495. /**
  60496. * One transform per agent
  60497. */
  60498. transforms: TransformNode[];
  60499. /**
  60500. * All agents created
  60501. */
  60502. agents: number[];
  60503. /**
  60504. * Link to the scene is kept to unregister the crowd from the scene
  60505. */
  60506. private _scene;
  60507. /**
  60508. * Observer for crowd updates
  60509. */
  60510. private _onBeforeAnimationsObserver;
  60511. /**
  60512. * Constructor
  60513. * @param plugin recastJS plugin
  60514. * @param maxAgents the maximum agent count in the crowd
  60515. * @param maxAgentRadius the maximum radius an agent can have
  60516. * @param scene to attach the crowd to
  60517. * @returns the crowd you can add agents to
  60518. */
  60519. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60520. /**
  60521. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60522. * You can attach anything to that node. The node position is updated in the scene update tick.
  60523. * @param pos world position that will be constrained by the navigation mesh
  60524. * @param parameters agent parameters
  60525. * @param transform hooked to the agent that will be update by the scene
  60526. * @returns agent index
  60527. */
  60528. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60529. /**
  60530. * Returns the agent position in world space
  60531. * @param index agent index returned by addAgent
  60532. * @returns world space position
  60533. */
  60534. getAgentPosition(index: number): Vector3;
  60535. /**
  60536. * Returns the agent velocity in world space
  60537. * @param index agent index returned by addAgent
  60538. * @returns world space velocity
  60539. */
  60540. getAgentVelocity(index: number): Vector3;
  60541. /**
  60542. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60543. * @param index agent index returned by addAgent
  60544. * @param destination targeted world position
  60545. */
  60546. agentGoto(index: number, destination: Vector3): void;
  60547. /**
  60548. * remove a particular agent previously created
  60549. * @param index agent index returned by addAgent
  60550. */
  60551. removeAgent(index: number): void;
  60552. /**
  60553. * get the list of all agents attached to this crowd
  60554. * @returns list of agent indices
  60555. */
  60556. getAgents(): number[];
  60557. /**
  60558. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60559. * @param deltaTime in seconds
  60560. */
  60561. update(deltaTime: number): void;
  60562. /**
  60563. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60564. * The queries will try to find a solution within those bounds
  60565. * default is (1,1,1)
  60566. * @param extent x,y,z value that define the extent around the queries point of reference
  60567. */
  60568. setDefaultQueryExtent(extent: Vector3): void;
  60569. /**
  60570. * Get the Bounding box extent specified by setDefaultQueryExtent
  60571. * @returns the box extent values
  60572. */
  60573. getDefaultQueryExtent(): Vector3;
  60574. /**
  60575. * Release all resources
  60576. */
  60577. dispose(): void;
  60578. }
  60579. }
  60580. declare module BABYLON {
  60581. /**
  60582. * Class used to enable access to IndexedDB
  60583. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60584. */
  60585. export class Database implements IOfflineProvider {
  60586. private _callbackManifestChecked;
  60587. private _currentSceneUrl;
  60588. private _db;
  60589. private _enableSceneOffline;
  60590. private _enableTexturesOffline;
  60591. private _manifestVersionFound;
  60592. private _mustUpdateRessources;
  60593. private _hasReachedQuota;
  60594. private _isSupported;
  60595. private _idbFactory;
  60596. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60597. private static IsUASupportingBlobStorage;
  60598. /**
  60599. * Gets a boolean indicating if Database storate is enabled (off by default)
  60600. */
  60601. static IDBStorageEnabled: boolean;
  60602. /**
  60603. * Gets a boolean indicating if scene must be saved in the database
  60604. */
  60605. get enableSceneOffline(): boolean;
  60606. /**
  60607. * Gets a boolean indicating if textures must be saved in the database
  60608. */
  60609. get enableTexturesOffline(): boolean;
  60610. /**
  60611. * Creates a new Database
  60612. * @param urlToScene defines the url to load the scene
  60613. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60614. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60615. */
  60616. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60617. private static _ParseURL;
  60618. private static _ReturnFullUrlLocation;
  60619. private _checkManifestFile;
  60620. /**
  60621. * Open the database and make it available
  60622. * @param successCallback defines the callback to call on success
  60623. * @param errorCallback defines the callback to call on error
  60624. */
  60625. open(successCallback: () => void, errorCallback: () => void): void;
  60626. /**
  60627. * Loads an image from the database
  60628. * @param url defines the url to load from
  60629. * @param image defines the target DOM image
  60630. */
  60631. loadImage(url: string, image: HTMLImageElement): void;
  60632. private _loadImageFromDBAsync;
  60633. private _saveImageIntoDBAsync;
  60634. private _checkVersionFromDB;
  60635. private _loadVersionFromDBAsync;
  60636. private _saveVersionIntoDBAsync;
  60637. /**
  60638. * Loads a file from database
  60639. * @param url defines the URL to load from
  60640. * @param sceneLoaded defines a callback to call on success
  60641. * @param progressCallBack defines a callback to call when progress changed
  60642. * @param errorCallback defines a callback to call on error
  60643. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60644. */
  60645. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60646. private _loadFileAsync;
  60647. private _saveFileAsync;
  60648. /**
  60649. * Validates if xhr data is correct
  60650. * @param xhr defines the request to validate
  60651. * @param dataType defines the expected data type
  60652. * @returns true if data is correct
  60653. */
  60654. private static _ValidateXHRData;
  60655. }
  60656. }
  60657. declare module BABYLON {
  60658. /** @hidden */
  60659. export var gpuUpdateParticlesPixelShader: {
  60660. name: string;
  60661. shader: string;
  60662. };
  60663. }
  60664. declare module BABYLON {
  60665. /** @hidden */
  60666. export var gpuUpdateParticlesVertexShader: {
  60667. name: string;
  60668. shader: string;
  60669. };
  60670. }
  60671. declare module BABYLON {
  60672. /** @hidden */
  60673. export var clipPlaneFragmentDeclaration2: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module BABYLON {
  60679. /** @hidden */
  60680. export var gpuRenderParticlesPixelShader: {
  60681. name: string;
  60682. shader: string;
  60683. };
  60684. }
  60685. declare module BABYLON {
  60686. /** @hidden */
  60687. export var clipPlaneVertexDeclaration2: {
  60688. name: string;
  60689. shader: string;
  60690. };
  60691. }
  60692. declare module BABYLON {
  60693. /** @hidden */
  60694. export var gpuRenderParticlesVertexShader: {
  60695. name: string;
  60696. shader: string;
  60697. };
  60698. }
  60699. declare module BABYLON {
  60700. /**
  60701. * This represents a GPU particle system in Babylon
  60702. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60703. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60704. */
  60705. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60706. /**
  60707. * The layer mask we are rendering the particles through.
  60708. */
  60709. layerMask: number;
  60710. private _capacity;
  60711. private _activeCount;
  60712. private _currentActiveCount;
  60713. private _accumulatedCount;
  60714. private _renderEffect;
  60715. private _updateEffect;
  60716. private _buffer0;
  60717. private _buffer1;
  60718. private _spriteBuffer;
  60719. private _updateVAO;
  60720. private _renderVAO;
  60721. private _targetIndex;
  60722. private _sourceBuffer;
  60723. private _targetBuffer;
  60724. private _engine;
  60725. private _currentRenderId;
  60726. private _started;
  60727. private _stopped;
  60728. private _timeDelta;
  60729. private _randomTexture;
  60730. private _randomTexture2;
  60731. private _attributesStrideSize;
  60732. private _updateEffectOptions;
  60733. private _randomTextureSize;
  60734. private _actualFrame;
  60735. private readonly _rawTextureWidth;
  60736. /**
  60737. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60738. */
  60739. static get IsSupported(): boolean;
  60740. /**
  60741. * An event triggered when the system is disposed.
  60742. */
  60743. onDisposeObservable: Observable<GPUParticleSystem>;
  60744. /**
  60745. * Gets the maximum number of particles active at the same time.
  60746. * @returns The max number of active particles.
  60747. */
  60748. getCapacity(): number;
  60749. /**
  60750. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60751. * to override the particles.
  60752. */
  60753. forceDepthWrite: boolean;
  60754. /**
  60755. * Gets or set the number of active particles
  60756. */
  60757. get activeParticleCount(): number;
  60758. set activeParticleCount(value: number);
  60759. private _preWarmDone;
  60760. /**
  60761. * Is this system ready to be used/rendered
  60762. * @return true if the system is ready
  60763. */
  60764. isReady(): boolean;
  60765. /**
  60766. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60767. * @returns True if it has been started, otherwise false.
  60768. */
  60769. isStarted(): boolean;
  60770. /**
  60771. * Starts the particle system and begins to emit
  60772. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60773. */
  60774. start(delay?: number): void;
  60775. /**
  60776. * Stops the particle system.
  60777. */
  60778. stop(): void;
  60779. /**
  60780. * Remove all active particles
  60781. */
  60782. reset(): void;
  60783. /**
  60784. * Returns the string "GPUParticleSystem"
  60785. * @returns a string containing the class name
  60786. */
  60787. getClassName(): string;
  60788. private _colorGradientsTexture;
  60789. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60790. /**
  60791. * Adds a new color gradient
  60792. * @param gradient defines the gradient to use (between 0 and 1)
  60793. * @param color1 defines the color to affect to the specified gradient
  60794. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60795. * @returns the current particle system
  60796. */
  60797. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60798. /**
  60799. * Remove a specific color gradient
  60800. * @param gradient defines the gradient to remove
  60801. * @returns the current particle system
  60802. */
  60803. removeColorGradient(gradient: number): GPUParticleSystem;
  60804. private _angularSpeedGradientsTexture;
  60805. private _sizeGradientsTexture;
  60806. private _velocityGradientsTexture;
  60807. private _limitVelocityGradientsTexture;
  60808. private _dragGradientsTexture;
  60809. private _addFactorGradient;
  60810. /**
  60811. * Adds a new size gradient
  60812. * @param gradient defines the gradient to use (between 0 and 1)
  60813. * @param factor defines the size factor to affect to the specified gradient
  60814. * @returns the current particle system
  60815. */
  60816. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60817. /**
  60818. * Remove a specific size gradient
  60819. * @param gradient defines the gradient to remove
  60820. * @returns the current particle system
  60821. */
  60822. removeSizeGradient(gradient: number): GPUParticleSystem;
  60823. /**
  60824. * Adds a new angular speed gradient
  60825. * @param gradient defines the gradient to use (between 0 and 1)
  60826. * @param factor defines the angular speed to affect to the specified gradient
  60827. * @returns the current particle system
  60828. */
  60829. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60830. /**
  60831. * Remove a specific angular speed gradient
  60832. * @param gradient defines the gradient to remove
  60833. * @returns the current particle system
  60834. */
  60835. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60836. /**
  60837. * Adds a new velocity gradient
  60838. * @param gradient defines the gradient to use (between 0 and 1)
  60839. * @param factor defines the velocity to affect to the specified gradient
  60840. * @returns the current particle system
  60841. */
  60842. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60843. /**
  60844. * Remove a specific velocity gradient
  60845. * @param gradient defines the gradient to remove
  60846. * @returns the current particle system
  60847. */
  60848. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60849. /**
  60850. * Adds a new limit velocity gradient
  60851. * @param gradient defines the gradient to use (between 0 and 1)
  60852. * @param factor defines the limit velocity value to affect to the specified gradient
  60853. * @returns the current particle system
  60854. */
  60855. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60856. /**
  60857. * Remove a specific limit velocity gradient
  60858. * @param gradient defines the gradient to remove
  60859. * @returns the current particle system
  60860. */
  60861. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60862. /**
  60863. * Adds a new drag gradient
  60864. * @param gradient defines the gradient to use (between 0 and 1)
  60865. * @param factor defines the drag value to affect to the specified gradient
  60866. * @returns the current particle system
  60867. */
  60868. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60869. /**
  60870. * Remove a specific drag gradient
  60871. * @param gradient defines the gradient to remove
  60872. * @returns the current particle system
  60873. */
  60874. removeDragGradient(gradient: number): GPUParticleSystem;
  60875. /**
  60876. * Not supported by GPUParticleSystem
  60877. * @param gradient defines the gradient to use (between 0 and 1)
  60878. * @param factor defines the emit rate value to affect to the specified gradient
  60879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60880. * @returns the current particle system
  60881. */
  60882. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60883. /**
  60884. * Not supported by GPUParticleSystem
  60885. * @param gradient defines the gradient to remove
  60886. * @returns the current particle system
  60887. */
  60888. removeEmitRateGradient(gradient: number): IParticleSystem;
  60889. /**
  60890. * Not supported by GPUParticleSystem
  60891. * @param gradient defines the gradient to use (between 0 and 1)
  60892. * @param factor defines the start size value to affect to the specified gradient
  60893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60894. * @returns the current particle system
  60895. */
  60896. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60897. /**
  60898. * Not supported by GPUParticleSystem
  60899. * @param gradient defines the gradient to remove
  60900. * @returns the current particle system
  60901. */
  60902. removeStartSizeGradient(gradient: number): IParticleSystem;
  60903. /**
  60904. * Not supported by GPUParticleSystem
  60905. * @param gradient defines the gradient to use (between 0 and 1)
  60906. * @param min defines the color remap minimal range
  60907. * @param max defines the color remap maximal range
  60908. * @returns the current particle system
  60909. */
  60910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60911. /**
  60912. * Not supported by GPUParticleSystem
  60913. * @param gradient defines the gradient to remove
  60914. * @returns the current particle system
  60915. */
  60916. removeColorRemapGradient(): IParticleSystem;
  60917. /**
  60918. * Not supported by GPUParticleSystem
  60919. * @param gradient defines the gradient to use (between 0 and 1)
  60920. * @param min defines the alpha remap minimal range
  60921. * @param max defines the alpha remap maximal range
  60922. * @returns the current particle system
  60923. */
  60924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60925. /**
  60926. * Not supported by GPUParticleSystem
  60927. * @param gradient defines the gradient to remove
  60928. * @returns the current particle system
  60929. */
  60930. removeAlphaRemapGradient(): IParticleSystem;
  60931. /**
  60932. * Not supported by GPUParticleSystem
  60933. * @param gradient defines the gradient to use (between 0 and 1)
  60934. * @param color defines the color to affect to the specified gradient
  60935. * @returns the current particle system
  60936. */
  60937. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60938. /**
  60939. * Not supported by GPUParticleSystem
  60940. * @param gradient defines the gradient to remove
  60941. * @returns the current particle system
  60942. */
  60943. removeRampGradient(): IParticleSystem;
  60944. /**
  60945. * Not supported by GPUParticleSystem
  60946. * @returns the list of ramp gradients
  60947. */
  60948. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60949. /**
  60950. * Not supported by GPUParticleSystem
  60951. * Gets or sets a boolean indicating that ramp gradients must be used
  60952. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60953. */
  60954. get useRampGradients(): boolean;
  60955. set useRampGradients(value: boolean);
  60956. /**
  60957. * Not supported by GPUParticleSystem
  60958. * @param gradient defines the gradient to use (between 0 and 1)
  60959. * @param factor defines the life time factor to affect to the specified gradient
  60960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60961. * @returns the current particle system
  60962. */
  60963. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60964. /**
  60965. * Not supported by GPUParticleSystem
  60966. * @param gradient defines the gradient to remove
  60967. * @returns the current particle system
  60968. */
  60969. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60970. /**
  60971. * Instantiates a GPU particle system.
  60972. * 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.
  60973. * @param name The name of the particle system
  60974. * @param options The options used to create the system
  60975. * @param scene The scene the particle system belongs to
  60976. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60977. */
  60978. constructor(name: string, options: Partial<{
  60979. capacity: number;
  60980. randomTextureSize: number;
  60981. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60982. protected _reset(): void;
  60983. private _createUpdateVAO;
  60984. private _createRenderVAO;
  60985. private _initialize;
  60986. /** @hidden */
  60987. _recreateUpdateEffect(): void;
  60988. /** @hidden */
  60989. _recreateRenderEffect(): void;
  60990. /**
  60991. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60992. * @param preWarm defines if we are in the pre-warmimg phase
  60993. */
  60994. animate(preWarm?: boolean): void;
  60995. private _createFactorGradientTexture;
  60996. private _createSizeGradientTexture;
  60997. private _createAngularSpeedGradientTexture;
  60998. private _createVelocityGradientTexture;
  60999. private _createLimitVelocityGradientTexture;
  61000. private _createDragGradientTexture;
  61001. private _createColorGradientTexture;
  61002. /**
  61003. * Renders the particle system in its current state
  61004. * @param preWarm defines if the system should only update the particles but not render them
  61005. * @returns the current number of particles
  61006. */
  61007. render(preWarm?: boolean): number;
  61008. /**
  61009. * Rebuilds the particle system
  61010. */
  61011. rebuild(): void;
  61012. private _releaseBuffers;
  61013. private _releaseVAOs;
  61014. /**
  61015. * Disposes the particle system and free the associated resources
  61016. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61017. */
  61018. dispose(disposeTexture?: boolean): void;
  61019. /**
  61020. * Clones the particle system.
  61021. * @param name The name of the cloned object
  61022. * @param newEmitter The new emitter to use
  61023. * @returns the cloned particle system
  61024. */
  61025. clone(name: string, newEmitter: any): GPUParticleSystem;
  61026. /**
  61027. * Serializes the particle system to a JSON object.
  61028. * @returns the JSON object
  61029. */
  61030. serialize(): any;
  61031. /**
  61032. * Parses a JSON object to create a GPU particle system.
  61033. * @param parsedParticleSystem The JSON object to parse
  61034. * @param scene The scene to create the particle system in
  61035. * @param rootUrl The root url to use to load external dependencies like texture
  61036. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61037. * @returns the parsed GPU particle system
  61038. */
  61039. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /**
  61044. * Represents a set of particle systems working together to create a specific effect
  61045. */
  61046. export class ParticleSystemSet implements IDisposable {
  61047. /**
  61048. * Gets or sets base Assets URL
  61049. */
  61050. static BaseAssetsUrl: string;
  61051. private _emitterCreationOptions;
  61052. private _emitterNode;
  61053. /**
  61054. * Gets the particle system list
  61055. */
  61056. systems: IParticleSystem[];
  61057. /**
  61058. * Gets the emitter node used with this set
  61059. */
  61060. get emitterNode(): Nullable<TransformNode>;
  61061. /**
  61062. * Creates a new emitter mesh as a sphere
  61063. * @param options defines the options used to create the sphere
  61064. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61065. * @param scene defines the hosting scene
  61066. */
  61067. setEmitterAsSphere(options: {
  61068. diameter: number;
  61069. segments: number;
  61070. color: Color3;
  61071. }, renderingGroupId: number, scene: Scene): void;
  61072. /**
  61073. * Starts all particle systems of the set
  61074. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61075. */
  61076. start(emitter?: AbstractMesh): void;
  61077. /**
  61078. * Release all associated resources
  61079. */
  61080. dispose(): void;
  61081. /**
  61082. * Serialize the set into a JSON compatible object
  61083. * @returns a JSON compatible representation of the set
  61084. */
  61085. serialize(): any;
  61086. /**
  61087. * Parse a new ParticleSystemSet from a serialized source
  61088. * @param data defines a JSON compatible representation of the set
  61089. * @param scene defines the hosting scene
  61090. * @param gpu defines if we want GPU particles or CPU particles
  61091. * @returns a new ParticleSystemSet
  61092. */
  61093. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61094. }
  61095. }
  61096. declare module BABYLON {
  61097. /**
  61098. * This class is made for on one-liner static method to help creating particle system set.
  61099. */
  61100. export class ParticleHelper {
  61101. /**
  61102. * Gets or sets base Assets URL
  61103. */
  61104. static BaseAssetsUrl: string;
  61105. /**
  61106. * Create a default particle system that you can tweak
  61107. * @param emitter defines the emitter to use
  61108. * @param capacity defines the system capacity (default is 500 particles)
  61109. * @param scene defines the hosting scene
  61110. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61111. * @returns the new Particle system
  61112. */
  61113. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61114. /**
  61115. * This is the main static method (one-liner) of this helper to create different particle systems
  61116. * @param type This string represents the type to the particle system to create
  61117. * @param scene The scene where the particle system should live
  61118. * @param gpu If the system will use gpu
  61119. * @returns the ParticleSystemSet created
  61120. */
  61121. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61122. /**
  61123. * Static function used to export a particle system to a ParticleSystemSet variable.
  61124. * Please note that the emitter shape is not exported
  61125. * @param systems defines the particle systems to export
  61126. * @returns the created particle system set
  61127. */
  61128. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61129. }
  61130. }
  61131. declare module BABYLON {
  61132. interface Engine {
  61133. /**
  61134. * Create an effect to use with particle systems.
  61135. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61136. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61137. * @param uniformsNames defines a list of attribute names
  61138. * @param samplers defines an array of string used to represent textures
  61139. * @param defines defines the string containing the defines to use to compile the shaders
  61140. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61141. * @param onCompiled defines a function to call when the effect creation is successful
  61142. * @param onError defines a function to call when the effect creation has failed
  61143. * @returns the new Effect
  61144. */
  61145. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61146. }
  61147. interface Mesh {
  61148. /**
  61149. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61150. * @returns an array of IParticleSystem
  61151. */
  61152. getEmittedParticleSystems(): IParticleSystem[];
  61153. /**
  61154. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61155. * @returns an array of IParticleSystem
  61156. */
  61157. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61158. }
  61159. /**
  61160. * @hidden
  61161. */
  61162. export var _IDoNeedToBeInTheBuild: number;
  61163. }
  61164. declare module BABYLON {
  61165. /** Defines the 4 color options */
  61166. export enum PointColor {
  61167. /** color value */
  61168. Color = 2,
  61169. /** uv value */
  61170. UV = 1,
  61171. /** random value */
  61172. Random = 0,
  61173. /** stated value */
  61174. Stated = 3
  61175. }
  61176. /**
  61177. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61178. * 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.
  61179. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61180. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61181. *
  61182. * Full documentation here : TO BE ENTERED
  61183. */
  61184. export class PointsCloudSystem implements IDisposable {
  61185. /**
  61186. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61187. * Example : var p = SPS.particles[i];
  61188. */
  61189. particles: CloudPoint[];
  61190. /**
  61191. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61192. */
  61193. nbParticles: number;
  61194. /**
  61195. * This a counter for your own usage. It's not set by any SPS functions.
  61196. */
  61197. counter: number;
  61198. /**
  61199. * The PCS name. This name is also given to the underlying mesh.
  61200. */
  61201. name: string;
  61202. /**
  61203. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61204. */
  61205. mesh: Mesh;
  61206. /**
  61207. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61208. * Please read :
  61209. */
  61210. vars: any;
  61211. /**
  61212. * @hidden
  61213. */
  61214. _size: number;
  61215. private _scene;
  61216. private _promises;
  61217. private _positions;
  61218. private _indices;
  61219. private _normals;
  61220. private _colors;
  61221. private _uvs;
  61222. private _indices32;
  61223. private _positions32;
  61224. private _colors32;
  61225. private _uvs32;
  61226. private _updatable;
  61227. private _isVisibilityBoxLocked;
  61228. private _alwaysVisible;
  61229. private _groups;
  61230. private _groupCounter;
  61231. private _computeParticleColor;
  61232. private _computeParticleTexture;
  61233. private _computeParticleRotation;
  61234. private _computeBoundingBox;
  61235. private _isReady;
  61236. /**
  61237. * Creates a PCS (Points Cloud System) object
  61238. * @param name (String) is the PCS name, this will be the underlying mesh name
  61239. * @param pointSize (number) is the size for each point
  61240. * @param scene (Scene) is the scene in which the PCS is added
  61241. * @param options defines the options of the PCS e.g.
  61242. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61243. */
  61244. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61245. updatable?: boolean;
  61246. });
  61247. /**
  61248. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61249. * If no points were added to the PCS, the returned mesh is just a single point.
  61250. * @returns a promise for the created mesh
  61251. */
  61252. buildMeshAsync(): Promise<Mesh>;
  61253. /**
  61254. * @hidden
  61255. */
  61256. private _buildMesh;
  61257. private _addParticle;
  61258. private _randomUnitVector;
  61259. private _getColorIndicesForCoord;
  61260. private _setPointsColorOrUV;
  61261. private _colorFromTexture;
  61262. private _calculateDensity;
  61263. /**
  61264. * Adds points to the PCS in random positions within a unit sphere
  61265. * @param nb (positive integer) the number of particles to be created from this model
  61266. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61267. * @returns the number of groups in the system
  61268. */
  61269. addPoints(nb: number, pointFunction?: any): number;
  61270. /**
  61271. * Adds points to the PCS from the surface of the model shape
  61272. * @param mesh is any Mesh object that will be used as a surface model for the points
  61273. * @param nb (positive integer) the number of particles to be created from this model
  61274. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61275. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61276. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61277. * @returns the number of groups in the system
  61278. */
  61279. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61280. /**
  61281. * Adds points to the PCS inside the model shape
  61282. * @param mesh is any Mesh object that will be used as a surface model for the points
  61283. * @param nb (positive integer) the number of particles to be created from this model
  61284. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61285. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61286. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61287. * @returns the number of groups in the system
  61288. */
  61289. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61290. /**
  61291. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61292. * This method calls `updateParticle()` for each particle of the SPS.
  61293. * For an animated SPS, it is usually called within the render loop.
  61294. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61295. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61296. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61297. * @returns the PCS.
  61298. */
  61299. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61300. /**
  61301. * Disposes the PCS.
  61302. */
  61303. dispose(): void;
  61304. /**
  61305. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61306. * doc :
  61307. * @returns the PCS.
  61308. */
  61309. refreshVisibleSize(): PointsCloudSystem;
  61310. /**
  61311. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61312. * @param size the size (float) of the visibility box
  61313. * note : this doesn't lock the PCS mesh bounding box.
  61314. * doc :
  61315. */
  61316. setVisibilityBox(size: number): void;
  61317. /**
  61318. * Gets whether the PCS is always visible or not
  61319. * doc :
  61320. */
  61321. get isAlwaysVisible(): boolean;
  61322. /**
  61323. * Sets the PCS as always visible or not
  61324. * doc :
  61325. */
  61326. set isAlwaysVisible(val: boolean);
  61327. /**
  61328. * Tells to `setParticles()` to compute the particle rotations or not
  61329. * Default value : false. The PCS is faster when it's set to false
  61330. * Note : particle rotations are only applied to parent particles
  61331. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61332. */
  61333. set computeParticleRotation(val: boolean);
  61334. /**
  61335. * Tells to `setParticles()` to compute the particle colors or not.
  61336. * Default value : true. The PCS is faster when it's set to false.
  61337. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61338. */
  61339. set computeParticleColor(val: boolean);
  61340. set computeParticleTexture(val: boolean);
  61341. /**
  61342. * Gets if `setParticles()` computes the particle colors or not.
  61343. * Default value : false. The PCS is faster when it's set to false.
  61344. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61345. */
  61346. get computeParticleColor(): boolean;
  61347. /**
  61348. * Gets if `setParticles()` computes the particle textures or not.
  61349. * Default value : false. The PCS is faster when it's set to false.
  61350. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61351. */
  61352. get computeParticleTexture(): boolean;
  61353. /**
  61354. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61355. */
  61356. set computeBoundingBox(val: boolean);
  61357. /**
  61358. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61359. */
  61360. get computeBoundingBox(): boolean;
  61361. /**
  61362. * This function does nothing. It may be overwritten to set all the particle first values.
  61363. * The PCS doesn't call this function, you may have to call it by your own.
  61364. * doc :
  61365. */
  61366. initParticles(): void;
  61367. /**
  61368. * This function does nothing. It may be overwritten to recycle a particle
  61369. * The PCS doesn't call this function, you can to call it
  61370. * doc :
  61371. * @param particle The particle to recycle
  61372. * @returns the recycled particle
  61373. */
  61374. recycleParticle(particle: CloudPoint): CloudPoint;
  61375. /**
  61376. * Updates a particle : this function should be overwritten by the user.
  61377. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61378. * doc :
  61379. * @example : just set a particle position or velocity and recycle conditions
  61380. * @param particle The particle to update
  61381. * @returns the updated particle
  61382. */
  61383. updateParticle(particle: CloudPoint): CloudPoint;
  61384. /**
  61385. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61386. * This does nothing and may be overwritten by the user.
  61387. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61388. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61389. * @param update the boolean update value actually passed to setParticles()
  61390. */
  61391. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61392. /**
  61393. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61394. * This will be passed three parameters.
  61395. * This does nothing and may be overwritten by the user.
  61396. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61398. * @param update the boolean update value actually passed to setParticles()
  61399. */
  61400. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61401. }
  61402. }
  61403. declare module BABYLON {
  61404. /**
  61405. * Represents one particle of a points cloud system.
  61406. */
  61407. export class CloudPoint {
  61408. /**
  61409. * particle global index
  61410. */
  61411. idx: number;
  61412. /**
  61413. * The color of the particle
  61414. */
  61415. color: Nullable<Color4>;
  61416. /**
  61417. * The world space position of the particle.
  61418. */
  61419. position: Vector3;
  61420. /**
  61421. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61422. */
  61423. rotation: Vector3;
  61424. /**
  61425. * The world space rotation quaternion of the particle.
  61426. */
  61427. rotationQuaternion: Nullable<Quaternion>;
  61428. /**
  61429. * The uv of the particle.
  61430. */
  61431. uv: Nullable<Vector2>;
  61432. /**
  61433. * The current speed of the particle.
  61434. */
  61435. velocity: Vector3;
  61436. /**
  61437. * The pivot point in the particle local space.
  61438. */
  61439. pivot: Vector3;
  61440. /**
  61441. * Must the particle be translated from its pivot point in its local space ?
  61442. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61443. * Default : false
  61444. */
  61445. translateFromPivot: boolean;
  61446. /**
  61447. * Index of this particle in the global "positions" array (Internal use)
  61448. * @hidden
  61449. */
  61450. _pos: number;
  61451. /**
  61452. * @hidden Index of this particle in the global "indices" array (Internal use)
  61453. */
  61454. _ind: number;
  61455. /**
  61456. * Group this particle belongs to
  61457. */
  61458. _group: PointsGroup;
  61459. /**
  61460. * Group id of this particle
  61461. */
  61462. groupId: number;
  61463. /**
  61464. * Index of the particle in its group id (Internal use)
  61465. */
  61466. idxInGroup: number;
  61467. /**
  61468. * @hidden Particle BoundingInfo object (Internal use)
  61469. */
  61470. _boundingInfo: BoundingInfo;
  61471. /**
  61472. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61473. */
  61474. _pcs: PointsCloudSystem;
  61475. /**
  61476. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61477. */
  61478. _stillInvisible: boolean;
  61479. /**
  61480. * @hidden Last computed particle rotation matrix
  61481. */
  61482. _rotationMatrix: number[];
  61483. /**
  61484. * Parent particle Id, if any.
  61485. * Default null.
  61486. */
  61487. parentId: Nullable<number>;
  61488. /**
  61489. * @hidden Internal global position in the PCS.
  61490. */
  61491. _globalPosition: Vector3;
  61492. /**
  61493. * Creates a Point Cloud object.
  61494. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61495. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61496. * @param group (PointsGroup) is the group the particle belongs to
  61497. * @param groupId (integer) is the group identifier in the PCS.
  61498. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61499. * @param pcs defines the PCS it is associated to
  61500. */
  61501. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61502. /**
  61503. * get point size
  61504. */
  61505. get size(): Vector3;
  61506. /**
  61507. * Set point size
  61508. */
  61509. set size(scale: Vector3);
  61510. /**
  61511. * Legacy support, changed quaternion to rotationQuaternion
  61512. */
  61513. get quaternion(): Nullable<Quaternion>;
  61514. /**
  61515. * Legacy support, changed quaternion to rotationQuaternion
  61516. */
  61517. set quaternion(q: Nullable<Quaternion>);
  61518. /**
  61519. * Returns a boolean. True if the particle intersects a mesh, else false
  61520. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61521. * @param target is the object (point or mesh) what the intersection is computed against
  61522. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61523. * @returns true if it intersects
  61524. */
  61525. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61526. /**
  61527. * get the rotation matrix of the particle
  61528. * @hidden
  61529. */
  61530. getRotationMatrix(m: Matrix): void;
  61531. }
  61532. /**
  61533. * Represents a group of points in a points cloud system
  61534. * * PCS internal tool, don't use it manually.
  61535. */
  61536. export class PointsGroup {
  61537. /**
  61538. * The group id
  61539. * @hidden
  61540. */
  61541. groupID: number;
  61542. /**
  61543. * image data for group (internal use)
  61544. * @hidden
  61545. */
  61546. _groupImageData: Nullable<ArrayBufferView>;
  61547. /**
  61548. * Image Width (internal use)
  61549. * @hidden
  61550. */
  61551. _groupImgWidth: number;
  61552. /**
  61553. * Image Height (internal use)
  61554. * @hidden
  61555. */
  61556. _groupImgHeight: number;
  61557. /**
  61558. * Custom position function (internal use)
  61559. * @hidden
  61560. */
  61561. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61562. /**
  61563. * density per facet for surface points
  61564. * @hidden
  61565. */
  61566. _groupDensity: number[];
  61567. /**
  61568. * Only when points are colored by texture carries pointer to texture list array
  61569. * @hidden
  61570. */
  61571. _textureNb: number;
  61572. /**
  61573. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61574. * PCS internal tool, don't use it manually.
  61575. * @hidden
  61576. */
  61577. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61578. }
  61579. }
  61580. declare module BABYLON {
  61581. interface Scene {
  61582. /** @hidden (Backing field) */
  61583. _physicsEngine: Nullable<IPhysicsEngine>;
  61584. /** @hidden */
  61585. _physicsTimeAccumulator: number;
  61586. /**
  61587. * Gets the current physics engine
  61588. * @returns a IPhysicsEngine or null if none attached
  61589. */
  61590. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61591. /**
  61592. * Enables physics to the current scene
  61593. * @param gravity defines the scene's gravity for the physics engine
  61594. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61595. * @return a boolean indicating if the physics engine was initialized
  61596. */
  61597. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61598. /**
  61599. * Disables and disposes the physics engine associated with the scene
  61600. */
  61601. disablePhysicsEngine(): void;
  61602. /**
  61603. * Gets a boolean indicating if there is an active physics engine
  61604. * @returns a boolean indicating if there is an active physics engine
  61605. */
  61606. isPhysicsEnabled(): boolean;
  61607. /**
  61608. * Deletes a physics compound impostor
  61609. * @param compound defines the compound to delete
  61610. */
  61611. deleteCompoundImpostor(compound: any): void;
  61612. /**
  61613. * An event triggered when physic simulation is about to be run
  61614. */
  61615. onBeforePhysicsObservable: Observable<Scene>;
  61616. /**
  61617. * An event triggered when physic simulation has been done
  61618. */
  61619. onAfterPhysicsObservable: Observable<Scene>;
  61620. }
  61621. interface AbstractMesh {
  61622. /** @hidden */
  61623. _physicsImpostor: Nullable<PhysicsImpostor>;
  61624. /**
  61625. * Gets or sets impostor used for physic simulation
  61626. * @see http://doc.babylonjs.com/features/physics_engine
  61627. */
  61628. physicsImpostor: Nullable<PhysicsImpostor>;
  61629. /**
  61630. * Gets the current physics impostor
  61631. * @see http://doc.babylonjs.com/features/physics_engine
  61632. * @returns a physics impostor or null
  61633. */
  61634. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61635. /** Apply a physic impulse to the mesh
  61636. * @param force defines the force to apply
  61637. * @param contactPoint defines where to apply the force
  61638. * @returns the current mesh
  61639. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61640. */
  61641. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61642. /**
  61643. * Creates a physic joint between two meshes
  61644. * @param otherMesh defines the other mesh to use
  61645. * @param pivot1 defines the pivot to use on this mesh
  61646. * @param pivot2 defines the pivot to use on the other mesh
  61647. * @param options defines additional options (can be plugin dependent)
  61648. * @returns the current mesh
  61649. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61650. */
  61651. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61652. /** @hidden */
  61653. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61654. }
  61655. /**
  61656. * Defines the physics engine scene component responsible to manage a physics engine
  61657. */
  61658. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61659. /**
  61660. * The component name helpful to identify the component in the list of scene components.
  61661. */
  61662. readonly name: string;
  61663. /**
  61664. * The scene the component belongs to.
  61665. */
  61666. scene: Scene;
  61667. /**
  61668. * Creates a new instance of the component for the given scene
  61669. * @param scene Defines the scene to register the component in
  61670. */
  61671. constructor(scene: Scene);
  61672. /**
  61673. * Registers the component in a given scene
  61674. */
  61675. register(): void;
  61676. /**
  61677. * Rebuilds the elements related to this component in case of
  61678. * context lost for instance.
  61679. */
  61680. rebuild(): void;
  61681. /**
  61682. * Disposes the component and the associated ressources
  61683. */
  61684. dispose(): void;
  61685. }
  61686. }
  61687. declare module BABYLON {
  61688. /**
  61689. * A helper for physics simulations
  61690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61691. */
  61692. export class PhysicsHelper {
  61693. private _scene;
  61694. private _physicsEngine;
  61695. /**
  61696. * Initializes the Physics helper
  61697. * @param scene Babylon.js scene
  61698. */
  61699. constructor(scene: Scene);
  61700. /**
  61701. * Applies a radial explosion impulse
  61702. * @param origin the origin of the explosion
  61703. * @param radiusOrEventOptions the radius or the options of radial explosion
  61704. * @param strength the explosion strength
  61705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61706. * @returns A physics radial explosion event, or null
  61707. */
  61708. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61709. /**
  61710. * Applies a radial explosion force
  61711. * @param origin the origin of the explosion
  61712. * @param radiusOrEventOptions the radius or the options of radial explosion
  61713. * @param strength the explosion strength
  61714. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61715. * @returns A physics radial explosion event, or null
  61716. */
  61717. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61718. /**
  61719. * Creates a gravitational field
  61720. * @param origin the origin of the explosion
  61721. * @param radiusOrEventOptions the radius or the options of radial explosion
  61722. * @param strength the explosion strength
  61723. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61724. * @returns A physics gravitational field event, or null
  61725. */
  61726. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61727. /**
  61728. * Creates a physics updraft event
  61729. * @param origin the origin of the updraft
  61730. * @param radiusOrEventOptions the radius or the options of the updraft
  61731. * @param strength the strength of the updraft
  61732. * @param height the height of the updraft
  61733. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61734. * @returns A physics updraft event, or null
  61735. */
  61736. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61737. /**
  61738. * Creates a physics vortex event
  61739. * @param origin the of the vortex
  61740. * @param radiusOrEventOptions the radius or the options of the vortex
  61741. * @param strength the strength of the vortex
  61742. * @param height the height of the vortex
  61743. * @returns a Physics vortex event, or null
  61744. * A physics vortex event or null
  61745. */
  61746. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61747. }
  61748. /**
  61749. * Represents a physics radial explosion event
  61750. */
  61751. class PhysicsRadialExplosionEvent {
  61752. private _scene;
  61753. private _options;
  61754. private _sphere;
  61755. private _dataFetched;
  61756. /**
  61757. * Initializes a radial explosioin event
  61758. * @param _scene BabylonJS scene
  61759. * @param _options The options for the vortex event
  61760. */
  61761. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61762. /**
  61763. * Returns the data related to the radial explosion event (sphere).
  61764. * @returns The radial explosion event data
  61765. */
  61766. getData(): PhysicsRadialExplosionEventData;
  61767. /**
  61768. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61769. * @param impostor A physics imposter
  61770. * @param origin the origin of the explosion
  61771. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61772. */
  61773. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61774. /**
  61775. * Triggers affecterd impostors callbacks
  61776. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61777. */
  61778. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61779. /**
  61780. * Disposes the sphere.
  61781. * @param force Specifies if the sphere should be disposed by force
  61782. */
  61783. dispose(force?: boolean): void;
  61784. /*** Helpers ***/
  61785. private _prepareSphere;
  61786. private _intersectsWithSphere;
  61787. }
  61788. /**
  61789. * Represents a gravitational field event
  61790. */
  61791. class PhysicsGravitationalFieldEvent {
  61792. private _physicsHelper;
  61793. private _scene;
  61794. private _origin;
  61795. private _options;
  61796. private _tickCallback;
  61797. private _sphere;
  61798. private _dataFetched;
  61799. /**
  61800. * Initializes the physics gravitational field event
  61801. * @param _physicsHelper A physics helper
  61802. * @param _scene BabylonJS scene
  61803. * @param _origin The origin position of the gravitational field event
  61804. * @param _options The options for the vortex event
  61805. */
  61806. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61807. /**
  61808. * Returns the data related to the gravitational field event (sphere).
  61809. * @returns A gravitational field event
  61810. */
  61811. getData(): PhysicsGravitationalFieldEventData;
  61812. /**
  61813. * Enables the gravitational field.
  61814. */
  61815. enable(): void;
  61816. /**
  61817. * Disables the gravitational field.
  61818. */
  61819. disable(): void;
  61820. /**
  61821. * Disposes the sphere.
  61822. * @param force The force to dispose from the gravitational field event
  61823. */
  61824. dispose(force?: boolean): void;
  61825. private _tick;
  61826. }
  61827. /**
  61828. * Represents a physics updraft event
  61829. */
  61830. class PhysicsUpdraftEvent {
  61831. private _scene;
  61832. private _origin;
  61833. private _options;
  61834. private _physicsEngine;
  61835. private _originTop;
  61836. private _originDirection;
  61837. private _tickCallback;
  61838. private _cylinder;
  61839. private _cylinderPosition;
  61840. private _dataFetched;
  61841. /**
  61842. * Initializes the physics updraft event
  61843. * @param _scene BabylonJS scene
  61844. * @param _origin The origin position of the updraft
  61845. * @param _options The options for the updraft event
  61846. */
  61847. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61848. /**
  61849. * Returns the data related to the updraft event (cylinder).
  61850. * @returns A physics updraft event
  61851. */
  61852. getData(): PhysicsUpdraftEventData;
  61853. /**
  61854. * Enables the updraft.
  61855. */
  61856. enable(): void;
  61857. /**
  61858. * Disables the updraft.
  61859. */
  61860. disable(): void;
  61861. /**
  61862. * Disposes the cylinder.
  61863. * @param force Specifies if the updraft should be disposed by force
  61864. */
  61865. dispose(force?: boolean): void;
  61866. private getImpostorHitData;
  61867. private _tick;
  61868. /*** Helpers ***/
  61869. private _prepareCylinder;
  61870. private _intersectsWithCylinder;
  61871. }
  61872. /**
  61873. * Represents a physics vortex event
  61874. */
  61875. class PhysicsVortexEvent {
  61876. private _scene;
  61877. private _origin;
  61878. private _options;
  61879. private _physicsEngine;
  61880. private _originTop;
  61881. private _tickCallback;
  61882. private _cylinder;
  61883. private _cylinderPosition;
  61884. private _dataFetched;
  61885. /**
  61886. * Initializes the physics vortex event
  61887. * @param _scene The BabylonJS scene
  61888. * @param _origin The origin position of the vortex
  61889. * @param _options The options for the vortex event
  61890. */
  61891. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61892. /**
  61893. * Returns the data related to the vortex event (cylinder).
  61894. * @returns The physics vortex event data
  61895. */
  61896. getData(): PhysicsVortexEventData;
  61897. /**
  61898. * Enables the vortex.
  61899. */
  61900. enable(): void;
  61901. /**
  61902. * Disables the cortex.
  61903. */
  61904. disable(): void;
  61905. /**
  61906. * Disposes the sphere.
  61907. * @param force
  61908. */
  61909. dispose(force?: boolean): void;
  61910. private getImpostorHitData;
  61911. private _tick;
  61912. /*** Helpers ***/
  61913. private _prepareCylinder;
  61914. private _intersectsWithCylinder;
  61915. }
  61916. /**
  61917. * Options fot the radial explosion event
  61918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61919. */
  61920. export class PhysicsRadialExplosionEventOptions {
  61921. /**
  61922. * The radius of the sphere for the radial explosion.
  61923. */
  61924. radius: number;
  61925. /**
  61926. * The strenth of the explosion.
  61927. */
  61928. strength: number;
  61929. /**
  61930. * The strenght of the force in correspondence to the distance of the affected object
  61931. */
  61932. falloff: PhysicsRadialImpulseFalloff;
  61933. /**
  61934. * Sphere options for the radial explosion.
  61935. */
  61936. sphere: {
  61937. segments: number;
  61938. diameter: number;
  61939. };
  61940. /**
  61941. * Sphere options for the radial explosion.
  61942. */
  61943. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61944. }
  61945. /**
  61946. * Options fot the updraft event
  61947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61948. */
  61949. export class PhysicsUpdraftEventOptions {
  61950. /**
  61951. * The radius of the cylinder for the vortex
  61952. */
  61953. radius: number;
  61954. /**
  61955. * The strenth of the updraft.
  61956. */
  61957. strength: number;
  61958. /**
  61959. * The height of the cylinder for the updraft.
  61960. */
  61961. height: number;
  61962. /**
  61963. * The mode for the the updraft.
  61964. */
  61965. updraftMode: PhysicsUpdraftMode;
  61966. }
  61967. /**
  61968. * Options fot the vortex event
  61969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61970. */
  61971. export class PhysicsVortexEventOptions {
  61972. /**
  61973. * The radius of the cylinder for the vortex
  61974. */
  61975. radius: number;
  61976. /**
  61977. * The strenth of the vortex.
  61978. */
  61979. strength: number;
  61980. /**
  61981. * The height of the cylinder for the vortex.
  61982. */
  61983. height: number;
  61984. /**
  61985. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61986. */
  61987. centripetalForceThreshold: number;
  61988. /**
  61989. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61990. */
  61991. centripetalForceMultiplier: number;
  61992. /**
  61993. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61994. */
  61995. centrifugalForceMultiplier: number;
  61996. /**
  61997. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61998. */
  61999. updraftForceMultiplier: number;
  62000. }
  62001. /**
  62002. * The strenght of the force in correspondence to the distance of the affected object
  62003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62004. */
  62005. export enum PhysicsRadialImpulseFalloff {
  62006. /** Defines that impulse is constant in strength across it's whole radius */
  62007. Constant = 0,
  62008. /** Defines that impulse gets weaker if it's further from the origin */
  62009. Linear = 1
  62010. }
  62011. /**
  62012. * The strength of the force in correspondence to the distance of the affected object
  62013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62014. */
  62015. export enum PhysicsUpdraftMode {
  62016. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62017. Center = 0,
  62018. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62019. Perpendicular = 1
  62020. }
  62021. /**
  62022. * Interface for a physics hit data
  62023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62024. */
  62025. export interface PhysicsHitData {
  62026. /**
  62027. * The force applied at the contact point
  62028. */
  62029. force: Vector3;
  62030. /**
  62031. * The contact point
  62032. */
  62033. contactPoint: Vector3;
  62034. /**
  62035. * The distance from the origin to the contact point
  62036. */
  62037. distanceFromOrigin: number;
  62038. }
  62039. /**
  62040. * Interface for radial explosion event data
  62041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62042. */
  62043. export interface PhysicsRadialExplosionEventData {
  62044. /**
  62045. * A sphere used for the radial explosion event
  62046. */
  62047. sphere: Mesh;
  62048. }
  62049. /**
  62050. * Interface for gravitational field event data
  62051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62052. */
  62053. export interface PhysicsGravitationalFieldEventData {
  62054. /**
  62055. * A sphere mesh used for the gravitational field event
  62056. */
  62057. sphere: Mesh;
  62058. }
  62059. /**
  62060. * Interface for updraft event data
  62061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62062. */
  62063. export interface PhysicsUpdraftEventData {
  62064. /**
  62065. * A cylinder used for the updraft event
  62066. */
  62067. cylinder: Mesh;
  62068. }
  62069. /**
  62070. * Interface for vortex event data
  62071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62072. */
  62073. export interface PhysicsVortexEventData {
  62074. /**
  62075. * A cylinder used for the vortex event
  62076. */
  62077. cylinder: Mesh;
  62078. }
  62079. /**
  62080. * Interface for an affected physics impostor
  62081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62082. */
  62083. export interface PhysicsAffectedImpostorWithData {
  62084. /**
  62085. * The impostor affected by the effect
  62086. */
  62087. impostor: PhysicsImpostor;
  62088. /**
  62089. * The data about the hit/horce from the explosion
  62090. */
  62091. hitData: PhysicsHitData;
  62092. }
  62093. }
  62094. declare module BABYLON {
  62095. /** @hidden */
  62096. export var blackAndWhitePixelShader: {
  62097. name: string;
  62098. shader: string;
  62099. };
  62100. }
  62101. declare module BABYLON {
  62102. /**
  62103. * Post process used to render in black and white
  62104. */
  62105. export class BlackAndWhitePostProcess extends PostProcess {
  62106. /**
  62107. * Linear about to convert he result to black and white (default: 1)
  62108. */
  62109. degree: number;
  62110. /**
  62111. * Creates a black and white post process
  62112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62113. * @param name The name of the effect.
  62114. * @param options The required width/height ratio to downsize to before computing the render pass.
  62115. * @param camera The camera to apply the render pass to.
  62116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62117. * @param engine The engine which the post process will be applied. (default: current engine)
  62118. * @param reusable If the post process can be reused on the same frame. (default: false)
  62119. */
  62120. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62121. }
  62122. }
  62123. declare module BABYLON {
  62124. /**
  62125. * This represents a set of one or more post processes in Babylon.
  62126. * A post process can be used to apply a shader to a texture after it is rendered.
  62127. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62128. */
  62129. export class PostProcessRenderEffect {
  62130. private _postProcesses;
  62131. private _getPostProcesses;
  62132. private _singleInstance;
  62133. private _cameras;
  62134. private _indicesForCamera;
  62135. /**
  62136. * Name of the effect
  62137. * @hidden
  62138. */
  62139. _name: string;
  62140. /**
  62141. * Instantiates a post process render effect.
  62142. * A post process can be used to apply a shader to a texture after it is rendered.
  62143. * @param engine The engine the effect is tied to
  62144. * @param name The name of the effect
  62145. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62146. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62147. */
  62148. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62149. /**
  62150. * Checks if all the post processes in the effect are supported.
  62151. */
  62152. get isSupported(): boolean;
  62153. /**
  62154. * Updates the current state of the effect
  62155. * @hidden
  62156. */
  62157. _update(): void;
  62158. /**
  62159. * Attaches the effect on cameras
  62160. * @param cameras The camera to attach to.
  62161. * @hidden
  62162. */
  62163. _attachCameras(cameras: Camera): void;
  62164. /**
  62165. * Attaches the effect on cameras
  62166. * @param cameras The camera to attach to.
  62167. * @hidden
  62168. */
  62169. _attachCameras(cameras: Camera[]): void;
  62170. /**
  62171. * Detaches the effect on cameras
  62172. * @param cameras The camera to detatch from.
  62173. * @hidden
  62174. */
  62175. _detachCameras(cameras: Camera): void;
  62176. /**
  62177. * Detatches the effect on cameras
  62178. * @param cameras The camera to detatch from.
  62179. * @hidden
  62180. */
  62181. _detachCameras(cameras: Camera[]): void;
  62182. /**
  62183. * Enables the effect on given cameras
  62184. * @param cameras The camera to enable.
  62185. * @hidden
  62186. */
  62187. _enable(cameras: Camera): void;
  62188. /**
  62189. * Enables the effect on given cameras
  62190. * @param cameras The camera to enable.
  62191. * @hidden
  62192. */
  62193. _enable(cameras: Nullable<Camera[]>): void;
  62194. /**
  62195. * Disables the effect on the given cameras
  62196. * @param cameras The camera to disable.
  62197. * @hidden
  62198. */
  62199. _disable(cameras: Camera): void;
  62200. /**
  62201. * Disables the effect on the given cameras
  62202. * @param cameras The camera to disable.
  62203. * @hidden
  62204. */
  62205. _disable(cameras: Nullable<Camera[]>): void;
  62206. /**
  62207. * Gets a list of the post processes contained in the effect.
  62208. * @param camera The camera to get the post processes on.
  62209. * @returns The list of the post processes in the effect.
  62210. */
  62211. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62212. }
  62213. }
  62214. declare module BABYLON {
  62215. /** @hidden */
  62216. export var extractHighlightsPixelShader: {
  62217. name: string;
  62218. shader: string;
  62219. };
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * 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.
  62224. */
  62225. export class ExtractHighlightsPostProcess extends PostProcess {
  62226. /**
  62227. * The luminance threshold, pixels below this value will be set to black.
  62228. */
  62229. threshold: number;
  62230. /** @hidden */
  62231. _exposure: number;
  62232. /**
  62233. * Post process which has the input texture to be used when performing highlight extraction
  62234. * @hidden
  62235. */
  62236. _inputPostProcess: Nullable<PostProcess>;
  62237. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62238. }
  62239. }
  62240. declare module BABYLON {
  62241. /** @hidden */
  62242. export var bloomMergePixelShader: {
  62243. name: string;
  62244. shader: string;
  62245. };
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62250. */
  62251. export class BloomMergePostProcess extends PostProcess {
  62252. /** Weight of the bloom to be added to the original input. */
  62253. weight: number;
  62254. /**
  62255. * Creates a new instance of @see BloomMergePostProcess
  62256. * @param name The name of the effect.
  62257. * @param originalFromInput Post process which's input will be used for the merge.
  62258. * @param blurred Blurred highlights post process which's output will be used.
  62259. * @param weight Weight of the bloom to be added to the original input.
  62260. * @param options The required width/height ratio to downsize to before computing the render pass.
  62261. * @param camera The camera to apply the render pass to.
  62262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62263. * @param engine The engine which the post process will be applied. (default: current engine)
  62264. * @param reusable If the post process can be reused on the same frame. (default: false)
  62265. * @param textureType Type of textures used when performing the post process. (default: 0)
  62266. * @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)
  62267. */
  62268. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62269. /** Weight of the bloom to be added to the original input. */
  62270. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62271. }
  62272. }
  62273. declare module BABYLON {
  62274. /**
  62275. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62276. */
  62277. export class BloomEffect extends PostProcessRenderEffect {
  62278. private bloomScale;
  62279. /**
  62280. * @hidden Internal
  62281. */
  62282. _effects: Array<PostProcess>;
  62283. /**
  62284. * @hidden Internal
  62285. */
  62286. _downscale: ExtractHighlightsPostProcess;
  62287. private _blurX;
  62288. private _blurY;
  62289. private _merge;
  62290. /**
  62291. * The luminance threshold to find bright areas of the image to bloom.
  62292. */
  62293. get threshold(): number;
  62294. set threshold(value: number);
  62295. /**
  62296. * The strength of the bloom.
  62297. */
  62298. get weight(): number;
  62299. set weight(value: number);
  62300. /**
  62301. * Specifies the size of the bloom blur kernel, relative to the final output size
  62302. */
  62303. get kernel(): number;
  62304. set kernel(value: number);
  62305. /**
  62306. * Creates a new instance of @see BloomEffect
  62307. * @param scene The scene the effect belongs to.
  62308. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62309. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62310. * @param bloomWeight The the strength of bloom.
  62311. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62312. * @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)
  62313. */
  62314. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62315. /**
  62316. * Disposes each of the internal effects for a given camera.
  62317. * @param camera The camera to dispose the effect on.
  62318. */
  62319. disposeEffects(camera: Camera): void;
  62320. /**
  62321. * @hidden Internal
  62322. */
  62323. _updateEffects(): void;
  62324. /**
  62325. * Internal
  62326. * @returns if all the contained post processes are ready.
  62327. * @hidden
  62328. */
  62329. _isReady(): boolean;
  62330. }
  62331. }
  62332. declare module BABYLON {
  62333. /** @hidden */
  62334. export var chromaticAberrationPixelShader: {
  62335. name: string;
  62336. shader: string;
  62337. };
  62338. }
  62339. declare module BABYLON {
  62340. /**
  62341. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62342. */
  62343. export class ChromaticAberrationPostProcess extends PostProcess {
  62344. /**
  62345. * The amount of seperation of rgb channels (default: 30)
  62346. */
  62347. aberrationAmount: number;
  62348. /**
  62349. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62350. */
  62351. radialIntensity: number;
  62352. /**
  62353. * 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))
  62354. */
  62355. direction: Vector2;
  62356. /**
  62357. * 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))
  62358. */
  62359. centerPosition: Vector2;
  62360. /**
  62361. * Creates a new instance ChromaticAberrationPostProcess
  62362. * @param name The name of the effect.
  62363. * @param screenWidth The width of the screen to apply the effect on.
  62364. * @param screenHeight The height of the screen to apply the effect on.
  62365. * @param options The required width/height ratio to downsize to before computing the render pass.
  62366. * @param camera The camera to apply the render pass to.
  62367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62368. * @param engine The engine which the post process will be applied. (default: current engine)
  62369. * @param reusable If the post process can be reused on the same frame. (default: false)
  62370. * @param textureType Type of textures used when performing the post process. (default: 0)
  62371. * @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)
  62372. */
  62373. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /** @hidden */
  62378. export var circleOfConfusionPixelShader: {
  62379. name: string;
  62380. shader: string;
  62381. };
  62382. }
  62383. declare module BABYLON {
  62384. /**
  62385. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62386. */
  62387. export class CircleOfConfusionPostProcess extends PostProcess {
  62388. /**
  62389. * 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.
  62390. */
  62391. lensSize: number;
  62392. /**
  62393. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62394. */
  62395. fStop: number;
  62396. /**
  62397. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62398. */
  62399. focusDistance: number;
  62400. /**
  62401. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62402. */
  62403. focalLength: number;
  62404. private _depthTexture;
  62405. /**
  62406. * Creates a new instance CircleOfConfusionPostProcess
  62407. * @param name The name of the effect.
  62408. * @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.
  62409. * @param options The required width/height ratio to downsize to before computing the render pass.
  62410. * @param camera The camera to apply the render pass to.
  62411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62412. * @param engine The engine which the post process will be applied. (default: current engine)
  62413. * @param reusable If the post process can be reused on the same frame. (default: false)
  62414. * @param textureType Type of textures used when performing the post process. (default: 0)
  62415. * @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)
  62416. */
  62417. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62418. /**
  62419. * 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.
  62420. */
  62421. set depthTexture(value: RenderTargetTexture);
  62422. }
  62423. }
  62424. declare module BABYLON {
  62425. /** @hidden */
  62426. export var colorCorrectionPixelShader: {
  62427. name: string;
  62428. shader: string;
  62429. };
  62430. }
  62431. declare module BABYLON {
  62432. /**
  62433. *
  62434. * This post-process allows the modification of rendered colors by using
  62435. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62436. *
  62437. * The object needs to be provided an url to a texture containing the color
  62438. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62439. * Use an image editing software to tweak the LUT to match your needs.
  62440. *
  62441. * For an example of a color LUT, see here:
  62442. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62443. * For explanations on color grading, see here:
  62444. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62445. *
  62446. */
  62447. export class ColorCorrectionPostProcess extends PostProcess {
  62448. private _colorTableTexture;
  62449. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /** @hidden */
  62454. export var convolutionPixelShader: {
  62455. name: string;
  62456. shader: string;
  62457. };
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62462. * input texture to perform effects such as edge detection or sharpening
  62463. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62464. */
  62465. export class ConvolutionPostProcess extends PostProcess {
  62466. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62467. kernel: number[];
  62468. /**
  62469. * Creates a new instance ConvolutionPostProcess
  62470. * @param name The name of the effect.
  62471. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62472. * @param options The required width/height ratio to downsize to before computing the render pass.
  62473. * @param camera The camera to apply the render pass to.
  62474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62475. * @param engine The engine which the post process will be applied. (default: current engine)
  62476. * @param reusable If the post process can be reused on the same frame. (default: false)
  62477. * @param textureType Type of textures used when performing the post process. (default: 0)
  62478. */
  62479. constructor(name: string,
  62480. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62481. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62482. /**
  62483. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62484. */
  62485. static EdgeDetect0Kernel: number[];
  62486. /**
  62487. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62488. */
  62489. static EdgeDetect1Kernel: number[];
  62490. /**
  62491. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62492. */
  62493. static EdgeDetect2Kernel: number[];
  62494. /**
  62495. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62496. */
  62497. static SharpenKernel: number[];
  62498. /**
  62499. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62500. */
  62501. static EmbossKernel: number[];
  62502. /**
  62503. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62504. */
  62505. static GaussianKernel: number[];
  62506. }
  62507. }
  62508. declare module BABYLON {
  62509. /**
  62510. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62511. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62512. * based on samples that have a large difference in distance than the center pixel.
  62513. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62514. */
  62515. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62516. direction: Vector2;
  62517. /**
  62518. * Creates a new instance CircleOfConfusionPostProcess
  62519. * @param name The name of the effect.
  62520. * @param scene The scene the effect belongs to.
  62521. * @param direction The direction the blur should be applied.
  62522. * @param kernel The size of the kernel used to blur.
  62523. * @param options The required width/height ratio to downsize to before computing the render pass.
  62524. * @param camera The camera to apply the render pass to.
  62525. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62526. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62528. * @param engine The engine which the post process will be applied. (default: current engine)
  62529. * @param reusable If the post process can be reused on the same frame. (default: false)
  62530. * @param textureType Type of textures used when performing the post process. (default: 0)
  62531. * @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)
  62532. */
  62533. 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);
  62534. }
  62535. }
  62536. declare module BABYLON {
  62537. /** @hidden */
  62538. export var depthOfFieldMergePixelShader: {
  62539. name: string;
  62540. shader: string;
  62541. };
  62542. }
  62543. declare module BABYLON {
  62544. /**
  62545. * Options to be set when merging outputs from the default pipeline.
  62546. */
  62547. export class DepthOfFieldMergePostProcessOptions {
  62548. /**
  62549. * The original image to merge on top of
  62550. */
  62551. originalFromInput: PostProcess;
  62552. /**
  62553. * Parameters to perform the merge of the depth of field effect
  62554. */
  62555. depthOfField?: {
  62556. circleOfConfusion: PostProcess;
  62557. blurSteps: Array<PostProcess>;
  62558. };
  62559. /**
  62560. * Parameters to perform the merge of bloom effect
  62561. */
  62562. bloom?: {
  62563. blurred: PostProcess;
  62564. weight: number;
  62565. };
  62566. }
  62567. /**
  62568. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62569. */
  62570. export class DepthOfFieldMergePostProcess extends PostProcess {
  62571. private blurSteps;
  62572. /**
  62573. * Creates a new instance of DepthOfFieldMergePostProcess
  62574. * @param name The name of the effect.
  62575. * @param originalFromInput Post process which's input will be used for the merge.
  62576. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62577. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62578. * @param options The required width/height ratio to downsize to before computing the render pass.
  62579. * @param camera The camera to apply the render pass to.
  62580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62581. * @param engine The engine which the post process will be applied. (default: current engine)
  62582. * @param reusable If the post process can be reused on the same frame. (default: false)
  62583. * @param textureType Type of textures used when performing the post process. (default: 0)
  62584. * @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)
  62585. */
  62586. 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);
  62587. /**
  62588. * Updates the effect with the current post process compile time values and recompiles the shader.
  62589. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62590. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62591. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62592. * @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
  62593. * @param onCompiled Called when the shader has been compiled.
  62594. * @param onError Called if there is an error when compiling a shader.
  62595. */
  62596. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62597. }
  62598. }
  62599. declare module BABYLON {
  62600. /**
  62601. * Specifies the level of max blur that should be applied when using the depth of field effect
  62602. */
  62603. export enum DepthOfFieldEffectBlurLevel {
  62604. /**
  62605. * Subtle blur
  62606. */
  62607. Low = 0,
  62608. /**
  62609. * Medium blur
  62610. */
  62611. Medium = 1,
  62612. /**
  62613. * Large blur
  62614. */
  62615. High = 2
  62616. }
  62617. /**
  62618. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62619. */
  62620. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62621. private _circleOfConfusion;
  62622. /**
  62623. * @hidden Internal, blurs from high to low
  62624. */
  62625. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62626. private _depthOfFieldBlurY;
  62627. private _dofMerge;
  62628. /**
  62629. * @hidden Internal post processes in depth of field effect
  62630. */
  62631. _effects: Array<PostProcess>;
  62632. /**
  62633. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62634. */
  62635. set focalLength(value: number);
  62636. get focalLength(): number;
  62637. /**
  62638. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62639. */
  62640. set fStop(value: number);
  62641. get fStop(): number;
  62642. /**
  62643. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62644. */
  62645. set focusDistance(value: number);
  62646. get focusDistance(): number;
  62647. /**
  62648. * 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.
  62649. */
  62650. set lensSize(value: number);
  62651. get lensSize(): number;
  62652. /**
  62653. * Creates a new instance DepthOfFieldEffect
  62654. * @param scene The scene the effect belongs to.
  62655. * @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.
  62656. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62657. * @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)
  62658. */
  62659. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62660. /**
  62661. * Get the current class name of the current effet
  62662. * @returns "DepthOfFieldEffect"
  62663. */
  62664. getClassName(): string;
  62665. /**
  62666. * 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.
  62667. */
  62668. set depthTexture(value: RenderTargetTexture);
  62669. /**
  62670. * Disposes each of the internal effects for a given camera.
  62671. * @param camera The camera to dispose the effect on.
  62672. */
  62673. disposeEffects(camera: Camera): void;
  62674. /**
  62675. * @hidden Internal
  62676. */
  62677. _updateEffects(): void;
  62678. /**
  62679. * Internal
  62680. * @returns if all the contained post processes are ready.
  62681. * @hidden
  62682. */
  62683. _isReady(): boolean;
  62684. }
  62685. }
  62686. declare module BABYLON {
  62687. /** @hidden */
  62688. export var displayPassPixelShader: {
  62689. name: string;
  62690. shader: string;
  62691. };
  62692. }
  62693. declare module BABYLON {
  62694. /**
  62695. * DisplayPassPostProcess which produces an output the same as it's input
  62696. */
  62697. export class DisplayPassPostProcess extends PostProcess {
  62698. /**
  62699. * Creates the DisplayPassPostProcess
  62700. * @param name The name of the effect.
  62701. * @param options The required width/height ratio to downsize to before computing the render pass.
  62702. * @param camera The camera to apply the render pass to.
  62703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62704. * @param engine The engine which the post process will be applied. (default: current engine)
  62705. * @param reusable If the post process can be reused on the same frame. (default: false)
  62706. */
  62707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62708. }
  62709. }
  62710. declare module BABYLON {
  62711. /** @hidden */
  62712. export var filterPixelShader: {
  62713. name: string;
  62714. shader: string;
  62715. };
  62716. }
  62717. declare module BABYLON {
  62718. /**
  62719. * Applies a kernel filter to the image
  62720. */
  62721. export class FilterPostProcess extends PostProcess {
  62722. /** The matrix to be applied to the image */
  62723. kernelMatrix: Matrix;
  62724. /**
  62725. *
  62726. * @param name The name of the effect.
  62727. * @param kernelMatrix The matrix to be applied to the image
  62728. * @param options The required width/height ratio to downsize to before computing the render pass.
  62729. * @param camera The camera to apply the render pass to.
  62730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62731. * @param engine The engine which the post process will be applied. (default: current engine)
  62732. * @param reusable If the post process can be reused on the same frame. (default: false)
  62733. */
  62734. constructor(name: string,
  62735. /** The matrix to be applied to the image */
  62736. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62737. }
  62738. }
  62739. declare module BABYLON {
  62740. /** @hidden */
  62741. export var fxaaPixelShader: {
  62742. name: string;
  62743. shader: string;
  62744. };
  62745. }
  62746. declare module BABYLON {
  62747. /** @hidden */
  62748. export var fxaaVertexShader: {
  62749. name: string;
  62750. shader: string;
  62751. };
  62752. }
  62753. declare module BABYLON {
  62754. /**
  62755. * Fxaa post process
  62756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62757. */
  62758. export class FxaaPostProcess extends PostProcess {
  62759. /** @hidden */
  62760. texelWidth: number;
  62761. /** @hidden */
  62762. texelHeight: number;
  62763. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62764. private _getDefines;
  62765. }
  62766. }
  62767. declare module BABYLON {
  62768. /** @hidden */
  62769. export var grainPixelShader: {
  62770. name: string;
  62771. shader: string;
  62772. };
  62773. }
  62774. declare module BABYLON {
  62775. /**
  62776. * The GrainPostProcess adds noise to the image at mid luminance levels
  62777. */
  62778. export class GrainPostProcess extends PostProcess {
  62779. /**
  62780. * The intensity of the grain added (default: 30)
  62781. */
  62782. intensity: number;
  62783. /**
  62784. * If the grain should be randomized on every frame
  62785. */
  62786. animated: boolean;
  62787. /**
  62788. * Creates a new instance of @see GrainPostProcess
  62789. * @param name The name of the effect.
  62790. * @param options The required width/height ratio to downsize to before computing the render pass.
  62791. * @param camera The camera to apply the render pass to.
  62792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62793. * @param engine The engine which the post process will be applied. (default: current engine)
  62794. * @param reusable If the post process can be reused on the same frame. (default: false)
  62795. * @param textureType Type of textures used when performing the post process. (default: 0)
  62796. * @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)
  62797. */
  62798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /** @hidden */
  62803. export var highlightsPixelShader: {
  62804. name: string;
  62805. shader: string;
  62806. };
  62807. }
  62808. declare module BABYLON {
  62809. /**
  62810. * Extracts highlights from the image
  62811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62812. */
  62813. export class HighlightsPostProcess extends PostProcess {
  62814. /**
  62815. * Extracts highlights from the image
  62816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62817. * @param name The name of the effect.
  62818. * @param options The required width/height ratio to downsize to before computing the render pass.
  62819. * @param camera The camera to apply the render pass to.
  62820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62821. * @param engine The engine which the post process will be applied. (default: current engine)
  62822. * @param reusable If the post process can be reused on the same frame. (default: false)
  62823. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62824. */
  62825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /** @hidden */
  62830. export var mrtFragmentDeclaration: {
  62831. name: string;
  62832. shader: string;
  62833. };
  62834. }
  62835. declare module BABYLON {
  62836. /** @hidden */
  62837. export var geometryPixelShader: {
  62838. name: string;
  62839. shader: string;
  62840. };
  62841. }
  62842. declare module BABYLON {
  62843. /** @hidden */
  62844. export var geometryVertexShader: {
  62845. name: string;
  62846. shader: string;
  62847. };
  62848. }
  62849. declare module BABYLON {
  62850. /** @hidden */
  62851. interface ISavedTransformationMatrix {
  62852. world: Matrix;
  62853. viewProjection: Matrix;
  62854. }
  62855. /**
  62856. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62857. */
  62858. export class GeometryBufferRenderer {
  62859. /**
  62860. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62861. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62862. */
  62863. static readonly POSITION_TEXTURE_TYPE: number;
  62864. /**
  62865. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62866. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62867. */
  62868. static readonly VELOCITY_TEXTURE_TYPE: number;
  62869. /**
  62870. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62871. * in order to compute objects velocities when enableVelocity is set to "true"
  62872. * @hidden
  62873. */
  62874. _previousTransformationMatrices: {
  62875. [index: number]: ISavedTransformationMatrix;
  62876. };
  62877. /**
  62878. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62879. * in order to compute objects velocities when enableVelocity is set to "true"
  62880. * @hidden
  62881. */
  62882. _previousBonesTransformationMatrices: {
  62883. [index: number]: Float32Array;
  62884. };
  62885. /**
  62886. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62887. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62888. */
  62889. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62890. private _scene;
  62891. private _multiRenderTarget;
  62892. private _ratio;
  62893. private _enablePosition;
  62894. private _enableVelocity;
  62895. private _positionIndex;
  62896. private _velocityIndex;
  62897. protected _effect: Effect;
  62898. protected _cachedDefines: string;
  62899. /**
  62900. * Set the render list (meshes to be rendered) used in the G buffer.
  62901. */
  62902. set renderList(meshes: Mesh[]);
  62903. /**
  62904. * Gets wether or not G buffer are supported by the running hardware.
  62905. * This requires draw buffer supports
  62906. */
  62907. get isSupported(): boolean;
  62908. /**
  62909. * Returns the index of the given texture type in the G-Buffer textures array
  62910. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62911. * @returns the index of the given texture type in the G-Buffer textures array
  62912. */
  62913. getTextureIndex(textureType: number): number;
  62914. /**
  62915. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62916. */
  62917. get enablePosition(): boolean;
  62918. /**
  62919. * Sets whether or not objects positions are enabled for the G buffer.
  62920. */
  62921. set enablePosition(enable: boolean);
  62922. /**
  62923. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62924. */
  62925. get enableVelocity(): boolean;
  62926. /**
  62927. * Sets wether or not objects velocities are enabled for the G buffer.
  62928. */
  62929. set enableVelocity(enable: boolean);
  62930. /**
  62931. * Gets the scene associated with the buffer.
  62932. */
  62933. get scene(): Scene;
  62934. /**
  62935. * Gets the ratio used by the buffer during its creation.
  62936. * How big is the buffer related to the main canvas.
  62937. */
  62938. get ratio(): number;
  62939. /** @hidden */
  62940. static _SceneComponentInitialization: (scene: Scene) => void;
  62941. /**
  62942. * Creates a new G Buffer for the scene
  62943. * @param scene The scene the buffer belongs to
  62944. * @param ratio How big is the buffer related to the main canvas.
  62945. */
  62946. constructor(scene: Scene, ratio?: number);
  62947. /**
  62948. * Checks wether everything is ready to render a submesh to the G buffer.
  62949. * @param subMesh the submesh to check readiness for
  62950. * @param useInstances is the mesh drawn using instance or not
  62951. * @returns true if ready otherwise false
  62952. */
  62953. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62954. /**
  62955. * Gets the current underlying G Buffer.
  62956. * @returns the buffer
  62957. */
  62958. getGBuffer(): MultiRenderTarget;
  62959. /**
  62960. * Gets the number of samples used to render the buffer (anti aliasing).
  62961. */
  62962. get samples(): number;
  62963. /**
  62964. * Sets the number of samples used to render the buffer (anti aliasing).
  62965. */
  62966. set samples(value: number);
  62967. /**
  62968. * Disposes the renderer and frees up associated resources.
  62969. */
  62970. dispose(): void;
  62971. protected _createRenderTargets(): void;
  62972. private _copyBonesTransformationMatrices;
  62973. }
  62974. }
  62975. declare module BABYLON {
  62976. interface Scene {
  62977. /** @hidden (Backing field) */
  62978. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62979. /**
  62980. * Gets or Sets the current geometry buffer associated to the scene.
  62981. */
  62982. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62983. /**
  62984. * Enables a GeometryBufferRender and associates it with the scene
  62985. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62986. * @returns the GeometryBufferRenderer
  62987. */
  62988. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62989. /**
  62990. * Disables the GeometryBufferRender associated with the scene
  62991. */
  62992. disableGeometryBufferRenderer(): void;
  62993. }
  62994. /**
  62995. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62996. * in several rendering techniques.
  62997. */
  62998. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62999. /**
  63000. * The component name helpful to identify the component in the list of scene components.
  63001. */
  63002. readonly name: string;
  63003. /**
  63004. * The scene the component belongs to.
  63005. */
  63006. scene: Scene;
  63007. /**
  63008. * Creates a new instance of the component for the given scene
  63009. * @param scene Defines the scene to register the component in
  63010. */
  63011. constructor(scene: Scene);
  63012. /**
  63013. * Registers the component in a given scene
  63014. */
  63015. register(): void;
  63016. /**
  63017. * Rebuilds the elements related to this component in case of
  63018. * context lost for instance.
  63019. */
  63020. rebuild(): void;
  63021. /**
  63022. * Disposes the component and the associated ressources
  63023. */
  63024. dispose(): void;
  63025. private _gatherRenderTargets;
  63026. }
  63027. }
  63028. declare module BABYLON {
  63029. /** @hidden */
  63030. export var motionBlurPixelShader: {
  63031. name: string;
  63032. shader: string;
  63033. };
  63034. }
  63035. declare module BABYLON {
  63036. /**
  63037. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63038. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63039. * As an example, all you have to do is to create the post-process:
  63040. * var mb = new BABYLON.MotionBlurPostProcess(
  63041. * 'mb', // The name of the effect.
  63042. * scene, // The scene containing the objects to blur according to their velocity.
  63043. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63044. * camera // The camera to apply the render pass to.
  63045. * );
  63046. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63047. */
  63048. export class MotionBlurPostProcess extends PostProcess {
  63049. /**
  63050. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63051. */
  63052. motionStrength: number;
  63053. /**
  63054. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63055. */
  63056. get motionBlurSamples(): number;
  63057. /**
  63058. * Sets the number of iterations to be used for motion blur quality
  63059. */
  63060. set motionBlurSamples(samples: number);
  63061. private _motionBlurSamples;
  63062. private _geometryBufferRenderer;
  63063. /**
  63064. * Creates a new instance MotionBlurPostProcess
  63065. * @param name The name of the effect.
  63066. * @param scene The scene containing the objects to blur according to their velocity.
  63067. * @param options The required width/height ratio to downsize to before computing the render pass.
  63068. * @param camera The camera to apply the render pass to.
  63069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63070. * @param engine The engine which the post process will be applied. (default: current engine)
  63071. * @param reusable If the post process can be reused on the same frame. (default: false)
  63072. * @param textureType Type of textures used when performing the post process. (default: 0)
  63073. * @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)
  63074. */
  63075. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63076. /**
  63077. * Excludes the given skinned mesh from computing bones velocities.
  63078. * 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.
  63079. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63080. */
  63081. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63082. /**
  63083. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63084. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63085. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63086. */
  63087. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63088. /**
  63089. * Disposes the post process.
  63090. * @param camera The camera to dispose the post process on.
  63091. */
  63092. dispose(camera?: Camera): void;
  63093. }
  63094. }
  63095. declare module BABYLON {
  63096. /** @hidden */
  63097. export var refractionPixelShader: {
  63098. name: string;
  63099. shader: string;
  63100. };
  63101. }
  63102. declare module BABYLON {
  63103. /**
  63104. * Post process which applies a refractin texture
  63105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63106. */
  63107. export class RefractionPostProcess extends PostProcess {
  63108. /** the base color of the refraction (used to taint the rendering) */
  63109. color: Color3;
  63110. /** simulated refraction depth */
  63111. depth: number;
  63112. /** the coefficient of the base color (0 to remove base color tainting) */
  63113. colorLevel: number;
  63114. private _refTexture;
  63115. private _ownRefractionTexture;
  63116. /**
  63117. * Gets or sets the refraction texture
  63118. * Please note that you are responsible for disposing the texture if you set it manually
  63119. */
  63120. get refractionTexture(): Texture;
  63121. set refractionTexture(value: Texture);
  63122. /**
  63123. * Initializes the RefractionPostProcess
  63124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63125. * @param name The name of the effect.
  63126. * @param refractionTextureUrl Url of the refraction texture to use
  63127. * @param color the base color of the refraction (used to taint the rendering)
  63128. * @param depth simulated refraction depth
  63129. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63130. * @param camera The camera to apply the render pass to.
  63131. * @param options The required width/height ratio to downsize to before computing the render pass.
  63132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63133. * @param engine The engine which the post process will be applied. (default: current engine)
  63134. * @param reusable If the post process can be reused on the same frame. (default: false)
  63135. */
  63136. constructor(name: string, refractionTextureUrl: string,
  63137. /** the base color of the refraction (used to taint the rendering) */
  63138. color: Color3,
  63139. /** simulated refraction depth */
  63140. depth: number,
  63141. /** the coefficient of the base color (0 to remove base color tainting) */
  63142. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63143. /**
  63144. * Disposes of the post process
  63145. * @param camera Camera to dispose post process on
  63146. */
  63147. dispose(camera: Camera): void;
  63148. }
  63149. }
  63150. declare module BABYLON {
  63151. /** @hidden */
  63152. export var sharpenPixelShader: {
  63153. name: string;
  63154. shader: string;
  63155. };
  63156. }
  63157. declare module BABYLON {
  63158. /**
  63159. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63160. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63161. */
  63162. export class SharpenPostProcess extends PostProcess {
  63163. /**
  63164. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63165. */
  63166. colorAmount: number;
  63167. /**
  63168. * How much sharpness should be applied (default: 0.3)
  63169. */
  63170. edgeAmount: number;
  63171. /**
  63172. * Creates a new instance ConvolutionPostProcess
  63173. * @param name The name of the effect.
  63174. * @param options The required width/height ratio to downsize to before computing the render pass.
  63175. * @param camera The camera to apply the render pass to.
  63176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63177. * @param engine The engine which the post process will be applied. (default: current engine)
  63178. * @param reusable If the post process can be reused on the same frame. (default: false)
  63179. * @param textureType Type of textures used when performing the post process. (default: 0)
  63180. * @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)
  63181. */
  63182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63183. }
  63184. }
  63185. declare module BABYLON {
  63186. /**
  63187. * PostProcessRenderPipeline
  63188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63189. */
  63190. export class PostProcessRenderPipeline {
  63191. private engine;
  63192. private _renderEffects;
  63193. private _renderEffectsForIsolatedPass;
  63194. /**
  63195. * List of inspectable custom properties (used by the Inspector)
  63196. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63197. */
  63198. inspectableCustomProperties: IInspectable[];
  63199. /**
  63200. * @hidden
  63201. */
  63202. protected _cameras: Camera[];
  63203. /** @hidden */
  63204. _name: string;
  63205. /**
  63206. * Gets pipeline name
  63207. */
  63208. get name(): string;
  63209. /** Gets the list of attached cameras */
  63210. get cameras(): Camera[];
  63211. /**
  63212. * Initializes a PostProcessRenderPipeline
  63213. * @param engine engine to add the pipeline to
  63214. * @param name name of the pipeline
  63215. */
  63216. constructor(engine: Engine, name: string);
  63217. /**
  63218. * Gets the class name
  63219. * @returns "PostProcessRenderPipeline"
  63220. */
  63221. getClassName(): string;
  63222. /**
  63223. * If all the render effects in the pipeline are supported
  63224. */
  63225. get isSupported(): boolean;
  63226. /**
  63227. * Adds an effect to the pipeline
  63228. * @param renderEffect the effect to add
  63229. */
  63230. addEffect(renderEffect: PostProcessRenderEffect): void;
  63231. /** @hidden */
  63232. _rebuild(): void;
  63233. /** @hidden */
  63234. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63235. /** @hidden */
  63236. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63237. /** @hidden */
  63238. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63239. /** @hidden */
  63240. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63241. /** @hidden */
  63242. _attachCameras(cameras: Camera, unique: boolean): void;
  63243. /** @hidden */
  63244. _attachCameras(cameras: Camera[], unique: boolean): void;
  63245. /** @hidden */
  63246. _detachCameras(cameras: Camera): void;
  63247. /** @hidden */
  63248. _detachCameras(cameras: Nullable<Camera[]>): void;
  63249. /** @hidden */
  63250. _update(): void;
  63251. /** @hidden */
  63252. _reset(): void;
  63253. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63254. /**
  63255. * Disposes of the pipeline
  63256. */
  63257. dispose(): void;
  63258. }
  63259. }
  63260. declare module BABYLON {
  63261. /**
  63262. * PostProcessRenderPipelineManager class
  63263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63264. */
  63265. export class PostProcessRenderPipelineManager {
  63266. private _renderPipelines;
  63267. /**
  63268. * Initializes a PostProcessRenderPipelineManager
  63269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63270. */
  63271. constructor();
  63272. /**
  63273. * Gets the list of supported render pipelines
  63274. */
  63275. get supportedPipelines(): PostProcessRenderPipeline[];
  63276. /**
  63277. * Adds a pipeline to the manager
  63278. * @param renderPipeline The pipeline to add
  63279. */
  63280. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63281. /**
  63282. * Attaches a camera to the pipeline
  63283. * @param renderPipelineName The name of the pipeline to attach to
  63284. * @param cameras the camera to attach
  63285. * @param unique if the camera can be attached multiple times to the pipeline
  63286. */
  63287. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63288. /**
  63289. * Detaches a camera from the pipeline
  63290. * @param renderPipelineName The name of the pipeline to detach from
  63291. * @param cameras the camera to detach
  63292. */
  63293. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63294. /**
  63295. * Enables an effect by name on a pipeline
  63296. * @param renderPipelineName the name of the pipeline to enable the effect in
  63297. * @param renderEffectName the name of the effect to enable
  63298. * @param cameras the cameras that the effect should be enabled on
  63299. */
  63300. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63301. /**
  63302. * Disables an effect by name on a pipeline
  63303. * @param renderPipelineName the name of the pipeline to disable the effect in
  63304. * @param renderEffectName the name of the effect to disable
  63305. * @param cameras the cameras that the effect should be disabled on
  63306. */
  63307. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63308. /**
  63309. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63310. */
  63311. update(): void;
  63312. /** @hidden */
  63313. _rebuild(): void;
  63314. /**
  63315. * Disposes of the manager and pipelines
  63316. */
  63317. dispose(): void;
  63318. }
  63319. }
  63320. declare module BABYLON {
  63321. interface Scene {
  63322. /** @hidden (Backing field) */
  63323. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63324. /**
  63325. * Gets the postprocess render pipeline manager
  63326. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63327. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63328. */
  63329. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63330. }
  63331. /**
  63332. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63333. */
  63334. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63335. /**
  63336. * The component name helpfull to identify the component in the list of scene components.
  63337. */
  63338. readonly name: string;
  63339. /**
  63340. * The scene the component belongs to.
  63341. */
  63342. scene: Scene;
  63343. /**
  63344. * Creates a new instance of the component for the given scene
  63345. * @param scene Defines the scene to register the component in
  63346. */
  63347. constructor(scene: Scene);
  63348. /**
  63349. * Registers the component in a given scene
  63350. */
  63351. register(): void;
  63352. /**
  63353. * Rebuilds the elements related to this component in case of
  63354. * context lost for instance.
  63355. */
  63356. rebuild(): void;
  63357. /**
  63358. * Disposes the component and the associated ressources
  63359. */
  63360. dispose(): void;
  63361. private _gatherRenderTargets;
  63362. }
  63363. }
  63364. declare module BABYLON {
  63365. /**
  63366. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63367. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63368. */
  63369. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63370. private _scene;
  63371. private _camerasToBeAttached;
  63372. /**
  63373. * ID of the sharpen post process,
  63374. */
  63375. private readonly SharpenPostProcessId;
  63376. /**
  63377. * @ignore
  63378. * ID of the image processing post process;
  63379. */
  63380. readonly ImageProcessingPostProcessId: string;
  63381. /**
  63382. * @ignore
  63383. * ID of the Fast Approximate Anti-Aliasing post process;
  63384. */
  63385. readonly FxaaPostProcessId: string;
  63386. /**
  63387. * ID of the chromatic aberration post process,
  63388. */
  63389. private readonly ChromaticAberrationPostProcessId;
  63390. /**
  63391. * ID of the grain post process
  63392. */
  63393. private readonly GrainPostProcessId;
  63394. /**
  63395. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63396. */
  63397. sharpen: SharpenPostProcess;
  63398. private _sharpenEffect;
  63399. private bloom;
  63400. /**
  63401. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63402. */
  63403. depthOfField: DepthOfFieldEffect;
  63404. /**
  63405. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63406. */
  63407. fxaa: FxaaPostProcess;
  63408. /**
  63409. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63410. */
  63411. imageProcessing: ImageProcessingPostProcess;
  63412. /**
  63413. * Chromatic aberration post process which will shift rgb colors in the image
  63414. */
  63415. chromaticAberration: ChromaticAberrationPostProcess;
  63416. private _chromaticAberrationEffect;
  63417. /**
  63418. * Grain post process which add noise to the image
  63419. */
  63420. grain: GrainPostProcess;
  63421. private _grainEffect;
  63422. /**
  63423. * Glow post process which adds a glow to emissive areas of the image
  63424. */
  63425. private _glowLayer;
  63426. /**
  63427. * Animations which can be used to tweak settings over a period of time
  63428. */
  63429. animations: Animation[];
  63430. private _imageProcessingConfigurationObserver;
  63431. private _sharpenEnabled;
  63432. private _bloomEnabled;
  63433. private _depthOfFieldEnabled;
  63434. private _depthOfFieldBlurLevel;
  63435. private _fxaaEnabled;
  63436. private _imageProcessingEnabled;
  63437. private _defaultPipelineTextureType;
  63438. private _bloomScale;
  63439. private _chromaticAberrationEnabled;
  63440. private _grainEnabled;
  63441. private _buildAllowed;
  63442. /**
  63443. * Gets active scene
  63444. */
  63445. get scene(): Scene;
  63446. /**
  63447. * Enable or disable the sharpen process from the pipeline
  63448. */
  63449. set sharpenEnabled(enabled: boolean);
  63450. get sharpenEnabled(): boolean;
  63451. private _resizeObserver;
  63452. private _hardwareScaleLevel;
  63453. private _bloomKernel;
  63454. /**
  63455. * Specifies the size of the bloom blur kernel, relative to the final output size
  63456. */
  63457. get bloomKernel(): number;
  63458. set bloomKernel(value: number);
  63459. /**
  63460. * Specifies the weight of the bloom in the final rendering
  63461. */
  63462. private _bloomWeight;
  63463. /**
  63464. * Specifies the luma threshold for the area that will be blurred by the bloom
  63465. */
  63466. private _bloomThreshold;
  63467. private _hdr;
  63468. /**
  63469. * The strength of the bloom.
  63470. */
  63471. set bloomWeight(value: number);
  63472. get bloomWeight(): number;
  63473. /**
  63474. * The strength of the bloom.
  63475. */
  63476. set bloomThreshold(value: number);
  63477. get bloomThreshold(): number;
  63478. /**
  63479. * The scale of the bloom, lower value will provide better performance.
  63480. */
  63481. set bloomScale(value: number);
  63482. get bloomScale(): number;
  63483. /**
  63484. * Enable or disable the bloom from the pipeline
  63485. */
  63486. set bloomEnabled(enabled: boolean);
  63487. get bloomEnabled(): boolean;
  63488. private _rebuildBloom;
  63489. /**
  63490. * If the depth of field is enabled.
  63491. */
  63492. get depthOfFieldEnabled(): boolean;
  63493. set depthOfFieldEnabled(enabled: boolean);
  63494. /**
  63495. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63496. */
  63497. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63498. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63499. /**
  63500. * If the anti aliasing is enabled.
  63501. */
  63502. set fxaaEnabled(enabled: boolean);
  63503. get fxaaEnabled(): boolean;
  63504. private _samples;
  63505. /**
  63506. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63507. */
  63508. set samples(sampleCount: number);
  63509. get samples(): number;
  63510. /**
  63511. * If image processing is enabled.
  63512. */
  63513. set imageProcessingEnabled(enabled: boolean);
  63514. get imageProcessingEnabled(): boolean;
  63515. /**
  63516. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63517. */
  63518. set glowLayerEnabled(enabled: boolean);
  63519. get glowLayerEnabled(): boolean;
  63520. /**
  63521. * Gets the glow layer (or null if not defined)
  63522. */
  63523. get glowLayer(): Nullable<GlowLayer>;
  63524. /**
  63525. * Enable or disable the chromaticAberration process from the pipeline
  63526. */
  63527. set chromaticAberrationEnabled(enabled: boolean);
  63528. get chromaticAberrationEnabled(): boolean;
  63529. /**
  63530. * Enable or disable the grain process from the pipeline
  63531. */
  63532. set grainEnabled(enabled: boolean);
  63533. get grainEnabled(): boolean;
  63534. /**
  63535. * @constructor
  63536. * @param name - The rendering pipeline name (default: "")
  63537. * @param hdr - If high dynamic range textures should be used (default: true)
  63538. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63539. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63540. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63541. */
  63542. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63543. /**
  63544. * Get the class name
  63545. * @returns "DefaultRenderingPipeline"
  63546. */
  63547. getClassName(): string;
  63548. /**
  63549. * Force the compilation of the entire pipeline.
  63550. */
  63551. prepare(): void;
  63552. private _hasCleared;
  63553. private _prevPostProcess;
  63554. private _prevPrevPostProcess;
  63555. private _setAutoClearAndTextureSharing;
  63556. private _depthOfFieldSceneObserver;
  63557. private _buildPipeline;
  63558. private _disposePostProcesses;
  63559. /**
  63560. * Adds a camera to the pipeline
  63561. * @param camera the camera to be added
  63562. */
  63563. addCamera(camera: Camera): void;
  63564. /**
  63565. * Removes a camera from the pipeline
  63566. * @param camera the camera to remove
  63567. */
  63568. removeCamera(camera: Camera): void;
  63569. /**
  63570. * Dispose of the pipeline and stop all post processes
  63571. */
  63572. dispose(): void;
  63573. /**
  63574. * Serialize the rendering pipeline (Used when exporting)
  63575. * @returns the serialized object
  63576. */
  63577. serialize(): any;
  63578. /**
  63579. * Parse the serialized pipeline
  63580. * @param source Source pipeline.
  63581. * @param scene The scene to load the pipeline to.
  63582. * @param rootUrl The URL of the serialized pipeline.
  63583. * @returns An instantiated pipeline from the serialized object.
  63584. */
  63585. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63586. }
  63587. }
  63588. declare module BABYLON {
  63589. /** @hidden */
  63590. export var lensHighlightsPixelShader: {
  63591. name: string;
  63592. shader: string;
  63593. };
  63594. }
  63595. declare module BABYLON {
  63596. /** @hidden */
  63597. export var depthOfFieldPixelShader: {
  63598. name: string;
  63599. shader: string;
  63600. };
  63601. }
  63602. declare module BABYLON {
  63603. /**
  63604. * BABYLON.JS Chromatic Aberration GLSL Shader
  63605. * Author: Olivier Guyot
  63606. * Separates very slightly R, G and B colors on the edges of the screen
  63607. * Inspired by Francois Tarlier & Martins Upitis
  63608. */
  63609. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63610. /**
  63611. * @ignore
  63612. * The chromatic aberration PostProcess id in the pipeline
  63613. */
  63614. LensChromaticAberrationEffect: string;
  63615. /**
  63616. * @ignore
  63617. * The highlights enhancing PostProcess id in the pipeline
  63618. */
  63619. HighlightsEnhancingEffect: string;
  63620. /**
  63621. * @ignore
  63622. * The depth-of-field PostProcess id in the pipeline
  63623. */
  63624. LensDepthOfFieldEffect: string;
  63625. private _scene;
  63626. private _depthTexture;
  63627. private _grainTexture;
  63628. private _chromaticAberrationPostProcess;
  63629. private _highlightsPostProcess;
  63630. private _depthOfFieldPostProcess;
  63631. private _edgeBlur;
  63632. private _grainAmount;
  63633. private _chromaticAberration;
  63634. private _distortion;
  63635. private _highlightsGain;
  63636. private _highlightsThreshold;
  63637. private _dofDistance;
  63638. private _dofAperture;
  63639. private _dofDarken;
  63640. private _dofPentagon;
  63641. private _blurNoise;
  63642. /**
  63643. * @constructor
  63644. *
  63645. * Effect parameters are as follow:
  63646. * {
  63647. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63648. * edge_blur: number; // from 0 to x (1 for realism)
  63649. * distortion: number; // from 0 to x (1 for realism)
  63650. * grain_amount: number; // from 0 to 1
  63651. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63652. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63653. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63654. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63655. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63656. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63657. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63658. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63659. * }
  63660. * Note: if an effect parameter is unset, effect is disabled
  63661. *
  63662. * @param name The rendering pipeline name
  63663. * @param parameters - An object containing all parameters (see above)
  63664. * @param scene The scene linked to this pipeline
  63665. * @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)
  63666. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63667. */
  63668. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63669. /**
  63670. * Get the class name
  63671. * @returns "LensRenderingPipeline"
  63672. */
  63673. getClassName(): string;
  63674. /**
  63675. * Gets associated scene
  63676. */
  63677. get scene(): Scene;
  63678. /**
  63679. * Gets or sets the edge blur
  63680. */
  63681. get edgeBlur(): number;
  63682. set edgeBlur(value: number);
  63683. /**
  63684. * Gets or sets the grain amount
  63685. */
  63686. get grainAmount(): number;
  63687. set grainAmount(value: number);
  63688. /**
  63689. * Gets or sets the chromatic aberration amount
  63690. */
  63691. get chromaticAberration(): number;
  63692. set chromaticAberration(value: number);
  63693. /**
  63694. * Gets or sets the depth of field aperture
  63695. */
  63696. get dofAperture(): number;
  63697. set dofAperture(value: number);
  63698. /**
  63699. * Gets or sets the edge distortion
  63700. */
  63701. get edgeDistortion(): number;
  63702. set edgeDistortion(value: number);
  63703. /**
  63704. * Gets or sets the depth of field distortion
  63705. */
  63706. get dofDistortion(): number;
  63707. set dofDistortion(value: number);
  63708. /**
  63709. * Gets or sets the darken out of focus amount
  63710. */
  63711. get darkenOutOfFocus(): number;
  63712. set darkenOutOfFocus(value: number);
  63713. /**
  63714. * Gets or sets a boolean indicating if blur noise is enabled
  63715. */
  63716. get blurNoise(): boolean;
  63717. set blurNoise(value: boolean);
  63718. /**
  63719. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63720. */
  63721. get pentagonBokeh(): boolean;
  63722. set pentagonBokeh(value: boolean);
  63723. /**
  63724. * Gets or sets the highlight grain amount
  63725. */
  63726. get highlightsGain(): number;
  63727. set highlightsGain(value: number);
  63728. /**
  63729. * Gets or sets the highlight threshold
  63730. */
  63731. get highlightsThreshold(): number;
  63732. set highlightsThreshold(value: number);
  63733. /**
  63734. * Sets the amount of blur at the edges
  63735. * @param amount blur amount
  63736. */
  63737. setEdgeBlur(amount: number): void;
  63738. /**
  63739. * Sets edge blur to 0
  63740. */
  63741. disableEdgeBlur(): void;
  63742. /**
  63743. * Sets the amout of grain
  63744. * @param amount Amount of grain
  63745. */
  63746. setGrainAmount(amount: number): void;
  63747. /**
  63748. * Set grain amount to 0
  63749. */
  63750. disableGrain(): void;
  63751. /**
  63752. * Sets the chromatic aberration amount
  63753. * @param amount amount of chromatic aberration
  63754. */
  63755. setChromaticAberration(amount: number): void;
  63756. /**
  63757. * Sets chromatic aberration amount to 0
  63758. */
  63759. disableChromaticAberration(): void;
  63760. /**
  63761. * Sets the EdgeDistortion amount
  63762. * @param amount amount of EdgeDistortion
  63763. */
  63764. setEdgeDistortion(amount: number): void;
  63765. /**
  63766. * Sets edge distortion to 0
  63767. */
  63768. disableEdgeDistortion(): void;
  63769. /**
  63770. * Sets the FocusDistance amount
  63771. * @param amount amount of FocusDistance
  63772. */
  63773. setFocusDistance(amount: number): void;
  63774. /**
  63775. * Disables depth of field
  63776. */
  63777. disableDepthOfField(): void;
  63778. /**
  63779. * Sets the Aperture amount
  63780. * @param amount amount of Aperture
  63781. */
  63782. setAperture(amount: number): void;
  63783. /**
  63784. * Sets the DarkenOutOfFocus amount
  63785. * @param amount amount of DarkenOutOfFocus
  63786. */
  63787. setDarkenOutOfFocus(amount: number): void;
  63788. private _pentagonBokehIsEnabled;
  63789. /**
  63790. * Creates a pentagon bokeh effect
  63791. */
  63792. enablePentagonBokeh(): void;
  63793. /**
  63794. * Disables the pentagon bokeh effect
  63795. */
  63796. disablePentagonBokeh(): void;
  63797. /**
  63798. * Enables noise blur
  63799. */
  63800. enableNoiseBlur(): void;
  63801. /**
  63802. * Disables noise blur
  63803. */
  63804. disableNoiseBlur(): void;
  63805. /**
  63806. * Sets the HighlightsGain amount
  63807. * @param amount amount of HighlightsGain
  63808. */
  63809. setHighlightsGain(amount: number): void;
  63810. /**
  63811. * Sets the HighlightsThreshold amount
  63812. * @param amount amount of HighlightsThreshold
  63813. */
  63814. setHighlightsThreshold(amount: number): void;
  63815. /**
  63816. * Disables highlights
  63817. */
  63818. disableHighlights(): void;
  63819. /**
  63820. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63821. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63822. */
  63823. dispose(disableDepthRender?: boolean): void;
  63824. private _createChromaticAberrationPostProcess;
  63825. private _createHighlightsPostProcess;
  63826. private _createDepthOfFieldPostProcess;
  63827. private _createGrainTexture;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /** @hidden */
  63832. export var ssao2PixelShader: {
  63833. name: string;
  63834. shader: string;
  63835. };
  63836. }
  63837. declare module BABYLON {
  63838. /** @hidden */
  63839. export var ssaoCombinePixelShader: {
  63840. name: string;
  63841. shader: string;
  63842. };
  63843. }
  63844. declare module BABYLON {
  63845. /**
  63846. * Render pipeline to produce ssao effect
  63847. */
  63848. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63849. /**
  63850. * @ignore
  63851. * The PassPostProcess id in the pipeline that contains the original scene color
  63852. */
  63853. SSAOOriginalSceneColorEffect: string;
  63854. /**
  63855. * @ignore
  63856. * The SSAO PostProcess id in the pipeline
  63857. */
  63858. SSAORenderEffect: string;
  63859. /**
  63860. * @ignore
  63861. * The horizontal blur PostProcess id in the pipeline
  63862. */
  63863. SSAOBlurHRenderEffect: string;
  63864. /**
  63865. * @ignore
  63866. * The vertical blur PostProcess id in the pipeline
  63867. */
  63868. SSAOBlurVRenderEffect: string;
  63869. /**
  63870. * @ignore
  63871. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63872. */
  63873. SSAOCombineRenderEffect: string;
  63874. /**
  63875. * The output strength of the SSAO post-process. Default value is 1.0.
  63876. */
  63877. totalStrength: number;
  63878. /**
  63879. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63880. */
  63881. maxZ: number;
  63882. /**
  63883. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63884. */
  63885. minZAspect: number;
  63886. private _samples;
  63887. /**
  63888. * Number of samples used for the SSAO calculations. Default value is 8
  63889. */
  63890. set samples(n: number);
  63891. get samples(): number;
  63892. private _textureSamples;
  63893. /**
  63894. * Number of samples to use for antialiasing
  63895. */
  63896. set textureSamples(n: number);
  63897. get textureSamples(): number;
  63898. /**
  63899. * Ratio object used for SSAO ratio and blur ratio
  63900. */
  63901. private _ratio;
  63902. /**
  63903. * Dynamically generated sphere sampler.
  63904. */
  63905. private _sampleSphere;
  63906. /**
  63907. * Blur filter offsets
  63908. */
  63909. private _samplerOffsets;
  63910. private _expensiveBlur;
  63911. /**
  63912. * If bilateral blur should be used
  63913. */
  63914. set expensiveBlur(b: boolean);
  63915. get expensiveBlur(): boolean;
  63916. /**
  63917. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63918. */
  63919. radius: number;
  63920. /**
  63921. * The base color of the SSAO post-process
  63922. * The final result is "base + ssao" between [0, 1]
  63923. */
  63924. base: number;
  63925. /**
  63926. * Support test.
  63927. */
  63928. static get IsSupported(): boolean;
  63929. private _scene;
  63930. private _depthTexture;
  63931. private _normalTexture;
  63932. private _randomTexture;
  63933. private _originalColorPostProcess;
  63934. private _ssaoPostProcess;
  63935. private _blurHPostProcess;
  63936. private _blurVPostProcess;
  63937. private _ssaoCombinePostProcess;
  63938. /**
  63939. * Gets active scene
  63940. */
  63941. get scene(): Scene;
  63942. /**
  63943. * @constructor
  63944. * @param name The rendering pipeline name
  63945. * @param scene The scene linked to this pipeline
  63946. * @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 }
  63947. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63948. */
  63949. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63950. /**
  63951. * Get the class name
  63952. * @returns "SSAO2RenderingPipeline"
  63953. */
  63954. getClassName(): string;
  63955. /**
  63956. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63957. */
  63958. dispose(disableGeometryBufferRenderer?: boolean): void;
  63959. private _createBlurPostProcess;
  63960. /** @hidden */
  63961. _rebuild(): void;
  63962. private _bits;
  63963. private _radicalInverse_VdC;
  63964. private _hammersley;
  63965. private _hemisphereSample_uniform;
  63966. private _generateHemisphere;
  63967. private _createSSAOPostProcess;
  63968. private _createSSAOCombinePostProcess;
  63969. private _createRandomTexture;
  63970. /**
  63971. * Serialize the rendering pipeline (Used when exporting)
  63972. * @returns the serialized object
  63973. */
  63974. serialize(): any;
  63975. /**
  63976. * Parse the serialized pipeline
  63977. * @param source Source pipeline.
  63978. * @param scene The scene to load the pipeline to.
  63979. * @param rootUrl The URL of the serialized pipeline.
  63980. * @returns An instantiated pipeline from the serialized object.
  63981. */
  63982. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63983. }
  63984. }
  63985. declare module BABYLON {
  63986. /** @hidden */
  63987. export var ssaoPixelShader: {
  63988. name: string;
  63989. shader: string;
  63990. };
  63991. }
  63992. declare module BABYLON {
  63993. /**
  63994. * Render pipeline to produce ssao effect
  63995. */
  63996. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63997. /**
  63998. * @ignore
  63999. * The PassPostProcess id in the pipeline that contains the original scene color
  64000. */
  64001. SSAOOriginalSceneColorEffect: string;
  64002. /**
  64003. * @ignore
  64004. * The SSAO PostProcess id in the pipeline
  64005. */
  64006. SSAORenderEffect: string;
  64007. /**
  64008. * @ignore
  64009. * The horizontal blur PostProcess id in the pipeline
  64010. */
  64011. SSAOBlurHRenderEffect: string;
  64012. /**
  64013. * @ignore
  64014. * The vertical blur PostProcess id in the pipeline
  64015. */
  64016. SSAOBlurVRenderEffect: string;
  64017. /**
  64018. * @ignore
  64019. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64020. */
  64021. SSAOCombineRenderEffect: string;
  64022. /**
  64023. * The output strength of the SSAO post-process. Default value is 1.0.
  64024. */
  64025. totalStrength: number;
  64026. /**
  64027. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64028. */
  64029. radius: number;
  64030. /**
  64031. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64032. * Must not be equal to fallOff and superior to fallOff.
  64033. * Default value is 0.0075
  64034. */
  64035. area: number;
  64036. /**
  64037. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64038. * Must not be equal to area and inferior to area.
  64039. * Default value is 0.000001
  64040. */
  64041. fallOff: number;
  64042. /**
  64043. * The base color of the SSAO post-process
  64044. * The final result is "base + ssao" between [0, 1]
  64045. */
  64046. base: number;
  64047. private _scene;
  64048. private _depthTexture;
  64049. private _randomTexture;
  64050. private _originalColorPostProcess;
  64051. private _ssaoPostProcess;
  64052. private _blurHPostProcess;
  64053. private _blurVPostProcess;
  64054. private _ssaoCombinePostProcess;
  64055. private _firstUpdate;
  64056. /**
  64057. * Gets active scene
  64058. */
  64059. get scene(): Scene;
  64060. /**
  64061. * @constructor
  64062. * @param name - The rendering pipeline name
  64063. * @param scene - The scene linked to this pipeline
  64064. * @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 }
  64065. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64066. */
  64067. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64068. /**
  64069. * Get the class name
  64070. * @returns "SSAORenderingPipeline"
  64071. */
  64072. getClassName(): string;
  64073. /**
  64074. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64075. */
  64076. dispose(disableDepthRender?: boolean): void;
  64077. private _createBlurPostProcess;
  64078. /** @hidden */
  64079. _rebuild(): void;
  64080. private _createSSAOPostProcess;
  64081. private _createSSAOCombinePostProcess;
  64082. private _createRandomTexture;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /** @hidden */
  64087. export var standardPixelShader: {
  64088. name: string;
  64089. shader: string;
  64090. };
  64091. }
  64092. declare module BABYLON {
  64093. /**
  64094. * Standard rendering pipeline
  64095. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64096. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64097. */
  64098. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64099. /**
  64100. * Public members
  64101. */
  64102. /**
  64103. * Post-process which contains the original scene color before the pipeline applies all the effects
  64104. */
  64105. originalPostProcess: Nullable<PostProcess>;
  64106. /**
  64107. * Post-process used to down scale an image x4
  64108. */
  64109. downSampleX4PostProcess: Nullable<PostProcess>;
  64110. /**
  64111. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64112. */
  64113. brightPassPostProcess: Nullable<PostProcess>;
  64114. /**
  64115. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64116. */
  64117. blurHPostProcesses: PostProcess[];
  64118. /**
  64119. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64120. */
  64121. blurVPostProcesses: PostProcess[];
  64122. /**
  64123. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64124. */
  64125. textureAdderPostProcess: Nullable<PostProcess>;
  64126. /**
  64127. * Post-process used to create volumetric lighting effect
  64128. */
  64129. volumetricLightPostProcess: Nullable<PostProcess>;
  64130. /**
  64131. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64132. */
  64133. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64134. /**
  64135. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64136. */
  64137. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64138. /**
  64139. * Post-process used to merge the volumetric light effect and the real scene color
  64140. */
  64141. volumetricLightMergePostProces: Nullable<PostProcess>;
  64142. /**
  64143. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64144. */
  64145. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64146. /**
  64147. * Base post-process used to calculate the average luminance of the final image for HDR
  64148. */
  64149. luminancePostProcess: Nullable<PostProcess>;
  64150. /**
  64151. * Post-processes used to create down sample post-processes in order to get
  64152. * the average luminance of the final image for HDR
  64153. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64154. */
  64155. luminanceDownSamplePostProcesses: PostProcess[];
  64156. /**
  64157. * Post-process used to create a HDR effect (light adaptation)
  64158. */
  64159. hdrPostProcess: Nullable<PostProcess>;
  64160. /**
  64161. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64162. */
  64163. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64164. /**
  64165. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64166. */
  64167. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64168. /**
  64169. * Post-process used to merge the final HDR post-process and the real scene color
  64170. */
  64171. hdrFinalPostProcess: Nullable<PostProcess>;
  64172. /**
  64173. * Post-process used to create a lens flare effect
  64174. */
  64175. lensFlarePostProcess: Nullable<PostProcess>;
  64176. /**
  64177. * Post-process that merges the result of the lens flare post-process and the real scene color
  64178. */
  64179. lensFlareComposePostProcess: Nullable<PostProcess>;
  64180. /**
  64181. * Post-process used to create a motion blur effect
  64182. */
  64183. motionBlurPostProcess: Nullable<PostProcess>;
  64184. /**
  64185. * Post-process used to create a depth of field effect
  64186. */
  64187. depthOfFieldPostProcess: Nullable<PostProcess>;
  64188. /**
  64189. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64190. */
  64191. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64192. /**
  64193. * Represents the brightness threshold in order to configure the illuminated surfaces
  64194. */
  64195. brightThreshold: number;
  64196. /**
  64197. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64198. */
  64199. blurWidth: number;
  64200. /**
  64201. * Sets if the blur for highlighted surfaces must be only horizontal
  64202. */
  64203. horizontalBlur: boolean;
  64204. /**
  64205. * Gets the overall exposure used by the pipeline
  64206. */
  64207. get exposure(): number;
  64208. /**
  64209. * Sets the overall exposure used by the pipeline
  64210. */
  64211. set exposure(value: number);
  64212. /**
  64213. * Texture used typically to simulate "dirty" on camera lens
  64214. */
  64215. lensTexture: Nullable<Texture>;
  64216. /**
  64217. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64218. */
  64219. volumetricLightCoefficient: number;
  64220. /**
  64221. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64222. */
  64223. volumetricLightPower: number;
  64224. /**
  64225. * Used the set the blur intensity to smooth the volumetric lights
  64226. */
  64227. volumetricLightBlurScale: number;
  64228. /**
  64229. * Light (spot or directional) used to generate the volumetric lights rays
  64230. * The source light must have a shadow generate so the pipeline can get its
  64231. * depth map
  64232. */
  64233. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64234. /**
  64235. * For eye adaptation, represents the minimum luminance the eye can see
  64236. */
  64237. hdrMinimumLuminance: number;
  64238. /**
  64239. * For eye adaptation, represents the decrease luminance speed
  64240. */
  64241. hdrDecreaseRate: number;
  64242. /**
  64243. * For eye adaptation, represents the increase luminance speed
  64244. */
  64245. hdrIncreaseRate: number;
  64246. /**
  64247. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64248. */
  64249. get hdrAutoExposure(): boolean;
  64250. /**
  64251. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64252. */
  64253. set hdrAutoExposure(value: boolean);
  64254. /**
  64255. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64256. */
  64257. lensColorTexture: Nullable<Texture>;
  64258. /**
  64259. * The overall strengh for the lens flare effect
  64260. */
  64261. lensFlareStrength: number;
  64262. /**
  64263. * Dispersion coefficient for lens flare ghosts
  64264. */
  64265. lensFlareGhostDispersal: number;
  64266. /**
  64267. * Main lens flare halo width
  64268. */
  64269. lensFlareHaloWidth: number;
  64270. /**
  64271. * Based on the lens distortion effect, defines how much the lens flare result
  64272. * is distorted
  64273. */
  64274. lensFlareDistortionStrength: number;
  64275. /**
  64276. * Configures the blur intensity used for for lens flare (halo)
  64277. */
  64278. lensFlareBlurWidth: number;
  64279. /**
  64280. * Lens star texture must be used to simulate rays on the flares and is available
  64281. * in the documentation
  64282. */
  64283. lensStarTexture: Nullable<Texture>;
  64284. /**
  64285. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64286. * flare effect by taking account of the dirt texture
  64287. */
  64288. lensFlareDirtTexture: Nullable<Texture>;
  64289. /**
  64290. * Represents the focal length for the depth of field effect
  64291. */
  64292. depthOfFieldDistance: number;
  64293. /**
  64294. * Represents the blur intensity for the blurred part of the depth of field effect
  64295. */
  64296. depthOfFieldBlurWidth: number;
  64297. /**
  64298. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64299. */
  64300. get motionStrength(): number;
  64301. /**
  64302. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64303. */
  64304. set motionStrength(strength: number);
  64305. /**
  64306. * Gets wether or not the motion blur post-process is object based or screen based.
  64307. */
  64308. get objectBasedMotionBlur(): boolean;
  64309. /**
  64310. * Sets wether or not the motion blur post-process should be object based or screen based
  64311. */
  64312. set objectBasedMotionBlur(value: boolean);
  64313. /**
  64314. * List of animations for the pipeline (IAnimatable implementation)
  64315. */
  64316. animations: Animation[];
  64317. /**
  64318. * Private members
  64319. */
  64320. private _scene;
  64321. private _currentDepthOfFieldSource;
  64322. private _basePostProcess;
  64323. private _fixedExposure;
  64324. private _currentExposure;
  64325. private _hdrAutoExposure;
  64326. private _hdrCurrentLuminance;
  64327. private _motionStrength;
  64328. private _isObjectBasedMotionBlur;
  64329. private _floatTextureType;
  64330. private _camerasToBeAttached;
  64331. private _ratio;
  64332. private _bloomEnabled;
  64333. private _depthOfFieldEnabled;
  64334. private _vlsEnabled;
  64335. private _lensFlareEnabled;
  64336. private _hdrEnabled;
  64337. private _motionBlurEnabled;
  64338. private _fxaaEnabled;
  64339. private _motionBlurSamples;
  64340. private _volumetricLightStepsCount;
  64341. private _samples;
  64342. /**
  64343. * @ignore
  64344. * Specifies if the bloom pipeline is enabled
  64345. */
  64346. get BloomEnabled(): boolean;
  64347. set BloomEnabled(enabled: boolean);
  64348. /**
  64349. * @ignore
  64350. * Specifies if the depth of field pipeline is enabed
  64351. */
  64352. get DepthOfFieldEnabled(): boolean;
  64353. set DepthOfFieldEnabled(enabled: boolean);
  64354. /**
  64355. * @ignore
  64356. * Specifies if the lens flare pipeline is enabed
  64357. */
  64358. get LensFlareEnabled(): boolean;
  64359. set LensFlareEnabled(enabled: boolean);
  64360. /**
  64361. * @ignore
  64362. * Specifies if the HDR pipeline is enabled
  64363. */
  64364. get HDREnabled(): boolean;
  64365. set HDREnabled(enabled: boolean);
  64366. /**
  64367. * @ignore
  64368. * Specifies if the volumetric lights scattering effect is enabled
  64369. */
  64370. get VLSEnabled(): boolean;
  64371. set VLSEnabled(enabled: boolean);
  64372. /**
  64373. * @ignore
  64374. * Specifies if the motion blur effect is enabled
  64375. */
  64376. get MotionBlurEnabled(): boolean;
  64377. set MotionBlurEnabled(enabled: boolean);
  64378. /**
  64379. * Specifies if anti-aliasing is enabled
  64380. */
  64381. get fxaaEnabled(): boolean;
  64382. set fxaaEnabled(enabled: boolean);
  64383. /**
  64384. * Specifies the number of steps used to calculate the volumetric lights
  64385. * Typically in interval [50, 200]
  64386. */
  64387. get volumetricLightStepsCount(): number;
  64388. set volumetricLightStepsCount(count: number);
  64389. /**
  64390. * Specifies the number of samples used for the motion blur effect
  64391. * Typically in interval [16, 64]
  64392. */
  64393. get motionBlurSamples(): number;
  64394. set motionBlurSamples(samples: number);
  64395. /**
  64396. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64397. */
  64398. get samples(): number;
  64399. set samples(sampleCount: number);
  64400. /**
  64401. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64402. * @constructor
  64403. * @param name The rendering pipeline name
  64404. * @param scene The scene linked to this pipeline
  64405. * @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)
  64406. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64408. */
  64409. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64410. private _buildPipeline;
  64411. private _createDownSampleX4PostProcess;
  64412. private _createBrightPassPostProcess;
  64413. private _createBlurPostProcesses;
  64414. private _createTextureAdderPostProcess;
  64415. private _createVolumetricLightPostProcess;
  64416. private _createLuminancePostProcesses;
  64417. private _createHdrPostProcess;
  64418. private _createLensFlarePostProcess;
  64419. private _createDepthOfFieldPostProcess;
  64420. private _createMotionBlurPostProcess;
  64421. private _getDepthTexture;
  64422. private _disposePostProcesses;
  64423. /**
  64424. * Dispose of the pipeline and stop all post processes
  64425. */
  64426. dispose(): void;
  64427. /**
  64428. * Serialize the rendering pipeline (Used when exporting)
  64429. * @returns the serialized object
  64430. */
  64431. serialize(): any;
  64432. /**
  64433. * Parse the serialized pipeline
  64434. * @param source Source pipeline.
  64435. * @param scene The scene to load the pipeline to.
  64436. * @param rootUrl The URL of the serialized pipeline.
  64437. * @returns An instantiated pipeline from the serialized object.
  64438. */
  64439. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64440. /**
  64441. * Luminance steps
  64442. */
  64443. static LuminanceSteps: number;
  64444. }
  64445. }
  64446. declare module BABYLON {
  64447. /** @hidden */
  64448. export var tonemapPixelShader: {
  64449. name: string;
  64450. shader: string;
  64451. };
  64452. }
  64453. declare module BABYLON {
  64454. /** Defines operator used for tonemapping */
  64455. export enum TonemappingOperator {
  64456. /** Hable */
  64457. Hable = 0,
  64458. /** Reinhard */
  64459. Reinhard = 1,
  64460. /** HejiDawson */
  64461. HejiDawson = 2,
  64462. /** Photographic */
  64463. Photographic = 3
  64464. }
  64465. /**
  64466. * Defines a post process to apply tone mapping
  64467. */
  64468. export class TonemapPostProcess extends PostProcess {
  64469. private _operator;
  64470. /** Defines the required exposure adjustement */
  64471. exposureAdjustment: number;
  64472. /**
  64473. * Creates a new TonemapPostProcess
  64474. * @param name defines the name of the postprocess
  64475. * @param _operator defines the operator to use
  64476. * @param exposureAdjustment defines the required exposure adjustement
  64477. * @param camera defines the camera to use (can be null)
  64478. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64479. * @param engine defines the hosting engine (can be ignore if camera is set)
  64480. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64481. */
  64482. constructor(name: string, _operator: TonemappingOperator,
  64483. /** Defines the required exposure adjustement */
  64484. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64485. }
  64486. }
  64487. declare module BABYLON {
  64488. /** @hidden */
  64489. export var depthVertexShader: {
  64490. name: string;
  64491. shader: string;
  64492. };
  64493. }
  64494. declare module BABYLON {
  64495. /** @hidden */
  64496. export var volumetricLightScatteringPixelShader: {
  64497. name: string;
  64498. shader: string;
  64499. };
  64500. }
  64501. declare module BABYLON {
  64502. /** @hidden */
  64503. export var volumetricLightScatteringPassVertexShader: {
  64504. name: string;
  64505. shader: string;
  64506. };
  64507. }
  64508. declare module BABYLON {
  64509. /** @hidden */
  64510. export var volumetricLightScatteringPassPixelShader: {
  64511. name: string;
  64512. shader: string;
  64513. };
  64514. }
  64515. declare module BABYLON {
  64516. /**
  64517. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64518. */
  64519. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64520. private _volumetricLightScatteringPass;
  64521. private _volumetricLightScatteringRTT;
  64522. private _viewPort;
  64523. private _screenCoordinates;
  64524. private _cachedDefines;
  64525. /**
  64526. * If not undefined, the mesh position is computed from the attached node position
  64527. */
  64528. attachedNode: {
  64529. position: Vector3;
  64530. };
  64531. /**
  64532. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64533. */
  64534. customMeshPosition: Vector3;
  64535. /**
  64536. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64537. */
  64538. useCustomMeshPosition: boolean;
  64539. /**
  64540. * If the post-process should inverse the light scattering direction
  64541. */
  64542. invert: boolean;
  64543. /**
  64544. * The internal mesh used by the post-process
  64545. */
  64546. mesh: Mesh;
  64547. /**
  64548. * @hidden
  64549. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64550. */
  64551. get useDiffuseColor(): boolean;
  64552. set useDiffuseColor(useDiffuseColor: boolean);
  64553. /**
  64554. * Array containing the excluded meshes not rendered in the internal pass
  64555. */
  64556. excludedMeshes: AbstractMesh[];
  64557. /**
  64558. * Controls the overall intensity of the post-process
  64559. */
  64560. exposure: number;
  64561. /**
  64562. * Dissipates each sample's contribution in range [0, 1]
  64563. */
  64564. decay: number;
  64565. /**
  64566. * Controls the overall intensity of each sample
  64567. */
  64568. weight: number;
  64569. /**
  64570. * Controls the density of each sample
  64571. */
  64572. density: number;
  64573. /**
  64574. * @constructor
  64575. * @param name The post-process name
  64576. * @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)
  64577. * @param camera The camera that the post-process will be attached to
  64578. * @param mesh The mesh used to create the light scattering
  64579. * @param samples The post-process quality, default 100
  64580. * @param samplingModeThe post-process filtering mode
  64581. * @param engine The babylon engine
  64582. * @param reusable If the post-process is reusable
  64583. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64584. */
  64585. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64586. /**
  64587. * Returns the string "VolumetricLightScatteringPostProcess"
  64588. * @returns "VolumetricLightScatteringPostProcess"
  64589. */
  64590. getClassName(): string;
  64591. private _isReady;
  64592. /**
  64593. * Sets the new light position for light scattering effect
  64594. * @param position The new custom light position
  64595. */
  64596. setCustomMeshPosition(position: Vector3): void;
  64597. /**
  64598. * Returns the light position for light scattering effect
  64599. * @return Vector3 The custom light position
  64600. */
  64601. getCustomMeshPosition(): Vector3;
  64602. /**
  64603. * Disposes the internal assets and detaches the post-process from the camera
  64604. */
  64605. dispose(camera: Camera): void;
  64606. /**
  64607. * Returns the render target texture used by the post-process
  64608. * @return the render target texture used by the post-process
  64609. */
  64610. getPass(): RenderTargetTexture;
  64611. private _meshExcluded;
  64612. private _createPass;
  64613. private _updateMeshScreenCoordinates;
  64614. /**
  64615. * Creates a default mesh for the Volumeric Light Scattering post-process
  64616. * @param name The mesh name
  64617. * @param scene The scene where to create the mesh
  64618. * @return the default mesh
  64619. */
  64620. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64621. }
  64622. }
  64623. declare module BABYLON {
  64624. interface Scene {
  64625. /** @hidden (Backing field) */
  64626. _boundingBoxRenderer: BoundingBoxRenderer;
  64627. /** @hidden (Backing field) */
  64628. _forceShowBoundingBoxes: boolean;
  64629. /**
  64630. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64631. */
  64632. forceShowBoundingBoxes: boolean;
  64633. /**
  64634. * Gets the bounding box renderer associated with the scene
  64635. * @returns a BoundingBoxRenderer
  64636. */
  64637. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64638. }
  64639. interface AbstractMesh {
  64640. /** @hidden (Backing field) */
  64641. _showBoundingBox: boolean;
  64642. /**
  64643. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64644. */
  64645. showBoundingBox: boolean;
  64646. }
  64647. /**
  64648. * Component responsible of rendering the bounding box of the meshes in a scene.
  64649. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64650. */
  64651. export class BoundingBoxRenderer implements ISceneComponent {
  64652. /**
  64653. * The component name helpfull to identify the component in the list of scene components.
  64654. */
  64655. readonly name: string;
  64656. /**
  64657. * The scene the component belongs to.
  64658. */
  64659. scene: Scene;
  64660. /**
  64661. * Color of the bounding box lines placed in front of an object
  64662. */
  64663. frontColor: Color3;
  64664. /**
  64665. * Color of the bounding box lines placed behind an object
  64666. */
  64667. backColor: Color3;
  64668. /**
  64669. * Defines if the renderer should show the back lines or not
  64670. */
  64671. showBackLines: boolean;
  64672. /**
  64673. * @hidden
  64674. */
  64675. renderList: SmartArray<BoundingBox>;
  64676. private _colorShader;
  64677. private _vertexBuffers;
  64678. private _indexBuffer;
  64679. private _fillIndexBuffer;
  64680. private _fillIndexData;
  64681. /**
  64682. * Instantiates a new bounding box renderer in a scene.
  64683. * @param scene the scene the renderer renders in
  64684. */
  64685. constructor(scene: Scene);
  64686. /**
  64687. * Registers the component in a given scene
  64688. */
  64689. register(): void;
  64690. private _evaluateSubMesh;
  64691. private _activeMesh;
  64692. private _prepareRessources;
  64693. private _createIndexBuffer;
  64694. /**
  64695. * Rebuilds the elements related to this component in case of
  64696. * context lost for instance.
  64697. */
  64698. rebuild(): void;
  64699. /**
  64700. * @hidden
  64701. */
  64702. reset(): void;
  64703. /**
  64704. * Render the bounding boxes of a specific rendering group
  64705. * @param renderingGroupId defines the rendering group to render
  64706. */
  64707. render(renderingGroupId: number): void;
  64708. /**
  64709. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64710. * @param mesh Define the mesh to render the occlusion bounding box for
  64711. */
  64712. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64713. /**
  64714. * Dispose and release the resources attached to this renderer.
  64715. */
  64716. dispose(): void;
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /** @hidden */
  64721. export var depthPixelShader: {
  64722. name: string;
  64723. shader: string;
  64724. };
  64725. }
  64726. declare module BABYLON {
  64727. /**
  64728. * This represents a depth renderer in Babylon.
  64729. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64730. */
  64731. export class DepthRenderer {
  64732. private _scene;
  64733. private _depthMap;
  64734. private _effect;
  64735. private readonly _storeNonLinearDepth;
  64736. private readonly _clearColor;
  64737. /** Get if the depth renderer is using packed depth or not */
  64738. readonly isPacked: boolean;
  64739. private _cachedDefines;
  64740. private _camera;
  64741. /**
  64742. * Specifiess that the depth renderer will only be used within
  64743. * the camera it is created for.
  64744. * This can help forcing its rendering during the camera processing.
  64745. */
  64746. useOnlyInActiveCamera: boolean;
  64747. /** @hidden */
  64748. static _SceneComponentInitialization: (scene: Scene) => void;
  64749. /**
  64750. * Instantiates a depth renderer
  64751. * @param scene The scene the renderer belongs to
  64752. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64753. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64754. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64755. */
  64756. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64757. /**
  64758. * Creates the depth rendering effect and checks if the effect is ready.
  64759. * @param subMesh The submesh to be used to render the depth map of
  64760. * @param useInstances If multiple world instances should be used
  64761. * @returns if the depth renderer is ready to render the depth map
  64762. */
  64763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64764. /**
  64765. * Gets the texture which the depth map will be written to.
  64766. * @returns The depth map texture
  64767. */
  64768. getDepthMap(): RenderTargetTexture;
  64769. /**
  64770. * Disposes of the depth renderer.
  64771. */
  64772. dispose(): void;
  64773. }
  64774. }
  64775. declare module BABYLON {
  64776. interface Scene {
  64777. /** @hidden (Backing field) */
  64778. _depthRenderer: {
  64779. [id: string]: DepthRenderer;
  64780. };
  64781. /**
  64782. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64783. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64784. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64785. * @returns the created depth renderer
  64786. */
  64787. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64788. /**
  64789. * Disables a depth renderer for a given camera
  64790. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64791. */
  64792. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64793. }
  64794. /**
  64795. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64796. * in several rendering techniques.
  64797. */
  64798. export class DepthRendererSceneComponent implements ISceneComponent {
  64799. /**
  64800. * The component name helpfull to identify the component in the list of scene components.
  64801. */
  64802. readonly name: string;
  64803. /**
  64804. * The scene the component belongs to.
  64805. */
  64806. scene: Scene;
  64807. /**
  64808. * Creates a new instance of the component for the given scene
  64809. * @param scene Defines the scene to register the component in
  64810. */
  64811. constructor(scene: Scene);
  64812. /**
  64813. * Registers the component in a given scene
  64814. */
  64815. register(): void;
  64816. /**
  64817. * Rebuilds the elements related to this component in case of
  64818. * context lost for instance.
  64819. */
  64820. rebuild(): void;
  64821. /**
  64822. * Disposes the component and the associated ressources
  64823. */
  64824. dispose(): void;
  64825. private _gatherRenderTargets;
  64826. private _gatherActiveCameraRenderTargets;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /** @hidden */
  64831. export var outlinePixelShader: {
  64832. name: string;
  64833. shader: string;
  64834. };
  64835. }
  64836. declare module BABYLON {
  64837. /** @hidden */
  64838. export var outlineVertexShader: {
  64839. name: string;
  64840. shader: string;
  64841. };
  64842. }
  64843. declare module BABYLON {
  64844. interface Scene {
  64845. /** @hidden */
  64846. _outlineRenderer: OutlineRenderer;
  64847. /**
  64848. * Gets the outline renderer associated with the scene
  64849. * @returns a OutlineRenderer
  64850. */
  64851. getOutlineRenderer(): OutlineRenderer;
  64852. }
  64853. interface AbstractMesh {
  64854. /** @hidden (Backing field) */
  64855. _renderOutline: boolean;
  64856. /**
  64857. * Gets or sets a boolean indicating if the outline must be rendered as well
  64858. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64859. */
  64860. renderOutline: boolean;
  64861. /** @hidden (Backing field) */
  64862. _renderOverlay: boolean;
  64863. /**
  64864. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64865. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64866. */
  64867. renderOverlay: boolean;
  64868. }
  64869. /**
  64870. * This class is responsible to draw bothe outline/overlay of meshes.
  64871. * It should not be used directly but through the available method on mesh.
  64872. */
  64873. export class OutlineRenderer implements ISceneComponent {
  64874. /**
  64875. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64876. */
  64877. private static _StencilReference;
  64878. /**
  64879. * The name of the component. Each component must have a unique name.
  64880. */
  64881. name: string;
  64882. /**
  64883. * The scene the component belongs to.
  64884. */
  64885. scene: Scene;
  64886. /**
  64887. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64888. */
  64889. zOffset: number;
  64890. private _engine;
  64891. private _effect;
  64892. private _cachedDefines;
  64893. private _savedDepthWrite;
  64894. /**
  64895. * Instantiates a new outline renderer. (There could be only one per scene).
  64896. * @param scene Defines the scene it belongs to
  64897. */
  64898. constructor(scene: Scene);
  64899. /**
  64900. * Register the component to one instance of a scene.
  64901. */
  64902. register(): void;
  64903. /**
  64904. * Rebuilds the elements related to this component in case of
  64905. * context lost for instance.
  64906. */
  64907. rebuild(): void;
  64908. /**
  64909. * Disposes the component and the associated ressources.
  64910. */
  64911. dispose(): void;
  64912. /**
  64913. * Renders the outline in the canvas.
  64914. * @param subMesh Defines the sumesh to render
  64915. * @param batch Defines the batch of meshes in case of instances
  64916. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64917. */
  64918. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64919. /**
  64920. * Returns whether or not the outline renderer is ready for a given submesh.
  64921. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64922. * @param subMesh Defines the submesh to check readyness for
  64923. * @param useInstances Defines wheter wee are trying to render instances or not
  64924. * @returns true if ready otherwise false
  64925. */
  64926. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64927. private _beforeRenderingMesh;
  64928. private _afterRenderingMesh;
  64929. }
  64930. }
  64931. declare module BABYLON {
  64932. /**
  64933. * Defines the basic options interface of a Sprite Frame Source Size.
  64934. */
  64935. export interface ISpriteJSONSpriteSourceSize {
  64936. /**
  64937. * number of the original width of the Frame
  64938. */
  64939. w: number;
  64940. /**
  64941. * number of the original height of the Frame
  64942. */
  64943. h: number;
  64944. }
  64945. /**
  64946. * Defines the basic options interface of a Sprite Frame Data.
  64947. */
  64948. export interface ISpriteJSONSpriteFrameData {
  64949. /**
  64950. * number of the x offset of the Frame
  64951. */
  64952. x: number;
  64953. /**
  64954. * number of the y offset of the Frame
  64955. */
  64956. y: number;
  64957. /**
  64958. * number of the width of the Frame
  64959. */
  64960. w: number;
  64961. /**
  64962. * number of the height of the Frame
  64963. */
  64964. h: number;
  64965. }
  64966. /**
  64967. * Defines the basic options interface of a JSON Sprite.
  64968. */
  64969. export interface ISpriteJSONSprite {
  64970. /**
  64971. * string name of the Frame
  64972. */
  64973. filename: string;
  64974. /**
  64975. * ISpriteJSONSpriteFrame basic object of the frame data
  64976. */
  64977. frame: ISpriteJSONSpriteFrameData;
  64978. /**
  64979. * boolean to flag is the frame was rotated.
  64980. */
  64981. rotated: boolean;
  64982. /**
  64983. * boolean to flag is the frame was trimmed.
  64984. */
  64985. trimmed: boolean;
  64986. /**
  64987. * ISpriteJSONSpriteFrame basic object of the source data
  64988. */
  64989. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64990. /**
  64991. * ISpriteJSONSpriteFrame basic object of the source data
  64992. */
  64993. sourceSize: ISpriteJSONSpriteSourceSize;
  64994. }
  64995. /**
  64996. * Defines the basic options interface of a JSON atlas.
  64997. */
  64998. export interface ISpriteJSONAtlas {
  64999. /**
  65000. * Array of objects that contain the frame data.
  65001. */
  65002. frames: Array<ISpriteJSONSprite>;
  65003. /**
  65004. * object basic object containing the sprite meta data.
  65005. */
  65006. meta?: object;
  65007. }
  65008. }
  65009. declare module BABYLON {
  65010. /** @hidden */
  65011. export var spriteMapPixelShader: {
  65012. name: string;
  65013. shader: string;
  65014. };
  65015. }
  65016. declare module BABYLON {
  65017. /** @hidden */
  65018. export var spriteMapVertexShader: {
  65019. name: string;
  65020. shader: string;
  65021. };
  65022. }
  65023. declare module BABYLON {
  65024. /**
  65025. * Defines the basic options interface of a SpriteMap
  65026. */
  65027. export interface ISpriteMapOptions {
  65028. /**
  65029. * Vector2 of the number of cells in the grid.
  65030. */
  65031. stageSize?: Vector2;
  65032. /**
  65033. * Vector2 of the size of the output plane in World Units.
  65034. */
  65035. outputSize?: Vector2;
  65036. /**
  65037. * Vector3 of the position of the output plane in World Units.
  65038. */
  65039. outputPosition?: Vector3;
  65040. /**
  65041. * Vector3 of the rotation of the output plane.
  65042. */
  65043. outputRotation?: Vector3;
  65044. /**
  65045. * number of layers that the system will reserve in resources.
  65046. */
  65047. layerCount?: number;
  65048. /**
  65049. * number of max animation frames a single cell will reserve in resources.
  65050. */
  65051. maxAnimationFrames?: number;
  65052. /**
  65053. * number cell index of the base tile when the system compiles.
  65054. */
  65055. baseTile?: number;
  65056. /**
  65057. * boolean flip the sprite after its been repositioned by the framing data.
  65058. */
  65059. flipU?: boolean;
  65060. /**
  65061. * Vector3 scalar of the global RGB values of the SpriteMap.
  65062. */
  65063. colorMultiply?: Vector3;
  65064. }
  65065. /**
  65066. * Defines the IDisposable interface in order to be cleanable from resources.
  65067. */
  65068. export interface ISpriteMap extends IDisposable {
  65069. /**
  65070. * String name of the SpriteMap.
  65071. */
  65072. name: string;
  65073. /**
  65074. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  65075. */
  65076. atlasJSON: ISpriteJSONAtlas;
  65077. /**
  65078. * Texture of the SpriteMap.
  65079. */
  65080. spriteSheet: Texture;
  65081. /**
  65082. * The parameters to initialize the SpriteMap with.
  65083. */
  65084. options: ISpriteMapOptions;
  65085. }
  65086. /**
  65087. * Class used to manage a grid restricted sprite deployment on an Output plane.
  65088. */
  65089. export class SpriteMap implements ISpriteMap {
  65090. /** The Name of the spriteMap */
  65091. name: string;
  65092. /** The JSON file with the frame and meta data */
  65093. atlasJSON: ISpriteJSONAtlas;
  65094. /** The systems Sprite Sheet Texture */
  65095. spriteSheet: Texture;
  65096. /** Arguments passed with the Constructor */
  65097. options: ISpriteMapOptions;
  65098. /** Public Sprite Storage array, parsed from atlasJSON */
  65099. sprites: Array<ISpriteJSONSprite>;
  65100. /** Returns the Number of Sprites in the System */
  65101. get spriteCount(): number;
  65102. /** Returns the Position of Output Plane*/
  65103. get position(): Vector3;
  65104. /** Returns the Position of Output Plane*/
  65105. set position(v: Vector3);
  65106. /** Returns the Rotation of Output Plane*/
  65107. get rotation(): Vector3;
  65108. /** Returns the Rotation of Output Plane*/
  65109. set rotation(v: Vector3);
  65110. /** Sets the AnimationMap*/
  65111. get animationMap(): RawTexture;
  65112. /** Sets the AnimationMap*/
  65113. set animationMap(v: RawTexture);
  65114. /** Scene that the SpriteMap was created in */
  65115. private _scene;
  65116. /** Texture Buffer of Float32 that holds tile frame data*/
  65117. private _frameMap;
  65118. /** Texture Buffers of Float32 that holds tileMap data*/
  65119. private _tileMaps;
  65120. /** Texture Buffer of Float32 that holds Animation Data*/
  65121. private _animationMap;
  65122. /** Custom ShaderMaterial Central to the System*/
  65123. private _material;
  65124. /** Custom ShaderMaterial Central to the System*/
  65125. private _output;
  65126. /** Systems Time Ticker*/
  65127. private _time;
  65128. /**
  65129. * Creates a new SpriteMap
  65130. * @param name defines the SpriteMaps Name
  65131. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65132. * @param spriteSheet is the Texture that the Sprites are on.
  65133. * @param options a basic deployment configuration
  65134. * @param scene The Scene that the map is deployed on
  65135. */
  65136. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65137. /**
  65138. * Returns tileID location
  65139. * @returns Vector2 the cell position ID
  65140. */
  65141. getTileID(): Vector2;
  65142. /**
  65143. * Gets the UV location of the mouse over the SpriteMap.
  65144. * @returns Vector2 the UV position of the mouse interaction
  65145. */
  65146. getMousePosition(): Vector2;
  65147. /**
  65148. * Creates the "frame" texture Buffer
  65149. * -------------------------------------
  65150. * Structure of frames
  65151. * "filename": "Falling-Water-2.png",
  65152. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65153. * "rotated": true,
  65154. * "trimmed": true,
  65155. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65156. * "sourceSize": {"w":32,"h":32}
  65157. * @returns RawTexture of the frameMap
  65158. */
  65159. private _createFrameBuffer;
  65160. /**
  65161. * Creates the tileMap texture Buffer
  65162. * @param buffer normally and array of numbers, or a false to generate from scratch
  65163. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65164. * @returns RawTexture of the tileMap
  65165. */
  65166. private _createTileBuffer;
  65167. /**
  65168. * Modifies the data of the tileMaps
  65169. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65170. * @param pos is the iVector2 Coordinates of the Tile
  65171. * @param tile The SpriteIndex of the new Tile
  65172. */
  65173. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65174. /**
  65175. * Creates the animationMap texture Buffer
  65176. * @param buffer normally and array of numbers, or a false to generate from scratch
  65177. * @returns RawTexture of the animationMap
  65178. */
  65179. private _createTileAnimationBuffer;
  65180. /**
  65181. * Modifies the data of the animationMap
  65182. * @param cellID is the Index of the Sprite
  65183. * @param _frame is the target Animation frame
  65184. * @param toCell is the Target Index of the next frame of the animation
  65185. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65186. * @param speed is a global scalar of the time variable on the map.
  65187. */
  65188. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65189. /**
  65190. * Exports the .tilemaps file
  65191. */
  65192. saveTileMaps(): void;
  65193. /**
  65194. * Imports the .tilemaps file
  65195. * @param url of the .tilemaps file
  65196. */
  65197. loadTileMaps(url: string): void;
  65198. /**
  65199. * Release associated resources
  65200. */
  65201. dispose(): void;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65207. * @see http://doc.babylonjs.com/babylon101/sprites
  65208. */
  65209. export class SpritePackedManager extends SpriteManager {
  65210. /** defines the packed manager's name */
  65211. name: string;
  65212. /**
  65213. * Creates a new sprite manager from a packed sprite sheet
  65214. * @param name defines the manager's name
  65215. * @param imgUrl defines the sprite sheet url
  65216. * @param capacity defines the maximum allowed number of sprites
  65217. * @param scene defines the hosting scene
  65218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65219. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65220. * @param samplingMode defines the smapling mode to use with spritesheet
  65221. * @param fromPacked set to true; do not alter
  65222. */
  65223. constructor(
  65224. /** defines the packed manager's name */
  65225. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65226. }
  65227. }
  65228. declare module BABYLON {
  65229. /**
  65230. * Defines the list of states available for a task inside a AssetsManager
  65231. */
  65232. export enum AssetTaskState {
  65233. /**
  65234. * Initialization
  65235. */
  65236. INIT = 0,
  65237. /**
  65238. * Running
  65239. */
  65240. RUNNING = 1,
  65241. /**
  65242. * Done
  65243. */
  65244. DONE = 2,
  65245. /**
  65246. * Error
  65247. */
  65248. ERROR = 3
  65249. }
  65250. /**
  65251. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65252. */
  65253. export abstract class AbstractAssetTask {
  65254. /**
  65255. * Task name
  65256. */ name: string;
  65257. /**
  65258. * Callback called when the task is successful
  65259. */
  65260. onSuccess: (task: any) => void;
  65261. /**
  65262. * Callback called when the task is not successful
  65263. */
  65264. onError: (task: any, message?: string, exception?: any) => void;
  65265. /**
  65266. * Creates a new AssetsManager
  65267. * @param name defines the name of the task
  65268. */
  65269. constructor(
  65270. /**
  65271. * Task name
  65272. */ name: string);
  65273. private _isCompleted;
  65274. private _taskState;
  65275. private _errorObject;
  65276. /**
  65277. * Get if the task is completed
  65278. */
  65279. get isCompleted(): boolean;
  65280. /**
  65281. * Gets the current state of the task
  65282. */
  65283. get taskState(): AssetTaskState;
  65284. /**
  65285. * Gets the current error object (if task is in error)
  65286. */
  65287. get errorObject(): {
  65288. message?: string;
  65289. exception?: any;
  65290. };
  65291. /**
  65292. * Internal only
  65293. * @hidden
  65294. */
  65295. _setErrorObject(message?: string, exception?: any): void;
  65296. /**
  65297. * Execute the current task
  65298. * @param scene defines the scene where you want your assets to be loaded
  65299. * @param onSuccess is a callback called when the task is successfully executed
  65300. * @param onError is a callback called if an error occurs
  65301. */
  65302. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65303. /**
  65304. * Execute the current task
  65305. * @param scene defines the scene where you want your assets to be loaded
  65306. * @param onSuccess is a callback called when the task is successfully executed
  65307. * @param onError is a callback called if an error occurs
  65308. */
  65309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65310. /**
  65311. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65312. * This can be used with failed tasks that have the reason for failure fixed.
  65313. */
  65314. reset(): void;
  65315. private onErrorCallback;
  65316. private onDoneCallback;
  65317. }
  65318. /**
  65319. * Define the interface used by progress events raised during assets loading
  65320. */
  65321. export interface IAssetsProgressEvent {
  65322. /**
  65323. * Defines the number of remaining tasks to process
  65324. */
  65325. remainingCount: number;
  65326. /**
  65327. * Defines the total number of tasks
  65328. */
  65329. totalCount: number;
  65330. /**
  65331. * Defines the task that was just processed
  65332. */
  65333. task: AbstractAssetTask;
  65334. }
  65335. /**
  65336. * Class used to share progress information about assets loading
  65337. */
  65338. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65339. /**
  65340. * Defines the number of remaining tasks to process
  65341. */
  65342. remainingCount: number;
  65343. /**
  65344. * Defines the total number of tasks
  65345. */
  65346. totalCount: number;
  65347. /**
  65348. * Defines the task that was just processed
  65349. */
  65350. task: AbstractAssetTask;
  65351. /**
  65352. * Creates a AssetsProgressEvent
  65353. * @param remainingCount defines the number of remaining tasks to process
  65354. * @param totalCount defines the total number of tasks
  65355. * @param task defines the task that was just processed
  65356. */
  65357. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65358. }
  65359. /**
  65360. * Define a task used by AssetsManager to load meshes
  65361. */
  65362. export class MeshAssetTask extends AbstractAssetTask {
  65363. /**
  65364. * Defines the name of the task
  65365. */
  65366. name: string;
  65367. /**
  65368. * Defines the list of mesh's names you want to load
  65369. */
  65370. meshesNames: any;
  65371. /**
  65372. * Defines the root url to use as a base to load your meshes and associated resources
  65373. */
  65374. rootUrl: string;
  65375. /**
  65376. * Defines the filename of the scene to load from
  65377. */
  65378. sceneFilename: string;
  65379. /**
  65380. * Gets the list of loaded meshes
  65381. */
  65382. loadedMeshes: Array<AbstractMesh>;
  65383. /**
  65384. * Gets the list of loaded particle systems
  65385. */
  65386. loadedParticleSystems: Array<IParticleSystem>;
  65387. /**
  65388. * Gets the list of loaded skeletons
  65389. */
  65390. loadedSkeletons: Array<Skeleton>;
  65391. /**
  65392. * Gets the list of loaded animation groups
  65393. */
  65394. loadedAnimationGroups: Array<AnimationGroup>;
  65395. /**
  65396. * Callback called when the task is successful
  65397. */
  65398. onSuccess: (task: MeshAssetTask) => void;
  65399. /**
  65400. * Callback called when the task is successful
  65401. */
  65402. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65403. /**
  65404. * Creates a new MeshAssetTask
  65405. * @param name defines the name of the task
  65406. * @param meshesNames defines the list of mesh's names you want to load
  65407. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65408. * @param sceneFilename defines the filename of the scene to load from
  65409. */
  65410. constructor(
  65411. /**
  65412. * Defines the name of the task
  65413. */
  65414. name: string,
  65415. /**
  65416. * Defines the list of mesh's names you want to load
  65417. */
  65418. meshesNames: any,
  65419. /**
  65420. * Defines the root url to use as a base to load your meshes and associated resources
  65421. */
  65422. rootUrl: string,
  65423. /**
  65424. * Defines the filename of the scene to load from
  65425. */
  65426. sceneFilename: string);
  65427. /**
  65428. * Execute the current task
  65429. * @param scene defines the scene where you want your assets to be loaded
  65430. * @param onSuccess is a callback called when the task is successfully executed
  65431. * @param onError is a callback called if an error occurs
  65432. */
  65433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65434. }
  65435. /**
  65436. * Define a task used by AssetsManager to load text content
  65437. */
  65438. export class TextFileAssetTask extends AbstractAssetTask {
  65439. /**
  65440. * Defines the name of the task
  65441. */
  65442. name: string;
  65443. /**
  65444. * Defines the location of the file to load
  65445. */
  65446. url: string;
  65447. /**
  65448. * Gets the loaded text string
  65449. */
  65450. text: string;
  65451. /**
  65452. * Callback called when the task is successful
  65453. */
  65454. onSuccess: (task: TextFileAssetTask) => void;
  65455. /**
  65456. * Callback called when the task is successful
  65457. */
  65458. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65459. /**
  65460. * Creates a new TextFileAssetTask object
  65461. * @param name defines the name of the task
  65462. * @param url defines the location of the file to load
  65463. */
  65464. constructor(
  65465. /**
  65466. * Defines the name of the task
  65467. */
  65468. name: string,
  65469. /**
  65470. * Defines the location of the file to load
  65471. */
  65472. url: string);
  65473. /**
  65474. * Execute the current task
  65475. * @param scene defines the scene where you want your assets to be loaded
  65476. * @param onSuccess is a callback called when the task is successfully executed
  65477. * @param onError is a callback called if an error occurs
  65478. */
  65479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65480. }
  65481. /**
  65482. * Define a task used by AssetsManager to load binary data
  65483. */
  65484. export class BinaryFileAssetTask extends AbstractAssetTask {
  65485. /**
  65486. * Defines the name of the task
  65487. */
  65488. name: string;
  65489. /**
  65490. * Defines the location of the file to load
  65491. */
  65492. url: string;
  65493. /**
  65494. * Gets the lodaded data (as an array buffer)
  65495. */
  65496. data: ArrayBuffer;
  65497. /**
  65498. * Callback called when the task is successful
  65499. */
  65500. onSuccess: (task: BinaryFileAssetTask) => void;
  65501. /**
  65502. * Callback called when the task is successful
  65503. */
  65504. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65505. /**
  65506. * Creates a new BinaryFileAssetTask object
  65507. * @param name defines the name of the new task
  65508. * @param url defines the location of the file to load
  65509. */
  65510. constructor(
  65511. /**
  65512. * Defines the name of the task
  65513. */
  65514. name: string,
  65515. /**
  65516. * Defines the location of the file to load
  65517. */
  65518. url: string);
  65519. /**
  65520. * Execute the current task
  65521. * @param scene defines the scene where you want your assets to be loaded
  65522. * @param onSuccess is a callback called when the task is successfully executed
  65523. * @param onError is a callback called if an error occurs
  65524. */
  65525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65526. }
  65527. /**
  65528. * Define a task used by AssetsManager to load images
  65529. */
  65530. export class ImageAssetTask extends AbstractAssetTask {
  65531. /**
  65532. * Defines the name of the task
  65533. */
  65534. name: string;
  65535. /**
  65536. * Defines the location of the image to load
  65537. */
  65538. url: string;
  65539. /**
  65540. * Gets the loaded images
  65541. */
  65542. image: HTMLImageElement;
  65543. /**
  65544. * Callback called when the task is successful
  65545. */
  65546. onSuccess: (task: ImageAssetTask) => void;
  65547. /**
  65548. * Callback called when the task is successful
  65549. */
  65550. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65551. /**
  65552. * Creates a new ImageAssetTask
  65553. * @param name defines the name of the task
  65554. * @param url defines the location of the image to load
  65555. */
  65556. constructor(
  65557. /**
  65558. * Defines the name of the task
  65559. */
  65560. name: string,
  65561. /**
  65562. * Defines the location of the image to load
  65563. */
  65564. url: string);
  65565. /**
  65566. * Execute the current task
  65567. * @param scene defines the scene where you want your assets to be loaded
  65568. * @param onSuccess is a callback called when the task is successfully executed
  65569. * @param onError is a callback called if an error occurs
  65570. */
  65571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65572. }
  65573. /**
  65574. * Defines the interface used by texture loading tasks
  65575. */
  65576. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65577. /**
  65578. * Gets the loaded texture
  65579. */
  65580. texture: TEX;
  65581. }
  65582. /**
  65583. * Define a task used by AssetsManager to load 2D textures
  65584. */
  65585. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65586. /**
  65587. * Defines the name of the task
  65588. */
  65589. name: string;
  65590. /**
  65591. * Defines the location of the file to load
  65592. */
  65593. url: string;
  65594. /**
  65595. * Defines if mipmap should not be generated (default is false)
  65596. */
  65597. noMipmap?: boolean | undefined;
  65598. /**
  65599. * Defines if texture must be inverted on Y axis (default is false)
  65600. */
  65601. invertY?: boolean | undefined;
  65602. /**
  65603. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65604. */
  65605. samplingMode: number;
  65606. /**
  65607. * Gets the loaded texture
  65608. */
  65609. texture: Texture;
  65610. /**
  65611. * Callback called when the task is successful
  65612. */
  65613. onSuccess: (task: TextureAssetTask) => void;
  65614. /**
  65615. * Callback called when the task is successful
  65616. */
  65617. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65618. /**
  65619. * Creates a new TextureAssetTask object
  65620. * @param name defines the name of the task
  65621. * @param url defines the location of the file to load
  65622. * @param noMipmap defines if mipmap should not be generated (default is false)
  65623. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65624. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65625. */
  65626. constructor(
  65627. /**
  65628. * Defines the name of the task
  65629. */
  65630. name: string,
  65631. /**
  65632. * Defines the location of the file to load
  65633. */
  65634. url: string,
  65635. /**
  65636. * Defines if mipmap should not be generated (default is false)
  65637. */
  65638. noMipmap?: boolean | undefined,
  65639. /**
  65640. * Defines if texture must be inverted on Y axis (default is false)
  65641. */
  65642. invertY?: boolean | undefined,
  65643. /**
  65644. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65645. */
  65646. samplingMode?: number);
  65647. /**
  65648. * Execute the current task
  65649. * @param scene defines the scene where you want your assets to be loaded
  65650. * @param onSuccess is a callback called when the task is successfully executed
  65651. * @param onError is a callback called if an error occurs
  65652. */
  65653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65654. }
  65655. /**
  65656. * Define a task used by AssetsManager to load cube textures
  65657. */
  65658. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65659. /**
  65660. * Defines the name of the task
  65661. */
  65662. name: string;
  65663. /**
  65664. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65665. */
  65666. url: string;
  65667. /**
  65668. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65669. */
  65670. extensions?: string[] | undefined;
  65671. /**
  65672. * Defines if mipmaps should not be generated (default is false)
  65673. */
  65674. noMipmap?: boolean | undefined;
  65675. /**
  65676. * Defines the explicit list of files (undefined by default)
  65677. */
  65678. files?: string[] | undefined;
  65679. /**
  65680. * Gets the loaded texture
  65681. */
  65682. texture: CubeTexture;
  65683. /**
  65684. * Callback called when the task is successful
  65685. */
  65686. onSuccess: (task: CubeTextureAssetTask) => void;
  65687. /**
  65688. * Callback called when the task is successful
  65689. */
  65690. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65691. /**
  65692. * Creates a new CubeTextureAssetTask
  65693. * @param name defines the name of the task
  65694. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65695. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65696. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65697. * @param files defines the explicit list of files (undefined by default)
  65698. */
  65699. constructor(
  65700. /**
  65701. * Defines the name of the task
  65702. */
  65703. name: string,
  65704. /**
  65705. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65706. */
  65707. url: string,
  65708. /**
  65709. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65710. */
  65711. extensions?: string[] | undefined,
  65712. /**
  65713. * Defines if mipmaps should not be generated (default is false)
  65714. */
  65715. noMipmap?: boolean | undefined,
  65716. /**
  65717. * Defines the explicit list of files (undefined by default)
  65718. */
  65719. files?: string[] | undefined);
  65720. /**
  65721. * Execute the current task
  65722. * @param scene defines the scene where you want your assets to be loaded
  65723. * @param onSuccess is a callback called when the task is successfully executed
  65724. * @param onError is a callback called if an error occurs
  65725. */
  65726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65727. }
  65728. /**
  65729. * Define a task used by AssetsManager to load HDR cube textures
  65730. */
  65731. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65732. /**
  65733. * Defines the name of the task
  65734. */
  65735. name: string;
  65736. /**
  65737. * Defines the location of the file to load
  65738. */
  65739. url: string;
  65740. /**
  65741. * Defines the desired size (the more it increases the longer the generation will be)
  65742. */
  65743. size: number;
  65744. /**
  65745. * Defines if mipmaps should not be generated (default is false)
  65746. */
  65747. noMipmap: boolean;
  65748. /**
  65749. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65750. */
  65751. generateHarmonics: boolean;
  65752. /**
  65753. * 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)
  65754. */
  65755. gammaSpace: boolean;
  65756. /**
  65757. * Internal Use Only
  65758. */
  65759. reserved: boolean;
  65760. /**
  65761. * Gets the loaded texture
  65762. */
  65763. texture: HDRCubeTexture;
  65764. /**
  65765. * Callback called when the task is successful
  65766. */
  65767. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65768. /**
  65769. * Callback called when the task is successful
  65770. */
  65771. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65772. /**
  65773. * Creates a new HDRCubeTextureAssetTask object
  65774. * @param name defines the name of the task
  65775. * @param url defines the location of the file to load
  65776. * @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.
  65777. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65778. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65779. * @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)
  65780. * @param reserved Internal use only
  65781. */
  65782. constructor(
  65783. /**
  65784. * Defines the name of the task
  65785. */
  65786. name: string,
  65787. /**
  65788. * Defines the location of the file to load
  65789. */
  65790. url: string,
  65791. /**
  65792. * Defines the desired size (the more it increases the longer the generation will be)
  65793. */
  65794. size: number,
  65795. /**
  65796. * Defines if mipmaps should not be generated (default is false)
  65797. */
  65798. noMipmap?: boolean,
  65799. /**
  65800. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65801. */
  65802. generateHarmonics?: boolean,
  65803. /**
  65804. * 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)
  65805. */
  65806. gammaSpace?: boolean,
  65807. /**
  65808. * Internal Use Only
  65809. */
  65810. reserved?: boolean);
  65811. /**
  65812. * Execute the current task
  65813. * @param scene defines the scene where you want your assets to be loaded
  65814. * @param onSuccess is a callback called when the task is successfully executed
  65815. * @param onError is a callback called if an error occurs
  65816. */
  65817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65818. }
  65819. /**
  65820. * Define a task used by AssetsManager to load Equirectangular cube textures
  65821. */
  65822. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65823. /**
  65824. * Defines the name of the task
  65825. */
  65826. name: string;
  65827. /**
  65828. * Defines the location of the file to load
  65829. */
  65830. url: string;
  65831. /**
  65832. * Defines the desired size (the more it increases the longer the generation will be)
  65833. */
  65834. size: number;
  65835. /**
  65836. * Defines if mipmaps should not be generated (default is false)
  65837. */
  65838. noMipmap: boolean;
  65839. /**
  65840. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65841. * but the standard material would require them in Gamma space) (default is true)
  65842. */
  65843. gammaSpace: boolean;
  65844. /**
  65845. * Gets the loaded texture
  65846. */
  65847. texture: EquiRectangularCubeTexture;
  65848. /**
  65849. * Callback called when the task is successful
  65850. */
  65851. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65852. /**
  65853. * Callback called when the task is successful
  65854. */
  65855. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65856. /**
  65857. * Creates a new EquiRectangularCubeTextureAssetTask object
  65858. * @param name defines the name of the task
  65859. * @param url defines the location of the file to load
  65860. * @param size defines the desired size (the more it increases the longer the generation will be)
  65861. * If the size is omitted this implies you are using a preprocessed cubemap.
  65862. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65863. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65864. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65865. * (default is true)
  65866. */
  65867. constructor(
  65868. /**
  65869. * Defines the name of the task
  65870. */
  65871. name: string,
  65872. /**
  65873. * Defines the location of the file to load
  65874. */
  65875. url: string,
  65876. /**
  65877. * Defines the desired size (the more it increases the longer the generation will be)
  65878. */
  65879. size: number,
  65880. /**
  65881. * Defines if mipmaps should not be generated (default is false)
  65882. */
  65883. noMipmap?: boolean,
  65884. /**
  65885. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65886. * but the standard material would require them in Gamma space) (default is true)
  65887. */
  65888. gammaSpace?: boolean);
  65889. /**
  65890. * Execute the current task
  65891. * @param scene defines the scene where you want your assets to be loaded
  65892. * @param onSuccess is a callback called when the task is successfully executed
  65893. * @param onError is a callback called if an error occurs
  65894. */
  65895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65896. }
  65897. /**
  65898. * This class can be used to easily import assets into a scene
  65899. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65900. */
  65901. export class AssetsManager {
  65902. private _scene;
  65903. private _isLoading;
  65904. protected _tasks: AbstractAssetTask[];
  65905. protected _waitingTasksCount: number;
  65906. protected _totalTasksCount: number;
  65907. /**
  65908. * Callback called when all tasks are processed
  65909. */
  65910. onFinish: (tasks: AbstractAssetTask[]) => void;
  65911. /**
  65912. * Callback called when a task is successful
  65913. */
  65914. onTaskSuccess: (task: AbstractAssetTask) => void;
  65915. /**
  65916. * Callback called when a task had an error
  65917. */
  65918. onTaskError: (task: AbstractAssetTask) => void;
  65919. /**
  65920. * Callback called when a task is done (whatever the result is)
  65921. */
  65922. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65923. /**
  65924. * Observable called when all tasks are processed
  65925. */
  65926. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65927. /**
  65928. * Observable called when a task had an error
  65929. */
  65930. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65931. /**
  65932. * Observable called when all tasks were executed
  65933. */
  65934. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65935. /**
  65936. * Observable called when a task is done (whatever the result is)
  65937. */
  65938. onProgressObservable: Observable<IAssetsProgressEvent>;
  65939. /**
  65940. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65942. */
  65943. useDefaultLoadingScreen: boolean;
  65944. /**
  65945. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65946. * when all assets have been downloaded.
  65947. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65948. */
  65949. autoHideLoadingUI: boolean;
  65950. /**
  65951. * Creates a new AssetsManager
  65952. * @param scene defines the scene to work on
  65953. */
  65954. constructor(scene: Scene);
  65955. /**
  65956. * Add a MeshAssetTask to the list of active tasks
  65957. * @param taskName defines the name of the new task
  65958. * @param meshesNames defines the name of meshes to load
  65959. * @param rootUrl defines the root url to use to locate files
  65960. * @param sceneFilename defines the filename of the scene file
  65961. * @returns a new MeshAssetTask object
  65962. */
  65963. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65964. /**
  65965. * Add a TextFileAssetTask to the list of active tasks
  65966. * @param taskName defines the name of the new task
  65967. * @param url defines the url of the file to load
  65968. * @returns a new TextFileAssetTask object
  65969. */
  65970. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65971. /**
  65972. * Add a BinaryFileAssetTask to the list of active tasks
  65973. * @param taskName defines the name of the new task
  65974. * @param url defines the url of the file to load
  65975. * @returns a new BinaryFileAssetTask object
  65976. */
  65977. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65978. /**
  65979. * Add a ImageAssetTask to the list of active tasks
  65980. * @param taskName defines the name of the new task
  65981. * @param url defines the url of the file to load
  65982. * @returns a new ImageAssetTask object
  65983. */
  65984. addImageTask(taskName: string, url: string): ImageAssetTask;
  65985. /**
  65986. * Add a TextureAssetTask to the list of active tasks
  65987. * @param taskName defines the name of the new task
  65988. * @param url defines the url of the file to load
  65989. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65990. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65991. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65992. * @returns a new TextureAssetTask object
  65993. */
  65994. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65995. /**
  65996. * Add a CubeTextureAssetTask to the list of active tasks
  65997. * @param taskName defines the name of the new task
  65998. * @param url defines the url of the file to load
  65999. * @param extensions defines the extension to use to load the cube map (can be null)
  66000. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66001. * @param files defines the list of files to load (can be null)
  66002. * @returns a new CubeTextureAssetTask object
  66003. */
  66004. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66005. /**
  66006. *
  66007. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66008. * @param taskName defines the name of the new task
  66009. * @param url defines the url of the file to load
  66010. * @param size defines the size you want for the cubemap (can be null)
  66011. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66012. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66013. * @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)
  66014. * @param reserved Internal use only
  66015. * @returns a new HDRCubeTextureAssetTask object
  66016. */
  66017. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66018. /**
  66019. *
  66020. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66021. * @param taskName defines the name of the new task
  66022. * @param url defines the url of the file to load
  66023. * @param size defines the size you want for the cubemap (can be null)
  66024. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66025. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66026. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66027. * @returns a new EquiRectangularCubeTextureAssetTask object
  66028. */
  66029. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66030. /**
  66031. * Remove a task from the assets manager.
  66032. * @param task the task to remove
  66033. */
  66034. removeTask(task: AbstractAssetTask): void;
  66035. private _decreaseWaitingTasksCount;
  66036. private _runTask;
  66037. /**
  66038. * Reset the AssetsManager and remove all tasks
  66039. * @return the current instance of the AssetsManager
  66040. */
  66041. reset(): AssetsManager;
  66042. /**
  66043. * Start the loading process
  66044. * @return the current instance of the AssetsManager
  66045. */
  66046. load(): AssetsManager;
  66047. /**
  66048. * Start the loading process as an async operation
  66049. * @return a promise returning the list of failed tasks
  66050. */
  66051. loadAsync(): Promise<void>;
  66052. }
  66053. }
  66054. declare module BABYLON {
  66055. /**
  66056. * Wrapper class for promise with external resolve and reject.
  66057. */
  66058. export class Deferred<T> {
  66059. /**
  66060. * The promise associated with this deferred object.
  66061. */
  66062. readonly promise: Promise<T>;
  66063. private _resolve;
  66064. private _reject;
  66065. /**
  66066. * The resolve method of the promise associated with this deferred object.
  66067. */
  66068. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  66069. /**
  66070. * The reject method of the promise associated with this deferred object.
  66071. */
  66072. get reject(): (reason?: any) => void;
  66073. /**
  66074. * Constructor for this deferred object.
  66075. */
  66076. constructor();
  66077. }
  66078. }
  66079. declare module BABYLON {
  66080. /**
  66081. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66082. */
  66083. export class MeshExploder {
  66084. private _centerMesh;
  66085. private _meshes;
  66086. private _meshesOrigins;
  66087. private _toCenterVectors;
  66088. private _scaledDirection;
  66089. private _newPosition;
  66090. private _centerPosition;
  66091. /**
  66092. * Explodes meshes from a center mesh.
  66093. * @param meshes The meshes to explode.
  66094. * @param centerMesh The mesh to be center of explosion.
  66095. */
  66096. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66097. private _setCenterMesh;
  66098. /**
  66099. * Get class name
  66100. * @returns "MeshExploder"
  66101. */
  66102. getClassName(): string;
  66103. /**
  66104. * "Exploded meshes"
  66105. * @returns Array of meshes with the centerMesh at index 0.
  66106. */
  66107. getMeshes(): Array<Mesh>;
  66108. /**
  66109. * Explodes meshes giving a specific direction
  66110. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66111. */
  66112. explode(direction?: number): void;
  66113. }
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * Class used to help managing file picking and drag'n'drop
  66118. */
  66119. export class FilesInput {
  66120. /**
  66121. * List of files ready to be loaded
  66122. */
  66123. static get FilesToLoad(): {
  66124. [key: string]: File;
  66125. };
  66126. /**
  66127. * Callback called when a file is processed
  66128. */
  66129. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66130. private _engine;
  66131. private _currentScene;
  66132. private _sceneLoadedCallback;
  66133. private _progressCallback;
  66134. private _additionalRenderLoopLogicCallback;
  66135. private _textureLoadingCallback;
  66136. private _startingProcessingFilesCallback;
  66137. private _onReloadCallback;
  66138. private _errorCallback;
  66139. private _elementToMonitor;
  66140. private _sceneFileToLoad;
  66141. private _filesToLoad;
  66142. /**
  66143. * Creates a new FilesInput
  66144. * @param engine defines the rendering engine
  66145. * @param scene defines the hosting scene
  66146. * @param sceneLoadedCallback callback called when scene is loaded
  66147. * @param progressCallback callback called to track progress
  66148. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66149. * @param textureLoadingCallback callback called when a texture is loading
  66150. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66151. * @param onReloadCallback callback called when a reload is requested
  66152. * @param errorCallback callback call if an error occurs
  66153. */
  66154. 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);
  66155. private _dragEnterHandler;
  66156. private _dragOverHandler;
  66157. private _dropHandler;
  66158. /**
  66159. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66160. * @param elementToMonitor defines the DOM element to track
  66161. */
  66162. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66163. /**
  66164. * Release all associated resources
  66165. */
  66166. dispose(): void;
  66167. private renderFunction;
  66168. private drag;
  66169. private drop;
  66170. private _traverseFolder;
  66171. private _processFiles;
  66172. /**
  66173. * Load files from a drop event
  66174. * @param event defines the drop event to use as source
  66175. */
  66176. loadFiles(event: any): void;
  66177. private _processReload;
  66178. /**
  66179. * Reload the current scene from the loaded files
  66180. */
  66181. reload(): void;
  66182. }
  66183. }
  66184. declare module BABYLON {
  66185. /**
  66186. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66188. */
  66189. export class SceneOptimization {
  66190. /**
  66191. * Defines the priority of this optimization (0 by default which means first in the list)
  66192. */
  66193. priority: number;
  66194. /**
  66195. * Gets a string describing the action executed by the current optimization
  66196. * @returns description string
  66197. */
  66198. getDescription(): string;
  66199. /**
  66200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66201. * @param scene defines the current scene where to apply this optimization
  66202. * @param optimizer defines the current optimizer
  66203. * @returns true if everything that can be done was applied
  66204. */
  66205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66206. /**
  66207. * Creates the SceneOptimization object
  66208. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66209. * @param desc defines the description associated with the optimization
  66210. */
  66211. constructor(
  66212. /**
  66213. * Defines the priority of this optimization (0 by default which means first in the list)
  66214. */
  66215. priority?: number);
  66216. }
  66217. /**
  66218. * Defines an optimization used to reduce the size of render target textures
  66219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66220. */
  66221. export class TextureOptimization extends SceneOptimization {
  66222. /**
  66223. * Defines the priority of this optimization (0 by default which means first in the list)
  66224. */
  66225. priority: number;
  66226. /**
  66227. * 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
  66228. */
  66229. maximumSize: number;
  66230. /**
  66231. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66232. */
  66233. step: number;
  66234. /**
  66235. * Gets a string describing the action executed by the current optimization
  66236. * @returns description string
  66237. */
  66238. getDescription(): string;
  66239. /**
  66240. * Creates the TextureOptimization object
  66241. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66242. * @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
  66243. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66244. */
  66245. constructor(
  66246. /**
  66247. * Defines the priority of this optimization (0 by default which means first in the list)
  66248. */
  66249. priority?: number,
  66250. /**
  66251. * 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
  66252. */
  66253. maximumSize?: number,
  66254. /**
  66255. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66256. */
  66257. step?: number);
  66258. /**
  66259. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66260. * @param scene defines the current scene where to apply this optimization
  66261. * @param optimizer defines the current optimizer
  66262. * @returns true if everything that can be done was applied
  66263. */
  66264. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66265. }
  66266. /**
  66267. * Defines an optimization used to increase or decrease the rendering resolution
  66268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66269. */
  66270. export class HardwareScalingOptimization extends SceneOptimization {
  66271. /**
  66272. * Defines the priority of this optimization (0 by default which means first in the list)
  66273. */
  66274. priority: number;
  66275. /**
  66276. * Defines the maximum scale to use (2 by default)
  66277. */
  66278. maximumScale: number;
  66279. /**
  66280. * Defines the step to use between two passes (0.5 by default)
  66281. */
  66282. step: number;
  66283. private _currentScale;
  66284. private _directionOffset;
  66285. /**
  66286. * Gets a string describing the action executed by the current optimization
  66287. * @return description string
  66288. */
  66289. getDescription(): string;
  66290. /**
  66291. * Creates the HardwareScalingOptimization object
  66292. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66293. * @param maximumScale defines the maximum scale to use (2 by default)
  66294. * @param step defines the step to use between two passes (0.5 by default)
  66295. */
  66296. constructor(
  66297. /**
  66298. * Defines the priority of this optimization (0 by default which means first in the list)
  66299. */
  66300. priority?: number,
  66301. /**
  66302. * Defines the maximum scale to use (2 by default)
  66303. */
  66304. maximumScale?: number,
  66305. /**
  66306. * Defines the step to use between two passes (0.5 by default)
  66307. */
  66308. step?: number);
  66309. /**
  66310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66311. * @param scene defines the current scene where to apply this optimization
  66312. * @param optimizer defines the current optimizer
  66313. * @returns true if everything that can be done was applied
  66314. */
  66315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66316. }
  66317. /**
  66318. * Defines an optimization used to remove shadows
  66319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66320. */
  66321. export class ShadowsOptimization extends SceneOptimization {
  66322. /**
  66323. * Gets a string describing the action executed by the current optimization
  66324. * @return description string
  66325. */
  66326. getDescription(): string;
  66327. /**
  66328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66329. * @param scene defines the current scene where to apply this optimization
  66330. * @param optimizer defines the current optimizer
  66331. * @returns true if everything that can be done was applied
  66332. */
  66333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66334. }
  66335. /**
  66336. * Defines an optimization used to turn post-processes off
  66337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66338. */
  66339. export class PostProcessesOptimization extends SceneOptimization {
  66340. /**
  66341. * Gets a string describing the action executed by the current optimization
  66342. * @return description string
  66343. */
  66344. getDescription(): string;
  66345. /**
  66346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66347. * @param scene defines the current scene where to apply this optimization
  66348. * @param optimizer defines the current optimizer
  66349. * @returns true if everything that can be done was applied
  66350. */
  66351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66352. }
  66353. /**
  66354. * Defines an optimization used to turn lens flares off
  66355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66356. */
  66357. export class LensFlaresOptimization extends SceneOptimization {
  66358. /**
  66359. * Gets a string describing the action executed by the current optimization
  66360. * @return description string
  66361. */
  66362. getDescription(): string;
  66363. /**
  66364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66365. * @param scene defines the current scene where to apply this optimization
  66366. * @param optimizer defines the current optimizer
  66367. * @returns true if everything that can be done was applied
  66368. */
  66369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66370. }
  66371. /**
  66372. * Defines an optimization based on user defined callback.
  66373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66374. */
  66375. export class CustomOptimization extends SceneOptimization {
  66376. /**
  66377. * Callback called to apply the custom optimization.
  66378. */
  66379. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66380. /**
  66381. * Callback called to get custom description
  66382. */
  66383. onGetDescription: () => string;
  66384. /**
  66385. * Gets a string describing the action executed by the current optimization
  66386. * @returns description string
  66387. */
  66388. getDescription(): string;
  66389. /**
  66390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66391. * @param scene defines the current scene where to apply this optimization
  66392. * @param optimizer defines the current optimizer
  66393. * @returns true if everything that can be done was applied
  66394. */
  66395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66396. }
  66397. /**
  66398. * Defines an optimization used to turn particles off
  66399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66400. */
  66401. export class ParticlesOptimization extends SceneOptimization {
  66402. /**
  66403. * Gets a string describing the action executed by the current optimization
  66404. * @return description string
  66405. */
  66406. getDescription(): string;
  66407. /**
  66408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66409. * @param scene defines the current scene where to apply this optimization
  66410. * @param optimizer defines the current optimizer
  66411. * @returns true if everything that can be done was applied
  66412. */
  66413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66414. }
  66415. /**
  66416. * Defines an optimization used to turn render targets off
  66417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66418. */
  66419. export class RenderTargetsOptimization extends SceneOptimization {
  66420. /**
  66421. * Gets a string describing the action executed by the current optimization
  66422. * @return description string
  66423. */
  66424. getDescription(): string;
  66425. /**
  66426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66427. * @param scene defines the current scene where to apply this optimization
  66428. * @param optimizer defines the current optimizer
  66429. * @returns true if everything that can be done was applied
  66430. */
  66431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66432. }
  66433. /**
  66434. * Defines an optimization used to merge meshes with compatible materials
  66435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66436. */
  66437. export class MergeMeshesOptimization extends SceneOptimization {
  66438. private static _UpdateSelectionTree;
  66439. /**
  66440. * Gets or sets a boolean which defines if optimization octree has to be updated
  66441. */
  66442. static get UpdateSelectionTree(): boolean;
  66443. /**
  66444. * Gets or sets a boolean which defines if optimization octree has to be updated
  66445. */
  66446. static set UpdateSelectionTree(value: boolean);
  66447. /**
  66448. * Gets a string describing the action executed by the current optimization
  66449. * @return description string
  66450. */
  66451. getDescription(): string;
  66452. private _canBeMerged;
  66453. /**
  66454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66455. * @param scene defines the current scene where to apply this optimization
  66456. * @param optimizer defines the current optimizer
  66457. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66458. * @returns true if everything that can be done was applied
  66459. */
  66460. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66461. }
  66462. /**
  66463. * Defines a list of options used by SceneOptimizer
  66464. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66465. */
  66466. export class SceneOptimizerOptions {
  66467. /**
  66468. * Defines the target frame rate to reach (60 by default)
  66469. */
  66470. targetFrameRate: number;
  66471. /**
  66472. * Defines the interval between two checkes (2000ms by default)
  66473. */
  66474. trackerDuration: number;
  66475. /**
  66476. * Gets the list of optimizations to apply
  66477. */
  66478. optimizations: SceneOptimization[];
  66479. /**
  66480. * Creates a new list of options used by SceneOptimizer
  66481. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66482. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66483. */
  66484. constructor(
  66485. /**
  66486. * Defines the target frame rate to reach (60 by default)
  66487. */
  66488. targetFrameRate?: number,
  66489. /**
  66490. * Defines the interval between two checkes (2000ms by default)
  66491. */
  66492. trackerDuration?: number);
  66493. /**
  66494. * Add a new optimization
  66495. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66496. * @returns the current SceneOptimizerOptions
  66497. */
  66498. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66499. /**
  66500. * Add a new custom optimization
  66501. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66502. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66503. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66504. * @returns the current SceneOptimizerOptions
  66505. */
  66506. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66507. /**
  66508. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66509. * @param targetFrameRate defines the target frame rate (60 by default)
  66510. * @returns a SceneOptimizerOptions object
  66511. */
  66512. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66513. /**
  66514. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66515. * @param targetFrameRate defines the target frame rate (60 by default)
  66516. * @returns a SceneOptimizerOptions object
  66517. */
  66518. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66519. /**
  66520. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66521. * @param targetFrameRate defines the target frame rate (60 by default)
  66522. * @returns a SceneOptimizerOptions object
  66523. */
  66524. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66525. }
  66526. /**
  66527. * Class used to run optimizations in order to reach a target frame rate
  66528. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66529. */
  66530. export class SceneOptimizer implements IDisposable {
  66531. private _isRunning;
  66532. private _options;
  66533. private _scene;
  66534. private _currentPriorityLevel;
  66535. private _targetFrameRate;
  66536. private _trackerDuration;
  66537. private _currentFrameRate;
  66538. private _sceneDisposeObserver;
  66539. private _improvementMode;
  66540. /**
  66541. * Defines an observable called when the optimizer reaches the target frame rate
  66542. */
  66543. onSuccessObservable: Observable<SceneOptimizer>;
  66544. /**
  66545. * Defines an observable called when the optimizer enables an optimization
  66546. */
  66547. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66548. /**
  66549. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66550. */
  66551. onFailureObservable: Observable<SceneOptimizer>;
  66552. /**
  66553. * Gets a boolean indicating if the optimizer is in improvement mode
  66554. */
  66555. get isInImprovementMode(): boolean;
  66556. /**
  66557. * Gets the current priority level (0 at start)
  66558. */
  66559. get currentPriorityLevel(): number;
  66560. /**
  66561. * Gets the current frame rate checked by the SceneOptimizer
  66562. */
  66563. get currentFrameRate(): number;
  66564. /**
  66565. * Gets or sets the current target frame rate (60 by default)
  66566. */
  66567. get targetFrameRate(): number;
  66568. /**
  66569. * Gets or sets the current target frame rate (60 by default)
  66570. */
  66571. set targetFrameRate(value: number);
  66572. /**
  66573. * Gets or sets the current interval between two checks (every 2000ms by default)
  66574. */
  66575. get trackerDuration(): number;
  66576. /**
  66577. * Gets or sets the current interval between two checks (every 2000ms by default)
  66578. */
  66579. set trackerDuration(value: number);
  66580. /**
  66581. * Gets the list of active optimizations
  66582. */
  66583. get optimizations(): SceneOptimization[];
  66584. /**
  66585. * Creates a new SceneOptimizer
  66586. * @param scene defines the scene to work on
  66587. * @param options defines the options to use with the SceneOptimizer
  66588. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66589. * @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)
  66590. */
  66591. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66592. /**
  66593. * Stops the current optimizer
  66594. */
  66595. stop(): void;
  66596. /**
  66597. * Reset the optimizer to initial step (current priority level = 0)
  66598. */
  66599. reset(): void;
  66600. /**
  66601. * Start the optimizer. By default it will try to reach a specific framerate
  66602. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66603. */
  66604. start(): void;
  66605. private _checkCurrentState;
  66606. /**
  66607. * Release all resources
  66608. */
  66609. dispose(): void;
  66610. /**
  66611. * Helper function to create a SceneOptimizer with one single line of code
  66612. * @param scene defines the scene to work on
  66613. * @param options defines the options to use with the SceneOptimizer
  66614. * @param onSuccess defines a callback to call on success
  66615. * @param onFailure defines a callback to call on failure
  66616. * @returns the new SceneOptimizer object
  66617. */
  66618. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66619. }
  66620. }
  66621. declare module BABYLON {
  66622. /**
  66623. * Class used to serialize a scene into a string
  66624. */
  66625. export class SceneSerializer {
  66626. /**
  66627. * Clear cache used by a previous serialization
  66628. */
  66629. static ClearCache(): void;
  66630. /**
  66631. * Serialize a scene into a JSON compatible object
  66632. * @param scene defines the scene to serialize
  66633. * @returns a JSON compatible object
  66634. */
  66635. static Serialize(scene: Scene): any;
  66636. /**
  66637. * Serialize a mesh into a JSON compatible object
  66638. * @param toSerialize defines the mesh to serialize
  66639. * @param withParents defines if parents must be serialized as well
  66640. * @param withChildren defines if children must be serialized as well
  66641. * @returns a JSON compatible object
  66642. */
  66643. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66644. }
  66645. }
  66646. declare module BABYLON {
  66647. /**
  66648. * Class used to host texture specific utilities
  66649. */
  66650. export class TextureTools {
  66651. /**
  66652. * Uses the GPU to create a copy texture rescaled at a given size
  66653. * @param texture Texture to copy from
  66654. * @param width defines the desired width
  66655. * @param height defines the desired height
  66656. * @param useBilinearMode defines if bilinear mode has to be used
  66657. * @return the generated texture
  66658. */
  66659. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66660. }
  66661. }
  66662. declare module BABYLON {
  66663. /**
  66664. * This represents the different options available for the video capture.
  66665. */
  66666. export interface VideoRecorderOptions {
  66667. /** Defines the mime type of the video. */
  66668. mimeType: string;
  66669. /** Defines the FPS the video should be recorded at. */
  66670. fps: number;
  66671. /** Defines the chunk size for the recording data. */
  66672. recordChunckSize: number;
  66673. /** The audio tracks to attach to the recording. */
  66674. audioTracks?: MediaStreamTrack[];
  66675. }
  66676. /**
  66677. * This can help with recording videos from BabylonJS.
  66678. * This is based on the available WebRTC functionalities of the browser.
  66679. *
  66680. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66681. */
  66682. export class VideoRecorder {
  66683. private static readonly _defaultOptions;
  66684. /**
  66685. * Returns whether or not the VideoRecorder is available in your browser.
  66686. * @param engine Defines the Babylon Engine.
  66687. * @returns true if supported otherwise false.
  66688. */
  66689. static IsSupported(engine: Engine): boolean;
  66690. private readonly _options;
  66691. private _canvas;
  66692. private _mediaRecorder;
  66693. private _recordedChunks;
  66694. private _fileName;
  66695. private _resolve;
  66696. private _reject;
  66697. /**
  66698. * True when a recording is already in progress.
  66699. */
  66700. get isRecording(): boolean;
  66701. /**
  66702. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66703. * @param engine Defines the BabylonJS Engine you wish to record.
  66704. * @param options Defines options that can be used to customize the capture.
  66705. */
  66706. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66707. /**
  66708. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66709. */
  66710. stopRecording(): void;
  66711. /**
  66712. * Starts recording the canvas for a max duration specified in parameters.
  66713. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66714. * If null no automatic download will start and you can rely on the promise to get the data back.
  66715. * @param maxDuration Defines the maximum recording time in seconds.
  66716. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66717. * @return A promise callback at the end of the recording with the video data in Blob.
  66718. */
  66719. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66720. /**
  66721. * Releases internal resources used during the recording.
  66722. */
  66723. dispose(): void;
  66724. private _handleDataAvailable;
  66725. private _handleError;
  66726. private _handleStop;
  66727. }
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * Class containing a set of static utilities functions for screenshots
  66732. */
  66733. export class ScreenshotTools {
  66734. /**
  66735. * Captures a screenshot of the current rendering
  66736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66737. * @param engine defines the rendering engine
  66738. * @param camera defines the source camera
  66739. * @param size This parameter can be set to a single number or to an object with the
  66740. * following (optional) properties: precision, width, height. If a single number is passed,
  66741. * it will be used for both width and height. If an object is passed, the screenshot size
  66742. * will be derived from the parameters. The precision property is a multiplier allowing
  66743. * rendering at a higher or lower resolution
  66744. * @param successCallback defines the callback receives a single parameter which contains the
  66745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66746. * src parameter of an <img> to display it
  66747. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66748. * Check your browser for supported MIME types
  66749. */
  66750. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66751. /**
  66752. * Captures a screenshot of the current rendering
  66753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66754. * @param engine defines the rendering engine
  66755. * @param camera defines the source camera
  66756. * @param size This parameter can be set to a single number or to an object with the
  66757. * following (optional) properties: precision, width, height. If a single number is passed,
  66758. * it will be used for both width and height. If an object is passed, the screenshot size
  66759. * will be derived from the parameters. The precision property is a multiplier allowing
  66760. * rendering at a higher or lower resolution
  66761. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66762. * Check your browser for supported MIME types
  66763. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66764. * to the src parameter of an <img> to display it
  66765. */
  66766. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66767. /**
  66768. * Generates an image screenshot from the specified camera.
  66769. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66770. * @param engine The engine to use for rendering
  66771. * @param camera The camera to use for rendering
  66772. * @param size This parameter can be set to a single number or to an object with the
  66773. * following (optional) properties: precision, width, height. If a single number is passed,
  66774. * it will be used for both width and height. If an object is passed, the screenshot size
  66775. * will be derived from the parameters. The precision property is a multiplier allowing
  66776. * rendering at a higher or lower resolution
  66777. * @param successCallback The callback receives a single parameter which contains the
  66778. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66779. * src parameter of an <img> to display it
  66780. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66781. * Check your browser for supported MIME types
  66782. * @param samples Texture samples (default: 1)
  66783. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66784. * @param fileName A name for for the downloaded file.
  66785. */
  66786. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66787. /**
  66788. * Generates an image screenshot from the specified camera.
  66789. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66790. * @param engine The engine to use for rendering
  66791. * @param camera The camera to use for rendering
  66792. * @param size This parameter can be set to a single number or to an object with the
  66793. * following (optional) properties: precision, width, height. If a single number is passed,
  66794. * it will be used for both width and height. If an object is passed, the screenshot size
  66795. * will be derived from the parameters. The precision property is a multiplier allowing
  66796. * rendering at a higher or lower resolution
  66797. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66798. * Check your browser for supported MIME types
  66799. * @param samples Texture samples (default: 1)
  66800. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66801. * @param fileName A name for for the downloaded file.
  66802. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66803. * to the src parameter of an <img> to display it
  66804. */
  66805. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66806. /**
  66807. * Gets height and width for screenshot size
  66808. * @private
  66809. */
  66810. private static _getScreenshotSize;
  66811. }
  66812. }
  66813. declare module BABYLON {
  66814. /**
  66815. * Interface for a data buffer
  66816. */
  66817. export interface IDataBuffer {
  66818. /**
  66819. * Reads bytes from the data buffer.
  66820. * @param byteOffset The byte offset to read
  66821. * @param byteLength The byte length to read
  66822. * @returns A promise that resolves when the bytes are read
  66823. */
  66824. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66825. /**
  66826. * The byte length of the buffer.
  66827. */
  66828. readonly byteLength: number;
  66829. }
  66830. /**
  66831. * Utility class for reading from a data buffer
  66832. */
  66833. export class DataReader {
  66834. /**
  66835. * The data buffer associated with this data reader.
  66836. */
  66837. readonly buffer: IDataBuffer;
  66838. /**
  66839. * The current byte offset from the beginning of the data buffer.
  66840. */
  66841. byteOffset: number;
  66842. private _dataView;
  66843. private _dataByteOffset;
  66844. /**
  66845. * Constructor
  66846. * @param buffer The buffer to read
  66847. */
  66848. constructor(buffer: IDataBuffer);
  66849. /**
  66850. * Loads the given byte length.
  66851. * @param byteLength The byte length to load
  66852. * @returns A promise that resolves when the load is complete
  66853. */
  66854. loadAsync(byteLength: number): Promise<void>;
  66855. /**
  66856. * Read a unsigned 32-bit integer from the currently loaded data range.
  66857. * @returns The 32-bit integer read
  66858. */
  66859. readUint32(): number;
  66860. /**
  66861. * Read a byte array from the currently loaded data range.
  66862. * @param byteLength The byte length to read
  66863. * @returns The byte array read
  66864. */
  66865. readUint8Array(byteLength: number): Uint8Array;
  66866. /**
  66867. * Read a string from the currently loaded data range.
  66868. * @param byteLength The byte length to read
  66869. * @returns The string read
  66870. */
  66871. readString(byteLength: number): string;
  66872. /**
  66873. * Skips the given byte length the currently loaded data range.
  66874. * @param byteLength The byte length to skip
  66875. */
  66876. skipBytes(byteLength: number): void;
  66877. }
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * A cursor which tracks a point on a path
  66882. */
  66883. export class PathCursor {
  66884. private path;
  66885. /**
  66886. * Stores path cursor callbacks for when an onchange event is triggered
  66887. */
  66888. private _onchange;
  66889. /**
  66890. * The value of the path cursor
  66891. */
  66892. value: number;
  66893. /**
  66894. * The animation array of the path cursor
  66895. */
  66896. animations: Animation[];
  66897. /**
  66898. * Initializes the path cursor
  66899. * @param path The path to track
  66900. */
  66901. constructor(path: Path2);
  66902. /**
  66903. * Gets the cursor point on the path
  66904. * @returns A point on the path cursor at the cursor location
  66905. */
  66906. getPoint(): Vector3;
  66907. /**
  66908. * Moves the cursor ahead by the step amount
  66909. * @param step The amount to move the cursor forward
  66910. * @returns This path cursor
  66911. */
  66912. moveAhead(step?: number): PathCursor;
  66913. /**
  66914. * Moves the cursor behind by the step amount
  66915. * @param step The amount to move the cursor back
  66916. * @returns This path cursor
  66917. */
  66918. moveBack(step?: number): PathCursor;
  66919. /**
  66920. * Moves the cursor by the step amount
  66921. * If the step amount is greater than one, an exception is thrown
  66922. * @param step The amount to move the cursor
  66923. * @returns This path cursor
  66924. */
  66925. move(step: number): PathCursor;
  66926. /**
  66927. * Ensures that the value is limited between zero and one
  66928. * @returns This path cursor
  66929. */
  66930. private ensureLimits;
  66931. /**
  66932. * Runs onchange callbacks on change (used by the animation engine)
  66933. * @returns This path cursor
  66934. */
  66935. private raiseOnChange;
  66936. /**
  66937. * Executes a function on change
  66938. * @param f A path cursor onchange callback
  66939. * @returns This path cursor
  66940. */
  66941. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66942. }
  66943. }
  66944. declare module BABYLON {
  66945. /** @hidden */
  66946. export var blurPixelShader: {
  66947. name: string;
  66948. shader: string;
  66949. };
  66950. }
  66951. declare module BABYLON {
  66952. /** @hidden */
  66953. export var pointCloudVertexDeclaration: {
  66954. name: string;
  66955. shader: string;
  66956. };
  66957. }
  66958. // Mixins
  66959. interface Window {
  66960. mozIndexedDB: IDBFactory;
  66961. webkitIndexedDB: IDBFactory;
  66962. msIndexedDB: IDBFactory;
  66963. webkitURL: typeof URL;
  66964. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66965. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66966. WebGLRenderingContext: WebGLRenderingContext;
  66967. MSGesture: MSGesture;
  66968. CANNON: any;
  66969. AudioContext: AudioContext;
  66970. webkitAudioContext: AudioContext;
  66971. PointerEvent: any;
  66972. Math: Math;
  66973. Uint8Array: Uint8ArrayConstructor;
  66974. Float32Array: Float32ArrayConstructor;
  66975. mozURL: typeof URL;
  66976. msURL: typeof URL;
  66977. VRFrameData: any; // WebVR, from specs 1.1
  66978. DracoDecoderModule: any;
  66979. setImmediate(handler: (...args: any[]) => void): number;
  66980. }
  66981. interface HTMLCanvasElement {
  66982. requestPointerLock(): void;
  66983. msRequestPointerLock?(): void;
  66984. mozRequestPointerLock?(): void;
  66985. webkitRequestPointerLock?(): void;
  66986. /** Track wether a record is in progress */
  66987. isRecording: boolean;
  66988. /** Capture Stream method defined by some browsers */
  66989. captureStream(fps?: number): MediaStream;
  66990. }
  66991. interface CanvasRenderingContext2D {
  66992. msImageSmoothingEnabled: boolean;
  66993. }
  66994. interface MouseEvent {
  66995. mozMovementX: number;
  66996. mozMovementY: number;
  66997. webkitMovementX: number;
  66998. webkitMovementY: number;
  66999. msMovementX: number;
  67000. msMovementY: number;
  67001. }
  67002. interface Navigator {
  67003. mozGetVRDevices: (any: any) => any;
  67004. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67005. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67006. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67007. webkitGetGamepads(): Gamepad[];
  67008. msGetGamepads(): Gamepad[];
  67009. webkitGamepads(): Gamepad[];
  67010. }
  67011. interface HTMLVideoElement {
  67012. mozSrcObject: any;
  67013. }
  67014. interface Math {
  67015. fround(x: number): number;
  67016. imul(a: number, b: number): number;
  67017. }
  67018. interface WebGLRenderingContext {
  67019. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  67020. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  67021. vertexAttribDivisor(index: number, divisor: number): void;
  67022. createVertexArray(): any;
  67023. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  67024. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  67025. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  67026. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  67027. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  67028. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  67029. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  67030. // Queries
  67031. createQuery(): WebGLQuery;
  67032. deleteQuery(query: WebGLQuery): void;
  67033. beginQuery(target: number, query: WebGLQuery): void;
  67034. endQuery(target: number): void;
  67035. getQueryParameter(query: WebGLQuery, pname: number): any;
  67036. getQuery(target: number, pname: number): any;
  67037. MAX_SAMPLES: number;
  67038. RGBA8: number;
  67039. READ_FRAMEBUFFER: number;
  67040. DRAW_FRAMEBUFFER: number;
  67041. UNIFORM_BUFFER: number;
  67042. HALF_FLOAT_OES: number;
  67043. RGBA16F: number;
  67044. RGBA32F: number;
  67045. R32F: number;
  67046. RG32F: number;
  67047. RGB32F: number;
  67048. R16F: number;
  67049. RG16F: number;
  67050. RGB16F: number;
  67051. RED: number;
  67052. RG: number;
  67053. R8: number;
  67054. RG8: number;
  67055. UNSIGNED_INT_24_8: number;
  67056. DEPTH24_STENCIL8: number;
  67057. MIN: number;
  67058. MAX: number;
  67059. /* Multiple Render Targets */
  67060. drawBuffers(buffers: number[]): void;
  67061. readBuffer(src: number): void;
  67062. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  67063. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  67064. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  67065. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  67066. // Occlusion Query
  67067. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  67068. ANY_SAMPLES_PASSED: number;
  67069. QUERY_RESULT_AVAILABLE: number;
  67070. QUERY_RESULT: number;
  67071. }
  67072. interface WebGLProgram {
  67073. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  67074. }
  67075. interface EXT_disjoint_timer_query {
  67076. QUERY_COUNTER_BITS_EXT: number;
  67077. TIME_ELAPSED_EXT: number;
  67078. TIMESTAMP_EXT: number;
  67079. GPU_DISJOINT_EXT: number;
  67080. QUERY_RESULT_EXT: number;
  67081. QUERY_RESULT_AVAILABLE_EXT: number;
  67082. queryCounterEXT(query: WebGLQuery, target: number): void;
  67083. createQueryEXT(): WebGLQuery;
  67084. beginQueryEXT(target: number, query: WebGLQuery): void;
  67085. endQueryEXT(target: number): void;
  67086. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  67087. deleteQueryEXT(query: WebGLQuery): void;
  67088. }
  67089. interface WebGLUniformLocation {
  67090. _currentState: any;
  67091. }
  67092. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  67093. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  67094. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  67095. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67096. interface WebGLRenderingContext {
  67097. readonly RASTERIZER_DISCARD: number;
  67098. readonly DEPTH_COMPONENT24: number;
  67099. readonly TEXTURE_3D: number;
  67100. readonly TEXTURE_2D_ARRAY: number;
  67101. readonly TEXTURE_COMPARE_FUNC: number;
  67102. readonly TEXTURE_COMPARE_MODE: number;
  67103. readonly COMPARE_REF_TO_TEXTURE: number;
  67104. readonly TEXTURE_WRAP_R: number;
  67105. readonly HALF_FLOAT: number;
  67106. readonly RGB8: number;
  67107. readonly RED_INTEGER: number;
  67108. readonly RG_INTEGER: number;
  67109. readonly RGB_INTEGER: number;
  67110. readonly RGBA_INTEGER: number;
  67111. readonly R8_SNORM: number;
  67112. readonly RG8_SNORM: number;
  67113. readonly RGB8_SNORM: number;
  67114. readonly RGBA8_SNORM: number;
  67115. readonly R8I: number;
  67116. readonly RG8I: number;
  67117. readonly RGB8I: number;
  67118. readonly RGBA8I: number;
  67119. readonly R8UI: number;
  67120. readonly RG8UI: number;
  67121. readonly RGB8UI: number;
  67122. readonly RGBA8UI: number;
  67123. readonly R16I: number;
  67124. readonly RG16I: number;
  67125. readonly RGB16I: number;
  67126. readonly RGBA16I: number;
  67127. readonly R16UI: number;
  67128. readonly RG16UI: number;
  67129. readonly RGB16UI: number;
  67130. readonly RGBA16UI: number;
  67131. readonly R32I: number;
  67132. readonly RG32I: number;
  67133. readonly RGB32I: number;
  67134. readonly RGBA32I: number;
  67135. readonly R32UI: number;
  67136. readonly RG32UI: number;
  67137. readonly RGB32UI: number;
  67138. readonly RGBA32UI: number;
  67139. readonly RGB10_A2UI: number;
  67140. readonly R11F_G11F_B10F: number;
  67141. readonly RGB9_E5: number;
  67142. readonly RGB10_A2: number;
  67143. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67144. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67145. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67146. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67147. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67148. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67149. 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;
  67150. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67151. readonly TRANSFORM_FEEDBACK: number;
  67152. readonly INTERLEAVED_ATTRIBS: number;
  67153. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67154. createTransformFeedback(): WebGLTransformFeedback;
  67155. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67156. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67157. beginTransformFeedback(primitiveMode: number): void;
  67158. endTransformFeedback(): void;
  67159. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67160. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67161. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67162. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67163. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67164. }
  67165. interface ImageBitmap {
  67166. readonly width: number;
  67167. readonly height: number;
  67168. close(): void;
  67169. }
  67170. interface WebGLQuery extends WebGLObject {
  67171. }
  67172. declare var WebGLQuery: {
  67173. prototype: WebGLQuery;
  67174. new(): WebGLQuery;
  67175. };
  67176. interface WebGLSampler extends WebGLObject {
  67177. }
  67178. declare var WebGLSampler: {
  67179. prototype: WebGLSampler;
  67180. new(): WebGLSampler;
  67181. };
  67182. interface WebGLSync extends WebGLObject {
  67183. }
  67184. declare var WebGLSync: {
  67185. prototype: WebGLSync;
  67186. new(): WebGLSync;
  67187. };
  67188. interface WebGLTransformFeedback extends WebGLObject {
  67189. }
  67190. declare var WebGLTransformFeedback: {
  67191. prototype: WebGLTransformFeedback;
  67192. new(): WebGLTransformFeedback;
  67193. };
  67194. interface WebGLVertexArrayObject extends WebGLObject {
  67195. }
  67196. declare var WebGLVertexArrayObject: {
  67197. prototype: WebGLVertexArrayObject;
  67198. new(): WebGLVertexArrayObject;
  67199. };
  67200. // Type definitions for WebVR API
  67201. // Project: https://w3c.github.io/webvr/
  67202. // Definitions by: six a <https://github.com/lostfictions>
  67203. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67204. interface VRDisplay extends EventTarget {
  67205. /**
  67206. * Dictionary of capabilities describing the VRDisplay.
  67207. */
  67208. readonly capabilities: VRDisplayCapabilities;
  67209. /**
  67210. * z-depth defining the far plane of the eye view frustum
  67211. * enables mapping of values in the render target depth
  67212. * attachment to scene coordinates. Initially set to 10000.0.
  67213. */
  67214. depthFar: number;
  67215. /**
  67216. * z-depth defining the near plane of the eye view frustum
  67217. * enables mapping of values in the render target depth
  67218. * attachment to scene coordinates. Initially set to 0.01.
  67219. */
  67220. depthNear: number;
  67221. /**
  67222. * An identifier for this distinct VRDisplay. Used as an
  67223. * association point in the Gamepad API.
  67224. */
  67225. readonly displayId: number;
  67226. /**
  67227. * A display name, a user-readable name identifying it.
  67228. */
  67229. readonly displayName: string;
  67230. readonly isConnected: boolean;
  67231. readonly isPresenting: boolean;
  67232. /**
  67233. * If this VRDisplay supports room-scale experiences, the optional
  67234. * stage attribute contains details on the room-scale parameters.
  67235. */
  67236. readonly stageParameters: VRStageParameters | null;
  67237. /**
  67238. * Passing the value returned by `requestAnimationFrame` to
  67239. * `cancelAnimationFrame` will unregister the callback.
  67240. * @param handle Define the hanle of the request to cancel
  67241. */
  67242. cancelAnimationFrame(handle: number): void;
  67243. /**
  67244. * Stops presenting to the VRDisplay.
  67245. * @returns a promise to know when it stopped
  67246. */
  67247. exitPresent(): Promise<void>;
  67248. /**
  67249. * Return the current VREyeParameters for the given eye.
  67250. * @param whichEye Define the eye we want the parameter for
  67251. * @returns the eye parameters
  67252. */
  67253. getEyeParameters(whichEye: string): VREyeParameters;
  67254. /**
  67255. * Populates the passed VRFrameData with the information required to render
  67256. * the current frame.
  67257. * @param frameData Define the data structure to populate
  67258. * @returns true if ok otherwise false
  67259. */
  67260. getFrameData(frameData: VRFrameData): boolean;
  67261. /**
  67262. * Get the layers currently being presented.
  67263. * @returns the list of VR layers
  67264. */
  67265. getLayers(): VRLayer[];
  67266. /**
  67267. * Return a VRPose containing the future predicted pose of the VRDisplay
  67268. * when the current frame will be presented. The value returned will not
  67269. * change until JavaScript has returned control to the browser.
  67270. *
  67271. * The VRPose will contain the position, orientation, velocity,
  67272. * and acceleration of each of these properties.
  67273. * @returns the pose object
  67274. */
  67275. getPose(): VRPose;
  67276. /**
  67277. * Return the current instantaneous pose of the VRDisplay, with no
  67278. * prediction applied.
  67279. * @returns the current instantaneous pose
  67280. */
  67281. getImmediatePose(): VRPose;
  67282. /**
  67283. * The callback passed to `requestAnimationFrame` will be called
  67284. * any time a new frame should be rendered. When the VRDisplay is
  67285. * presenting the callback will be called at the native refresh
  67286. * rate of the HMD. When not presenting this function acts
  67287. * identically to how window.requestAnimationFrame acts. Content should
  67288. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67289. * asynchronously from other displays and at differing refresh rates.
  67290. * @param callback Define the eaction to run next frame
  67291. * @returns the request handle it
  67292. */
  67293. requestAnimationFrame(callback: FrameRequestCallback): number;
  67294. /**
  67295. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67296. * Repeat calls while already presenting will update the VRLayers being displayed.
  67297. * @param layers Define the list of layer to present
  67298. * @returns a promise to know when the request has been fulfilled
  67299. */
  67300. requestPresent(layers: VRLayer[]): Promise<void>;
  67301. /**
  67302. * Reset the pose for this display, treating its current position and
  67303. * orientation as the "origin/zero" values. VRPose.position,
  67304. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67305. * updated when calling resetPose(). This should be called in only
  67306. * sitting-space experiences.
  67307. */
  67308. resetPose(): void;
  67309. /**
  67310. * The VRLayer provided to the VRDisplay will be captured and presented
  67311. * in the HMD. Calling this function has the same effect on the source
  67312. * canvas as any other operation that uses its source image, and canvases
  67313. * created without preserveDrawingBuffer set to true will be cleared.
  67314. * @param pose Define the pose to submit
  67315. */
  67316. submitFrame(pose?: VRPose): void;
  67317. }
  67318. declare var VRDisplay: {
  67319. prototype: VRDisplay;
  67320. new(): VRDisplay;
  67321. };
  67322. interface VRLayer {
  67323. leftBounds?: number[] | Float32Array | null;
  67324. rightBounds?: number[] | Float32Array | null;
  67325. source?: HTMLCanvasElement | null;
  67326. }
  67327. interface VRDisplayCapabilities {
  67328. readonly canPresent: boolean;
  67329. readonly hasExternalDisplay: boolean;
  67330. readonly hasOrientation: boolean;
  67331. readonly hasPosition: boolean;
  67332. readonly maxLayers: number;
  67333. }
  67334. interface VREyeParameters {
  67335. /** @deprecated */
  67336. readonly fieldOfView: VRFieldOfView;
  67337. readonly offset: Float32Array;
  67338. readonly renderHeight: number;
  67339. readonly renderWidth: number;
  67340. }
  67341. interface VRFieldOfView {
  67342. readonly downDegrees: number;
  67343. readonly leftDegrees: number;
  67344. readonly rightDegrees: number;
  67345. readonly upDegrees: number;
  67346. }
  67347. interface VRFrameData {
  67348. readonly leftProjectionMatrix: Float32Array;
  67349. readonly leftViewMatrix: Float32Array;
  67350. readonly pose: VRPose;
  67351. readonly rightProjectionMatrix: Float32Array;
  67352. readonly rightViewMatrix: Float32Array;
  67353. readonly timestamp: number;
  67354. }
  67355. interface VRPose {
  67356. readonly angularAcceleration: Float32Array | null;
  67357. readonly angularVelocity: Float32Array | null;
  67358. readonly linearAcceleration: Float32Array | null;
  67359. readonly linearVelocity: Float32Array | null;
  67360. readonly orientation: Float32Array | null;
  67361. readonly position: Float32Array | null;
  67362. readonly timestamp: number;
  67363. }
  67364. interface VRStageParameters {
  67365. sittingToStandingTransform?: Float32Array;
  67366. sizeX?: number;
  67367. sizeY?: number;
  67368. }
  67369. interface Navigator {
  67370. getVRDisplays(): Promise<VRDisplay[]>;
  67371. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67372. }
  67373. interface Window {
  67374. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67375. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67376. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67377. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67378. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67379. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67380. }
  67381. interface Gamepad {
  67382. readonly displayId: number;
  67383. }
  67384. type XRSessionMode =
  67385. | "inline"
  67386. | "immersive-vr"
  67387. | "immersive-ar";
  67388. type XRReferenceSpaceType =
  67389. | "viewer"
  67390. | "local"
  67391. | "local-floor"
  67392. | "bounded-floor"
  67393. | "unbounded";
  67394. type XREnvironmentBlendMode =
  67395. | "opaque"
  67396. | "additive"
  67397. | "alpha-blend";
  67398. type XRVisibilityState =
  67399. | "visible"
  67400. | "visible-blurred"
  67401. | "hidden";
  67402. type XRHandedness =
  67403. | "none"
  67404. | "left"
  67405. | "right";
  67406. type XRTargetRayMode =
  67407. | "gaze"
  67408. | "tracked-pointer"
  67409. | "screen";
  67410. type XREye =
  67411. | "none"
  67412. | "left"
  67413. | "right";
  67414. interface XRSpace extends EventTarget {
  67415. }
  67416. interface XRRenderState {
  67417. depthNear?: number;
  67418. depthFar?: number;
  67419. inlineVerticalFieldOfView?: number;
  67420. baseLayer?: XRWebGLLayer;
  67421. }
  67422. interface XRInputSource {
  67423. handedness: XRHandedness;
  67424. targetRayMode: XRTargetRayMode;
  67425. targetRaySpace: XRSpace;
  67426. gripSpace: XRSpace | undefined;
  67427. gamepad: Gamepad | undefined;
  67428. profiles: Array<string>;
  67429. }
  67430. interface XRSession extends XRAnchorCreator {
  67431. addEventListener: Function;
  67432. removeEventListener: Function;
  67433. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67434. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67435. requestAnimationFrame: Function;
  67436. end(): Promise<void>;
  67437. renderState: XRRenderState;
  67438. inputSources: Array<XRInputSource>;
  67439. // AR hit test
  67440. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67441. updateWorldTrackingState(options: {
  67442. planeDetectionState?: { enabled: boolean; }
  67443. }): void;
  67444. }
  67445. interface XRReferenceSpace extends XRSpace {
  67446. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67447. onreset: any;
  67448. }
  67449. type XRPlaneSet = Set<XRPlane>;
  67450. type XRAnchorSet = Set<XRAnchor>;
  67451. interface XRFrame {
  67452. session: XRSession;
  67453. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67454. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67455. // Anchors
  67456. trackedAnchors?: XRAnchorSet;
  67457. // Planes
  67458. worldInformation: {
  67459. detectedPlanes?: XRPlaneSet;
  67460. };
  67461. }
  67462. interface XRViewerPose extends XRPose {
  67463. views: Array<XRView>;
  67464. }
  67465. interface XRPose {
  67466. transform: XRRigidTransform;
  67467. emulatedPosition: boolean;
  67468. }
  67469. interface XRWebGLLayerOptions {
  67470. antialias?: boolean;
  67471. depth?: boolean;
  67472. stencil?: boolean;
  67473. alpha?: boolean;
  67474. multiview?: boolean;
  67475. framebufferScaleFactor?: number;
  67476. }
  67477. declare var XRWebGLLayer: {
  67478. prototype: XRWebGLLayer;
  67479. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67480. };
  67481. interface XRWebGLLayer {
  67482. framebuffer: WebGLFramebuffer;
  67483. framebufferWidth: number;
  67484. framebufferHeight: number;
  67485. getViewport: Function;
  67486. }
  67487. declare class XRRigidTransform {
  67488. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  67489. position: DOMPointReadOnly;
  67490. orientation: DOMPointReadOnly;
  67491. matrix: Float32Array;
  67492. inverse: XRRigidTransform;
  67493. }
  67494. interface XRView {
  67495. eye: XREye;
  67496. projectionMatrix: Float32Array;
  67497. transform: XRRigidTransform;
  67498. }
  67499. interface XRInputSourceChangeEvent {
  67500. session: XRSession;
  67501. removed: Array<XRInputSource>;
  67502. added: Array<XRInputSource>;
  67503. }
  67504. interface XRInputSourceEvent extends Event {
  67505. readonly frame: XRFrame;
  67506. readonly inputSource: XRInputSource;
  67507. }
  67508. // Experimental(er) features
  67509. declare class XRRay {
  67510. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  67511. origin: DOMPointReadOnly;
  67512. direction: DOMPointReadOnly;
  67513. matrix: Float32Array;
  67514. }
  67515. interface XRHitResult {
  67516. hitMatrix: Float32Array;
  67517. }
  67518. interface XRAnchor {
  67519. // remove?
  67520. id?: string;
  67521. anchorSpace: XRSpace;
  67522. lastChangedTime: number;
  67523. detach(): void;
  67524. }
  67525. interface XRPlane extends XRAnchorCreator {
  67526. orientation: "Horizontal" | "Vertical";
  67527. planeSpace: XRSpace;
  67528. polygon: Array<DOMPointReadOnly>;
  67529. lastChangedTime: number;
  67530. }
  67531. interface XRAnchorCreator {
  67532. // AR Anchors
  67533. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67534. }
  67535. /**
  67536. * @ignore
  67537. */
  67538. declare module BABYLON.GLTF2.Exporter {
  67539. }
  67540. /**
  67541. * @ignore
  67542. */
  67543. declare module BABYLON.GLTF1 {
  67544. }
  67545. declare module BABYLON.GUI {
  67546. /**
  67547. * Class used to specific a value and its associated unit
  67548. */
  67549. export class ValueAndUnit {
  67550. /** defines the unit to store */
  67551. unit: number;
  67552. /** defines a boolean indicating if the value can be negative */
  67553. negativeValueAllowed: boolean;
  67554. private _value;
  67555. private _originalUnit;
  67556. /**
  67557. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  67558. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67559. */
  67560. ignoreAdaptiveScaling: boolean;
  67561. /**
  67562. * Creates a new ValueAndUnit
  67563. * @param value defines the value to store
  67564. * @param unit defines the unit to store
  67565. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  67566. */
  67567. constructor(value: number,
  67568. /** defines the unit to store */
  67569. unit?: number,
  67570. /** defines a boolean indicating if the value can be negative */
  67571. negativeValueAllowed?: boolean);
  67572. /** Gets a boolean indicating if the value is a percentage */
  67573. get isPercentage(): boolean;
  67574. /** Gets a boolean indicating if the value is store as pixel */
  67575. get isPixel(): boolean;
  67576. /** Gets direct internal value */
  67577. get internalValue(): number;
  67578. /**
  67579. * Gets value as pixel
  67580. * @param host defines the root host
  67581. * @param refValue defines the reference value for percentages
  67582. * @returns the value as pixel
  67583. */
  67584. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  67585. /**
  67586. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  67587. * @param value defines the value to store
  67588. * @param unit defines the unit to store
  67589. * @returns the current ValueAndUnit
  67590. */
  67591. updateInPlace(value: number, unit?: number): ValueAndUnit;
  67592. /**
  67593. * Gets the value accordingly to its unit
  67594. * @param host defines the root host
  67595. * @returns the value
  67596. */
  67597. getValue(host: AdvancedDynamicTexture): number;
  67598. /**
  67599. * Gets a string representation of the value
  67600. * @param host defines the root host
  67601. * @param decimals defines an optional number of decimals to display
  67602. * @returns a string
  67603. */
  67604. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  67605. /**
  67606. * Store a value parsed from a string
  67607. * @param source defines the source string
  67608. * @returns true if the value was successfully parsed
  67609. */
  67610. fromString(source: string | number): boolean;
  67611. private static _Regex;
  67612. private static _UNITMODE_PERCENTAGE;
  67613. private static _UNITMODE_PIXEL;
  67614. /** UNITMODE_PERCENTAGE */
  67615. static get UNITMODE_PERCENTAGE(): number;
  67616. /** UNITMODE_PIXEL */
  67617. static get UNITMODE_PIXEL(): number;
  67618. }
  67619. }
  67620. declare module BABYLON.GUI {
  67621. /**
  67622. * Define a style used by control to automatically setup properties based on a template.
  67623. * Only support font related properties so far
  67624. */
  67625. export class Style implements BABYLON.IDisposable {
  67626. private _fontFamily;
  67627. private _fontStyle;
  67628. private _fontWeight;
  67629. /** @hidden */
  67630. _host: AdvancedDynamicTexture;
  67631. /** @hidden */
  67632. _fontSize: ValueAndUnit;
  67633. /**
  67634. * BABYLON.Observable raised when the style values are changed
  67635. */
  67636. onChangedObservable: BABYLON.Observable<Style>;
  67637. /**
  67638. * Creates a new style object
  67639. * @param host defines the AdvancedDynamicTexture which hosts this style
  67640. */
  67641. constructor(host: AdvancedDynamicTexture);
  67642. /**
  67643. * Gets or sets the font size
  67644. */
  67645. get fontSize(): string | number;
  67646. set fontSize(value: string | number);
  67647. /**
  67648. * Gets or sets the font family
  67649. */
  67650. get fontFamily(): string;
  67651. set fontFamily(value: string);
  67652. /**
  67653. * Gets or sets the font style
  67654. */
  67655. get fontStyle(): string;
  67656. set fontStyle(value: string);
  67657. /** Gets or sets font weight */
  67658. get fontWeight(): string;
  67659. set fontWeight(value: string);
  67660. /** Dispose all associated resources */
  67661. dispose(): void;
  67662. }
  67663. }
  67664. declare module BABYLON.GUI {
  67665. /**
  67666. * Class used to transport BABYLON.Vector2 information for pointer events
  67667. */
  67668. export class Vector2WithInfo extends BABYLON.Vector2 {
  67669. /** defines the current mouse button index */
  67670. buttonIndex: number;
  67671. /**
  67672. * Creates a new Vector2WithInfo
  67673. * @param source defines the vector2 data to transport
  67674. * @param buttonIndex defines the current mouse button index
  67675. */
  67676. constructor(source: BABYLON.Vector2,
  67677. /** defines the current mouse button index */
  67678. buttonIndex?: number);
  67679. }
  67680. /** Class used to provide 2D matrix features */
  67681. export class Matrix2D {
  67682. /** Gets the internal array of 6 floats used to store matrix data */
  67683. m: Float32Array;
  67684. /**
  67685. * Creates a new matrix
  67686. * @param m00 defines value for (0, 0)
  67687. * @param m01 defines value for (0, 1)
  67688. * @param m10 defines value for (1, 0)
  67689. * @param m11 defines value for (1, 1)
  67690. * @param m20 defines value for (2, 0)
  67691. * @param m21 defines value for (2, 1)
  67692. */
  67693. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  67694. /**
  67695. * Fills the matrix from direct values
  67696. * @param m00 defines value for (0, 0)
  67697. * @param m01 defines value for (0, 1)
  67698. * @param m10 defines value for (1, 0)
  67699. * @param m11 defines value for (1, 1)
  67700. * @param m20 defines value for (2, 0)
  67701. * @param m21 defines value for (2, 1)
  67702. * @returns the current modified matrix
  67703. */
  67704. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  67705. /**
  67706. * Gets matrix determinant
  67707. * @returns the determinant
  67708. */
  67709. determinant(): number;
  67710. /**
  67711. * Inverses the matrix and stores it in a target matrix
  67712. * @param result defines the target matrix
  67713. * @returns the current matrix
  67714. */
  67715. invertToRef(result: Matrix2D): Matrix2D;
  67716. /**
  67717. * Multiplies the current matrix with another one
  67718. * @param other defines the second operand
  67719. * @param result defines the target matrix
  67720. * @returns the current matrix
  67721. */
  67722. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67723. /**
  67724. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67725. * @param x defines the x coordinate to transform
  67726. * @param y defines the x coordinate to transform
  67727. * @param result defines the target vector2
  67728. * @returns the current matrix
  67729. */
  67730. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67731. /**
  67732. * Creates an identity matrix
  67733. * @returns a new matrix
  67734. */
  67735. static Identity(): Matrix2D;
  67736. /**
  67737. * Creates a translation matrix and stores it in a target matrix
  67738. * @param x defines the x coordinate of the translation
  67739. * @param y defines the y coordinate of the translation
  67740. * @param result defines the target matrix
  67741. */
  67742. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67743. /**
  67744. * Creates a scaling matrix and stores it in a target matrix
  67745. * @param x defines the x coordinate of the scaling
  67746. * @param y defines the y coordinate of the scaling
  67747. * @param result defines the target matrix
  67748. */
  67749. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67750. /**
  67751. * Creates a rotation matrix and stores it in a target matrix
  67752. * @param angle defines the rotation angle
  67753. * @param result defines the target matrix
  67754. */
  67755. static RotationToRef(angle: number, result: Matrix2D): void;
  67756. private static _TempPreTranslationMatrix;
  67757. private static _TempPostTranslationMatrix;
  67758. private static _TempRotationMatrix;
  67759. private static _TempScalingMatrix;
  67760. private static _TempCompose0;
  67761. private static _TempCompose1;
  67762. private static _TempCompose2;
  67763. /**
  67764. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67765. * @param tx defines the x coordinate of the translation
  67766. * @param ty defines the y coordinate of the translation
  67767. * @param angle defines the rotation angle
  67768. * @param scaleX defines the x coordinate of the scaling
  67769. * @param scaleY defines the y coordinate of the scaling
  67770. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67771. * @param result defines the target matrix
  67772. */
  67773. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67774. }
  67775. }
  67776. declare module BABYLON.GUI {
  67777. /**
  67778. * Class used to store 2D control sizes
  67779. */
  67780. export class Measure {
  67781. /** defines left coordinate */
  67782. left: number;
  67783. /** defines top coordinate */
  67784. top: number;
  67785. /** defines width dimension */
  67786. width: number;
  67787. /** defines height dimension */
  67788. height: number;
  67789. /**
  67790. * Creates a new measure
  67791. * @param left defines left coordinate
  67792. * @param top defines top coordinate
  67793. * @param width defines width dimension
  67794. * @param height defines height dimension
  67795. */
  67796. constructor(
  67797. /** defines left coordinate */
  67798. left: number,
  67799. /** defines top coordinate */
  67800. top: number,
  67801. /** defines width dimension */
  67802. width: number,
  67803. /** defines height dimension */
  67804. height: number);
  67805. /**
  67806. * Copy from another measure
  67807. * @param other defines the other measure to copy from
  67808. */
  67809. copyFrom(other: Measure): void;
  67810. /**
  67811. * Copy from a group of 4 floats
  67812. * @param left defines left coordinate
  67813. * @param top defines top coordinate
  67814. * @param width defines width dimension
  67815. * @param height defines height dimension
  67816. */
  67817. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67818. /**
  67819. * Computes the axis aligned bounding box measure for two given measures
  67820. * @param a Input measure
  67821. * @param b Input measure
  67822. * @param result the resulting bounding measure
  67823. */
  67824. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67825. /**
  67826. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67827. * @param transform the matrix to transform the measure before computing the AABB
  67828. * @param result the resulting AABB
  67829. */
  67830. transformToRef(transform: Matrix2D, result: Measure): void;
  67831. /**
  67832. * Check equality between this measure and another one
  67833. * @param other defines the other measures
  67834. * @returns true if both measures are equals
  67835. */
  67836. isEqualsTo(other: Measure): boolean;
  67837. /**
  67838. * Creates an empty measure
  67839. * @returns a new measure
  67840. */
  67841. static Empty(): Measure;
  67842. }
  67843. }
  67844. declare module BABYLON.GUI {
  67845. /**
  67846. * Interface used to define a control that can receive focus
  67847. */
  67848. export interface IFocusableControl {
  67849. /**
  67850. * Function called when the control receives the focus
  67851. */
  67852. onFocus(): void;
  67853. /**
  67854. * Function called when the control loses the focus
  67855. */
  67856. onBlur(): void;
  67857. /**
  67858. * Function called to let the control handle keyboard events
  67859. * @param evt defines the current keyboard event
  67860. */
  67861. processKeyboard(evt: KeyboardEvent): void;
  67862. /**
  67863. * Function called to get the list of controls that should not steal the focus from this control
  67864. * @returns an array of controls
  67865. */
  67866. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67867. }
  67868. /**
  67869. * Class used to create texture to support 2D GUI elements
  67870. * @see http://doc.babylonjs.com/how_to/gui
  67871. */
  67872. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67873. private _isDirty;
  67874. private _renderObserver;
  67875. private _resizeObserver;
  67876. private _preKeyboardObserver;
  67877. private _pointerMoveObserver;
  67878. private _pointerObserver;
  67879. private _canvasPointerOutObserver;
  67880. private _background;
  67881. /** @hidden */
  67882. _rootContainer: Container;
  67883. /** @hidden */
  67884. _lastPickedControl: Control;
  67885. /** @hidden */
  67886. _lastControlOver: {
  67887. [pointerId: number]: Control;
  67888. };
  67889. /** @hidden */
  67890. _lastControlDown: {
  67891. [pointerId: number]: Control;
  67892. };
  67893. /** @hidden */
  67894. _capturingControl: {
  67895. [pointerId: number]: Control;
  67896. };
  67897. /** @hidden */
  67898. _shouldBlockPointer: boolean;
  67899. /** @hidden */
  67900. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67901. /** @hidden */
  67902. _linkedControls: Control[];
  67903. private _isFullscreen;
  67904. private _fullscreenViewport;
  67905. private _idealWidth;
  67906. private _idealHeight;
  67907. private _useSmallestIdeal;
  67908. private _renderAtIdealSize;
  67909. private _focusedControl;
  67910. private _blockNextFocusCheck;
  67911. private _renderScale;
  67912. private _rootElement;
  67913. private _cursorChanged;
  67914. /**
  67915. * Define type to string to ensure compatibility across browsers
  67916. * Safari doesn't support DataTransfer constructor
  67917. */
  67918. private _clipboardData;
  67919. /**
  67920. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67921. */
  67922. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67923. /**
  67924. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67925. */
  67926. onControlPickedObservable: BABYLON.Observable<Control>;
  67927. /**
  67928. * BABYLON.Observable event triggered before layout is evaluated
  67929. */
  67930. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67931. /**
  67932. * BABYLON.Observable event triggered after the layout was evaluated
  67933. */
  67934. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67935. /**
  67936. * BABYLON.Observable event triggered before the texture is rendered
  67937. */
  67938. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67939. /**
  67940. * BABYLON.Observable event triggered after the texture was rendered
  67941. */
  67942. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67943. /**
  67944. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67945. */
  67946. premulAlpha: boolean;
  67947. /**
  67948. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67949. * Useful when you want more antialiasing
  67950. */
  67951. get renderScale(): number;
  67952. set renderScale(value: number);
  67953. /** Gets or sets the background color */
  67954. get background(): string;
  67955. set background(value: string);
  67956. /**
  67957. * Gets or sets the ideal width used to design controls.
  67958. * The GUI will then rescale everything accordingly
  67959. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67960. */
  67961. get idealWidth(): number;
  67962. set idealWidth(value: number);
  67963. /**
  67964. * Gets or sets the ideal height used to design controls.
  67965. * The GUI will then rescale everything accordingly
  67966. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67967. */
  67968. get idealHeight(): number;
  67969. set idealHeight(value: number);
  67970. /**
  67971. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67972. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67973. */
  67974. get useSmallestIdeal(): boolean;
  67975. set useSmallestIdeal(value: boolean);
  67976. /**
  67977. * Gets or sets a boolean indicating if adaptive scaling must be used
  67978. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67979. */
  67980. get renderAtIdealSize(): boolean;
  67981. set renderAtIdealSize(value: boolean);
  67982. /**
  67983. * Gets the underlying layer used to render the texture when in fullscreen mode
  67984. */
  67985. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  67986. /**
  67987. * Gets the root container control
  67988. */
  67989. get rootContainer(): Container;
  67990. /**
  67991. * Returns an array containing the root container.
  67992. * This is mostly used to let the Inspector introspects the ADT
  67993. * @returns an array containing the rootContainer
  67994. */
  67995. getChildren(): Array<Container>;
  67996. /**
  67997. * Will return all controls that are inside this texture
  67998. * @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
  67999. * @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
  68000. * @return all child controls
  68001. */
  68002. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68003. /**
  68004. * Gets or sets the current focused control
  68005. */
  68006. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  68007. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  68008. /**
  68009. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  68010. */
  68011. get isForeground(): boolean;
  68012. set isForeground(value: boolean);
  68013. /**
  68014. * Gets or set information about clipboardData
  68015. */
  68016. get clipboardData(): string;
  68017. set clipboardData(value: string);
  68018. /**
  68019. * Creates a new AdvancedDynamicTexture
  68020. * @param name defines the name of the texture
  68021. * @param width defines the width of the texture
  68022. * @param height defines the height of the texture
  68023. * @param scene defines the hosting scene
  68024. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  68025. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  68026. */
  68027. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  68028. /**
  68029. * Get the current class name of the texture useful for serialization or dynamic coding.
  68030. * @returns "AdvancedDynamicTexture"
  68031. */
  68032. getClassName(): string;
  68033. /**
  68034. * Function used to execute a function on all controls
  68035. * @param func defines the function to execute
  68036. * @param container defines the container where controls belong. If null the root container will be used
  68037. */
  68038. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  68039. private _useInvalidateRectOptimization;
  68040. /**
  68041. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  68042. */
  68043. get useInvalidateRectOptimization(): boolean;
  68044. set useInvalidateRectOptimization(value: boolean);
  68045. private _invalidatedRectangle;
  68046. /**
  68047. * Invalidates a rectangle area on the gui texture
  68048. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  68049. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  68050. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  68051. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  68052. */
  68053. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  68054. /**
  68055. * Marks the texture as dirty forcing a complete update
  68056. */
  68057. markAsDirty(): void;
  68058. /**
  68059. * Helper function used to create a new style
  68060. * @returns a new style
  68061. * @see http://doc.babylonjs.com/how_to/gui#styles
  68062. */
  68063. createStyle(): Style;
  68064. /**
  68065. * Adds a new control to the root container
  68066. * @param control defines the control to add
  68067. * @returns the current texture
  68068. */
  68069. addControl(control: Control): AdvancedDynamicTexture;
  68070. /**
  68071. * Removes a control from the root container
  68072. * @param control defines the control to remove
  68073. * @returns the current texture
  68074. */
  68075. removeControl(control: Control): AdvancedDynamicTexture;
  68076. /**
  68077. * Release all resources
  68078. */
  68079. dispose(): void;
  68080. private _onResize;
  68081. /** @hidden */
  68082. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  68083. /**
  68084. * Get screen coordinates for a vector3
  68085. * @param position defines the position to project
  68086. * @param worldMatrix defines the world matrix to use
  68087. * @returns the projected position
  68088. */
  68089. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  68090. private _checkUpdate;
  68091. private _clearMeasure;
  68092. private _render;
  68093. /** @hidden */
  68094. _changeCursor(cursor: string): void;
  68095. /** @hidden */
  68096. _registerLastControlDown(control: Control, pointerId: number): void;
  68097. private _doPicking;
  68098. /** @hidden */
  68099. _cleanControlAfterRemovalFromList(list: {
  68100. [pointerId: number]: Control;
  68101. }, control: Control): void;
  68102. /** @hidden */
  68103. _cleanControlAfterRemoval(control: Control): void;
  68104. /** Attach to all scene events required to support pointer events */
  68105. attach(): void;
  68106. /** @hidden */
  68107. private onClipboardCopy;
  68108. /** @hidden */
  68109. private onClipboardCut;
  68110. /** @hidden */
  68111. private onClipboardPaste;
  68112. /**
  68113. * Register the clipboard Events onto the canvas
  68114. */
  68115. registerClipboardEvents(): void;
  68116. /**
  68117. * Unregister the clipboard Events from the canvas
  68118. */
  68119. unRegisterClipboardEvents(): void;
  68120. /**
  68121. * Connect the texture to a hosting mesh to enable interactions
  68122. * @param mesh defines the mesh to attach to
  68123. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68124. */
  68125. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68126. /**
  68127. * Move the focus to a specific control
  68128. * @param control defines the control which will receive the focus
  68129. */
  68130. moveFocusToControl(control: IFocusableControl): void;
  68131. private _manageFocus;
  68132. private _attachToOnPointerOut;
  68133. /**
  68134. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68135. * @param mesh defines the mesh which will receive the texture
  68136. * @param width defines the texture width (1024 by default)
  68137. * @param height defines the texture height (1024 by default)
  68138. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68139. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68140. * @returns a new AdvancedDynamicTexture
  68141. */
  68142. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68143. /**
  68144. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68145. * In this mode the texture will rely on a layer for its rendering.
  68146. * This allows it to be treated like any other layer.
  68147. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68148. * LayerMask is set through advancedTexture.layer.layerMask
  68149. * @param name defines name for the texture
  68150. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68151. * @param scene defines the hsoting scene
  68152. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68153. * @returns a new AdvancedDynamicTexture
  68154. */
  68155. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68156. }
  68157. }
  68158. declare module BABYLON.GUI {
  68159. /**
  68160. * Root class used for all 2D controls
  68161. * @see http://doc.babylonjs.com/how_to/gui#controls
  68162. */
  68163. export class Control {
  68164. /** defines the name of the control */
  68165. name?: string | undefined;
  68166. /**
  68167. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68168. */
  68169. static AllowAlphaInheritance: boolean;
  68170. private _alpha;
  68171. private _alphaSet;
  68172. private _zIndex;
  68173. /** @hidden */
  68174. _host: AdvancedDynamicTexture;
  68175. /** Gets or sets the control parent */
  68176. parent: BABYLON.Nullable<Container>;
  68177. /** @hidden */
  68178. _currentMeasure: Measure;
  68179. private _fontFamily;
  68180. private _fontStyle;
  68181. private _fontWeight;
  68182. private _fontSize;
  68183. private _font;
  68184. /** @hidden */
  68185. _width: ValueAndUnit;
  68186. /** @hidden */
  68187. _height: ValueAndUnit;
  68188. /** @hidden */
  68189. protected _fontOffset: {
  68190. ascent: number;
  68191. height: number;
  68192. descent: number;
  68193. };
  68194. private _color;
  68195. private _style;
  68196. private _styleObserver;
  68197. /** @hidden */
  68198. protected _horizontalAlignment: number;
  68199. /** @hidden */
  68200. protected _verticalAlignment: number;
  68201. /** @hidden */
  68202. protected _isDirty: boolean;
  68203. /** @hidden */
  68204. protected _wasDirty: boolean;
  68205. /** @hidden */
  68206. _tempParentMeasure: Measure;
  68207. /** @hidden */
  68208. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68209. /** @hidden */
  68210. protected _cachedParentMeasure: Measure;
  68211. private _paddingLeft;
  68212. private _paddingRight;
  68213. private _paddingTop;
  68214. private _paddingBottom;
  68215. /** @hidden */
  68216. _left: ValueAndUnit;
  68217. /** @hidden */
  68218. _top: ValueAndUnit;
  68219. private _scaleX;
  68220. private _scaleY;
  68221. private _rotation;
  68222. private _transformCenterX;
  68223. private _transformCenterY;
  68224. /** @hidden */
  68225. _transformMatrix: Matrix2D;
  68226. /** @hidden */
  68227. protected _invertTransformMatrix: Matrix2D;
  68228. /** @hidden */
  68229. protected _transformedPosition: BABYLON.Vector2;
  68230. private _isMatrixDirty;
  68231. private _cachedOffsetX;
  68232. private _cachedOffsetY;
  68233. private _isVisible;
  68234. private _isHighlighted;
  68235. /** @hidden */
  68236. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68237. private _fontSet;
  68238. private _dummyVector2;
  68239. private _downCount;
  68240. private _enterCount;
  68241. private _doNotRender;
  68242. private _downPointerIds;
  68243. protected _isEnabled: boolean;
  68244. protected _disabledColor: string;
  68245. /** @hidden */
  68246. protected _rebuildLayout: boolean;
  68247. /** @hidden */
  68248. _isClipped: boolean;
  68249. /** @hidden */
  68250. _automaticSize: boolean;
  68251. /** @hidden */
  68252. _tag: any;
  68253. /**
  68254. * 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
  68255. */
  68256. uniqueId: number;
  68257. /**
  68258. * Gets or sets an object used to store user defined information for the node
  68259. */
  68260. metadata: any;
  68261. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68262. isHitTestVisible: boolean;
  68263. /** Gets or sets a boolean indicating if the control can block pointer events */
  68264. isPointerBlocker: boolean;
  68265. /** Gets or sets a boolean indicating if the control can be focusable */
  68266. isFocusInvisible: boolean;
  68267. /**
  68268. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  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. clipChildren: boolean;
  68272. /**
  68273. * Gets or sets a boolean indicating that control content must be clipped
  68274. * 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
  68275. */
  68276. clipContent: boolean;
  68277. /**
  68278. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68279. */
  68280. useBitmapCache: boolean;
  68281. private _cacheData;
  68282. private _shadowOffsetX;
  68283. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68284. get shadowOffsetX(): number;
  68285. set shadowOffsetX(value: number);
  68286. private _shadowOffsetY;
  68287. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68288. get shadowOffsetY(): number;
  68289. set shadowOffsetY(value: number);
  68290. private _shadowBlur;
  68291. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68292. get shadowBlur(): number;
  68293. set shadowBlur(value: number);
  68294. private _shadowColor;
  68295. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68296. get shadowColor(): string;
  68297. set shadowColor(value: string);
  68298. /** Gets or sets the cursor to use when the control is hovered */
  68299. hoverCursor: string;
  68300. /** @hidden */
  68301. protected _linkOffsetX: ValueAndUnit;
  68302. /** @hidden */
  68303. protected _linkOffsetY: ValueAndUnit;
  68304. /** Gets the control type name */
  68305. get typeName(): string;
  68306. /**
  68307. * Get the current class name of the control.
  68308. * @returns current class name
  68309. */
  68310. getClassName(): string;
  68311. /**
  68312. * An event triggered when the pointer move over the control.
  68313. */
  68314. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68315. /**
  68316. * An event triggered when the pointer move out of the control.
  68317. */
  68318. onPointerOutObservable: BABYLON.Observable<Control>;
  68319. /**
  68320. * An event triggered when the pointer taps the control
  68321. */
  68322. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68323. /**
  68324. * An event triggered when pointer up
  68325. */
  68326. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  68327. /**
  68328. * An event triggered when a control is clicked on
  68329. */
  68330. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  68331. /**
  68332. * An event triggered when pointer enters the control
  68333. */
  68334. onPointerEnterObservable: BABYLON.Observable<Control>;
  68335. /**
  68336. * An event triggered when the control is marked as dirty
  68337. */
  68338. onDirtyObservable: BABYLON.Observable<Control>;
  68339. /**
  68340. * An event triggered before drawing the control
  68341. */
  68342. onBeforeDrawObservable: BABYLON.Observable<Control>;
  68343. /**
  68344. * An event triggered after the control was drawn
  68345. */
  68346. onAfterDrawObservable: BABYLON.Observable<Control>;
  68347. /**
  68348. * Get the hosting AdvancedDynamicTexture
  68349. */
  68350. get host(): AdvancedDynamicTexture;
  68351. /** Gets or set information about font offsets (used to render and align text) */
  68352. get fontOffset(): {
  68353. ascent: number;
  68354. height: number;
  68355. descent: number;
  68356. };
  68357. set fontOffset(offset: {
  68358. ascent: number;
  68359. height: number;
  68360. descent: number;
  68361. });
  68362. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  68363. get alpha(): number;
  68364. set alpha(value: number);
  68365. /**
  68366. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  68367. */
  68368. get isHighlighted(): boolean;
  68369. set isHighlighted(value: boolean);
  68370. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  68371. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68372. */
  68373. get scaleX(): number;
  68374. set scaleX(value: number);
  68375. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  68376. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68377. */
  68378. get scaleY(): number;
  68379. set scaleY(value: number);
  68380. /** Gets or sets the rotation angle (0 by default)
  68381. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68382. */
  68383. get rotation(): number;
  68384. set rotation(value: number);
  68385. /** Gets or sets the transformation center on Y axis (0 by default)
  68386. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68387. */
  68388. get transformCenterY(): number;
  68389. set transformCenterY(value: number);
  68390. /** Gets or sets the transformation center on X axis (0 by default)
  68391. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68392. */
  68393. get transformCenterX(): number;
  68394. set transformCenterX(value: number);
  68395. /**
  68396. * Gets or sets the horizontal alignment
  68397. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68398. */
  68399. get horizontalAlignment(): number;
  68400. set horizontalAlignment(value: number);
  68401. /**
  68402. * Gets or sets the vertical alignment
  68403. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68404. */
  68405. get verticalAlignment(): number;
  68406. set verticalAlignment(value: number);
  68407. /**
  68408. * Gets or sets control width
  68409. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68410. */
  68411. get width(): string | number;
  68412. set width(value: string | number);
  68413. /**
  68414. * Gets or sets the control width in pixel
  68415. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68416. */
  68417. get widthInPixels(): number;
  68418. set widthInPixels(value: number);
  68419. /**
  68420. * Gets or sets control height
  68421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68422. */
  68423. get height(): string | number;
  68424. set height(value: string | number);
  68425. /**
  68426. * Gets or sets control height in pixel
  68427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68428. */
  68429. get heightInPixels(): number;
  68430. set heightInPixels(value: number);
  68431. /** Gets or set font family */
  68432. get fontFamily(): string;
  68433. set fontFamily(value: string);
  68434. /** Gets or sets font style */
  68435. get fontStyle(): string;
  68436. set fontStyle(value: string);
  68437. /** Gets or sets font weight */
  68438. get fontWeight(): string;
  68439. set fontWeight(value: string);
  68440. /**
  68441. * Gets or sets style
  68442. * @see http://doc.babylonjs.com/how_to/gui#styles
  68443. */
  68444. get style(): BABYLON.Nullable<Style>;
  68445. set style(value: BABYLON.Nullable<Style>);
  68446. /** @hidden */
  68447. get _isFontSizeInPercentage(): boolean;
  68448. /** Gets or sets font size in pixels */
  68449. get fontSizeInPixels(): number;
  68450. set fontSizeInPixels(value: number);
  68451. /** Gets or sets font size */
  68452. get fontSize(): string | number;
  68453. set fontSize(value: string | number);
  68454. /** Gets or sets foreground color */
  68455. get color(): string;
  68456. set color(value: string);
  68457. /** Gets or sets z index which is used to reorder controls on the z axis */
  68458. get zIndex(): number;
  68459. set zIndex(value: number);
  68460. /** Gets or sets a boolean indicating if the control can be rendered */
  68461. get notRenderable(): boolean;
  68462. set notRenderable(value: boolean);
  68463. /** Gets or sets a boolean indicating if the control is visible */
  68464. get isVisible(): boolean;
  68465. set isVisible(value: boolean);
  68466. /** Gets a boolean indicating that the control needs to update its rendering */
  68467. get isDirty(): boolean;
  68468. /**
  68469. * Gets the current linked mesh (or null if none)
  68470. */
  68471. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  68472. /**
  68473. * Gets or sets a value indicating the padding to use on the left of the control
  68474. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68475. */
  68476. get paddingLeft(): string | number;
  68477. set paddingLeft(value: string | number);
  68478. /**
  68479. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  68480. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68481. */
  68482. get paddingLeftInPixels(): number;
  68483. set paddingLeftInPixels(value: number);
  68484. /**
  68485. * Gets or sets a value indicating the padding to use on the right of the control
  68486. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68487. */
  68488. get paddingRight(): string | number;
  68489. set paddingRight(value: string | number);
  68490. /**
  68491. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  68492. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68493. */
  68494. get paddingRightInPixels(): number;
  68495. set paddingRightInPixels(value: number);
  68496. /**
  68497. * Gets or sets a value indicating the padding to use on the top of the control
  68498. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68499. */
  68500. get paddingTop(): string | number;
  68501. set paddingTop(value: string | number);
  68502. /**
  68503. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  68504. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68505. */
  68506. get paddingTopInPixels(): number;
  68507. set paddingTopInPixels(value: number);
  68508. /**
  68509. * Gets or sets a value indicating the padding to use on the bottom of the control
  68510. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68511. */
  68512. get paddingBottom(): string | number;
  68513. set paddingBottom(value: string | number);
  68514. /**
  68515. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  68516. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68517. */
  68518. get paddingBottomInPixels(): number;
  68519. set paddingBottomInPixels(value: number);
  68520. /**
  68521. * Gets or sets a value indicating the left coordinate of the control
  68522. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68523. */
  68524. get left(): string | number;
  68525. set left(value: string | number);
  68526. /**
  68527. * Gets or sets a value indicating the left coordinate in pixels of the control
  68528. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68529. */
  68530. get leftInPixels(): number;
  68531. set leftInPixels(value: number);
  68532. /**
  68533. * Gets or sets a value indicating the top coordinate of the control
  68534. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68535. */
  68536. get top(): string | number;
  68537. set top(value: string | number);
  68538. /**
  68539. * Gets or sets a value indicating the top coordinate in pixels of the control
  68540. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68541. */
  68542. get topInPixels(): number;
  68543. set topInPixels(value: number);
  68544. /**
  68545. * Gets or sets a value indicating the offset on X axis to the linked mesh
  68546. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68547. */
  68548. get linkOffsetX(): string | number;
  68549. set linkOffsetX(value: string | number);
  68550. /**
  68551. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  68552. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68553. */
  68554. get linkOffsetXInPixels(): number;
  68555. set linkOffsetXInPixels(value: number);
  68556. /**
  68557. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  68558. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68559. */
  68560. get linkOffsetY(): string | number;
  68561. set linkOffsetY(value: string | number);
  68562. /**
  68563. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  68564. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68565. */
  68566. get linkOffsetYInPixels(): number;
  68567. set linkOffsetYInPixels(value: number);
  68568. /** Gets the center coordinate on X axis */
  68569. get centerX(): number;
  68570. /** Gets the center coordinate on Y axis */
  68571. get centerY(): number;
  68572. /** Gets or sets if control is Enabled*/
  68573. get isEnabled(): boolean;
  68574. set isEnabled(value: boolean);
  68575. /** Gets or sets background color of control if it's disabled*/
  68576. get disabledColor(): string;
  68577. set disabledColor(value: string);
  68578. /**
  68579. * Creates a new control
  68580. * @param name defines the name of the control
  68581. */
  68582. constructor(
  68583. /** defines the name of the control */
  68584. name?: string | undefined);
  68585. /** @hidden */
  68586. protected _getTypeName(): string;
  68587. /**
  68588. * Gets the first ascendant in the hierarchy of the given type
  68589. * @param className defines the required type
  68590. * @returns the ascendant or null if not found
  68591. */
  68592. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  68593. /** @hidden */
  68594. _resetFontCache(): void;
  68595. /**
  68596. * Determines if a container is an ascendant of the current control
  68597. * @param container defines the container to look for
  68598. * @returns true if the container is one of the ascendant of the control
  68599. */
  68600. isAscendant(container: Control): boolean;
  68601. /**
  68602. * Gets coordinates in local control space
  68603. * @param globalCoordinates defines the coordinates to transform
  68604. * @returns the new coordinates in local space
  68605. */
  68606. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68607. /**
  68608. * Gets coordinates in local control space
  68609. * @param globalCoordinates defines the coordinates to transform
  68610. * @param result defines the target vector2 where to store the result
  68611. * @returns the current control
  68612. */
  68613. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  68614. /**
  68615. * Gets coordinates in parent local control space
  68616. * @param globalCoordinates defines the coordinates to transform
  68617. * @returns the new coordinates in parent local space
  68618. */
  68619. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68620. /**
  68621. * Move the current control to a vector3 position projected onto the screen.
  68622. * @param position defines the target position
  68623. * @param scene defines the hosting scene
  68624. */
  68625. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  68626. /**
  68627. * Will store all controls that have this control as ascendant in a given array
  68628. * @param results defines the array where to store the descendants
  68629. * @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
  68630. * @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
  68631. */
  68632. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68633. /**
  68634. * Will return all controls that have this control as ascendant
  68635. * @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
  68636. * @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
  68637. * @return all child controls
  68638. */
  68639. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68640. /**
  68641. * Link current control with a target mesh
  68642. * @param mesh defines the mesh to link with
  68643. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68644. */
  68645. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  68646. /** @hidden */
  68647. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  68648. /** @hidden */
  68649. _offsetLeft(offset: number): void;
  68650. /** @hidden */
  68651. _offsetTop(offset: number): void;
  68652. /** @hidden */
  68653. _markMatrixAsDirty(): void;
  68654. /** @hidden */
  68655. _flagDescendantsAsMatrixDirty(): void;
  68656. /** @hidden */
  68657. _intersectsRect(rect: Measure): boolean;
  68658. /** @hidden */
  68659. protected invalidateRect(): void;
  68660. /** @hidden */
  68661. _markAsDirty(force?: boolean): void;
  68662. /** @hidden */
  68663. _markAllAsDirty(): void;
  68664. /** @hidden */
  68665. _link(host: AdvancedDynamicTexture): void;
  68666. /** @hidden */
  68667. protected _transform(context?: CanvasRenderingContext2D): void;
  68668. /** @hidden */
  68669. _renderHighlight(context: CanvasRenderingContext2D): void;
  68670. /** @hidden */
  68671. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68672. /** @hidden */
  68673. protected _applyStates(context: CanvasRenderingContext2D): void;
  68674. /** @hidden */
  68675. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68676. /** @hidden */
  68677. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68678. protected _evaluateClippingState(parentMeasure: Measure): void;
  68679. /** @hidden */
  68680. _measure(): void;
  68681. /** @hidden */
  68682. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68683. /** @hidden */
  68684. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68685. /** @hidden */
  68686. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68687. /** @hidden */
  68688. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68689. private static _ClipMeasure;
  68690. private _tmpMeasureA;
  68691. private _clip;
  68692. /** @hidden */
  68693. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  68694. /** @hidden */
  68695. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68696. /**
  68697. * Tests if a given coordinates belong to the current control
  68698. * @param x defines x coordinate to test
  68699. * @param y defines y coordinate to test
  68700. * @returns true if the coordinates are inside the control
  68701. */
  68702. contains(x: number, y: number): boolean;
  68703. /** @hidden */
  68704. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68705. /** @hidden */
  68706. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68707. /** @hidden */
  68708. _onPointerEnter(target: Control): boolean;
  68709. /** @hidden */
  68710. _onPointerOut(target: Control, force?: boolean): void;
  68711. /** @hidden */
  68712. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68713. /** @hidden */
  68714. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68715. /** @hidden */
  68716. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68717. /** @hidden */
  68718. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  68719. private _prepareFont;
  68720. /** Releases associated resources */
  68721. dispose(): void;
  68722. private static _HORIZONTAL_ALIGNMENT_LEFT;
  68723. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  68724. private static _HORIZONTAL_ALIGNMENT_CENTER;
  68725. private static _VERTICAL_ALIGNMENT_TOP;
  68726. private static _VERTICAL_ALIGNMENT_BOTTOM;
  68727. private static _VERTICAL_ALIGNMENT_CENTER;
  68728. /** HORIZONTAL_ALIGNMENT_LEFT */
  68729. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  68730. /** HORIZONTAL_ALIGNMENT_RIGHT */
  68731. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  68732. /** HORIZONTAL_ALIGNMENT_CENTER */
  68733. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  68734. /** VERTICAL_ALIGNMENT_TOP */
  68735. static get VERTICAL_ALIGNMENT_TOP(): number;
  68736. /** VERTICAL_ALIGNMENT_BOTTOM */
  68737. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  68738. /** VERTICAL_ALIGNMENT_CENTER */
  68739. static get VERTICAL_ALIGNMENT_CENTER(): number;
  68740. private static _FontHeightSizes;
  68741. /** @hidden */
  68742. static _GetFontOffset(font: string): {
  68743. ascent: number;
  68744. height: number;
  68745. descent: number;
  68746. };
  68747. /**
  68748. * Creates a stack panel that can be used to render headers
  68749. * @param control defines the control to associate with the header
  68750. * @param text defines the text of the header
  68751. * @param size defines the size of the header
  68752. * @param options defines options used to configure the header
  68753. * @returns a new StackPanel
  68754. * @ignore
  68755. * @hidden
  68756. */
  68757. static AddHeader: (control: Control, text: string, size: string | number, options: {
  68758. isHorizontal: boolean;
  68759. controlFirst: boolean;
  68760. }) => any;
  68761. /** @hidden */
  68762. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  68763. }
  68764. }
  68765. declare module BABYLON.GUI {
  68766. /**
  68767. * Root class for 2D containers
  68768. * @see http://doc.babylonjs.com/how_to/gui#containers
  68769. */
  68770. export class Container extends Control {
  68771. name?: string | undefined;
  68772. /** @hidden */
  68773. protected _children: Control[];
  68774. /** @hidden */
  68775. protected _measureForChildren: Measure;
  68776. /** @hidden */
  68777. protected _background: string;
  68778. /** @hidden */
  68779. protected _adaptWidthToChildren: boolean;
  68780. /** @hidden */
  68781. protected _adaptHeightToChildren: boolean;
  68782. /**
  68783. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68784. */
  68785. logLayoutCycleErrors: boolean;
  68786. /**
  68787. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68788. */
  68789. maxLayoutCycle: number;
  68790. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68791. get adaptHeightToChildren(): boolean;
  68792. set adaptHeightToChildren(value: boolean);
  68793. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68794. get adaptWidthToChildren(): boolean;
  68795. set adaptWidthToChildren(value: boolean);
  68796. /** Gets or sets background color */
  68797. get background(): string;
  68798. set background(value: string);
  68799. /** Gets the list of children */
  68800. get children(): Control[];
  68801. /**
  68802. * Creates a new Container
  68803. * @param name defines the name of the container
  68804. */
  68805. constructor(name?: string | undefined);
  68806. protected _getTypeName(): string;
  68807. _flagDescendantsAsMatrixDirty(): void;
  68808. /**
  68809. * Gets a child using its name
  68810. * @param name defines the child name to look for
  68811. * @returns the child control if found
  68812. */
  68813. getChildByName(name: string): BABYLON.Nullable<Control>;
  68814. /**
  68815. * Gets a child using its type and its name
  68816. * @param name defines the child name to look for
  68817. * @param type defines the child type to look for
  68818. * @returns the child control if found
  68819. */
  68820. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68821. /**
  68822. * Search for a specific control in children
  68823. * @param control defines the control to look for
  68824. * @returns true if the control is in child list
  68825. */
  68826. containsControl(control: Control): boolean;
  68827. /**
  68828. * Adds a new control to the current container
  68829. * @param control defines the control to add
  68830. * @returns the current container
  68831. */
  68832. addControl(control: BABYLON.Nullable<Control>): Container;
  68833. /**
  68834. * Removes all controls from the current container
  68835. * @returns the current container
  68836. */
  68837. clearControls(): Container;
  68838. /**
  68839. * Removes a control from the current container
  68840. * @param control defines the control to remove
  68841. * @returns the current container
  68842. */
  68843. removeControl(control: Control): Container;
  68844. /** @hidden */
  68845. _reOrderControl(control: Control): void;
  68846. /** @hidden */
  68847. _offsetLeft(offset: number): void;
  68848. /** @hidden */
  68849. _offsetTop(offset: number): void;
  68850. /** @hidden */
  68851. _markAllAsDirty(): void;
  68852. /** @hidden */
  68853. protected _localDraw(context: CanvasRenderingContext2D): void;
  68854. /** @hidden */
  68855. _link(host: AdvancedDynamicTexture): void;
  68856. /** @hidden */
  68857. protected _beforeLayout(): void;
  68858. /** @hidden */
  68859. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68860. /** @hidden */
  68861. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68862. protected _postMeasure(): void;
  68863. /** @hidden */
  68864. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68865. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68866. /** @hidden */
  68867. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68868. /** @hidden */
  68869. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68870. /** Releases associated resources */
  68871. dispose(): void;
  68872. }
  68873. }
  68874. declare module BABYLON.GUI {
  68875. /** Class used to create rectangle container */
  68876. export class Rectangle extends Container {
  68877. name?: string | undefined;
  68878. private _thickness;
  68879. private _cornerRadius;
  68880. /** Gets or sets border thickness */
  68881. get thickness(): number;
  68882. set thickness(value: number);
  68883. /** Gets or sets the corner radius angle */
  68884. get cornerRadius(): number;
  68885. set cornerRadius(value: number);
  68886. /**
  68887. * Creates a new Rectangle
  68888. * @param name defines the control name
  68889. */
  68890. constructor(name?: string | undefined);
  68891. protected _getTypeName(): string;
  68892. protected _localDraw(context: CanvasRenderingContext2D): void;
  68893. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68894. private _drawRoundedRect;
  68895. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68896. }
  68897. }
  68898. declare module BABYLON.GUI {
  68899. /**
  68900. * Enum that determines the text-wrapping mode to use.
  68901. */
  68902. export enum TextWrapping {
  68903. /**
  68904. * Clip the text when it's larger than Control.width; this is the default mode.
  68905. */
  68906. Clip = 0,
  68907. /**
  68908. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68909. */
  68910. WordWrap = 1,
  68911. /**
  68912. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68913. */
  68914. Ellipsis = 2
  68915. }
  68916. /**
  68917. * Class used to create text block control
  68918. */
  68919. export class TextBlock extends Control {
  68920. /**
  68921. * Defines the name of the control
  68922. */
  68923. name?: string | undefined;
  68924. private _text;
  68925. private _textWrapping;
  68926. private _textHorizontalAlignment;
  68927. private _textVerticalAlignment;
  68928. private _lines;
  68929. private _resizeToFit;
  68930. private _lineSpacing;
  68931. private _outlineWidth;
  68932. private _outlineColor;
  68933. /**
  68934. * An event triggered after the text is changed
  68935. */
  68936. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68937. /**
  68938. * An event triggered after the text was broken up into lines
  68939. */
  68940. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68941. /**
  68942. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68943. */
  68944. get lines(): any[];
  68945. /**
  68946. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68947. */
  68948. get resizeToFit(): boolean;
  68949. /**
  68950. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68951. */
  68952. set resizeToFit(value: boolean);
  68953. /**
  68954. * Gets or sets a boolean indicating if text must be wrapped
  68955. */
  68956. get textWrapping(): TextWrapping | boolean;
  68957. /**
  68958. * Gets or sets a boolean indicating if text must be wrapped
  68959. */
  68960. set textWrapping(value: TextWrapping | boolean);
  68961. /**
  68962. * Gets or sets text to display
  68963. */
  68964. get text(): string;
  68965. /**
  68966. * Gets or sets text to display
  68967. */
  68968. set text(value: string);
  68969. /**
  68970. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68971. */
  68972. get textHorizontalAlignment(): number;
  68973. /**
  68974. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68975. */
  68976. set textHorizontalAlignment(value: number);
  68977. /**
  68978. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68979. */
  68980. get textVerticalAlignment(): number;
  68981. /**
  68982. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68983. */
  68984. set textVerticalAlignment(value: number);
  68985. /**
  68986. * Gets or sets line spacing value
  68987. */
  68988. set lineSpacing(value: string | number);
  68989. /**
  68990. * Gets or sets line spacing value
  68991. */
  68992. get lineSpacing(): string | number;
  68993. /**
  68994. * Gets or sets outlineWidth of the text to display
  68995. */
  68996. get outlineWidth(): number;
  68997. /**
  68998. * Gets or sets outlineWidth of the text to display
  68999. */
  69000. set outlineWidth(value: number);
  69001. /**
  69002. * Gets or sets outlineColor of the text to display
  69003. */
  69004. get outlineColor(): string;
  69005. /**
  69006. * Gets or sets outlineColor of the text to display
  69007. */
  69008. set outlineColor(value: string);
  69009. /**
  69010. * Creates a new TextBlock object
  69011. * @param name defines the name of the control
  69012. * @param text defines the text to display (emptry string by default)
  69013. */
  69014. constructor(
  69015. /**
  69016. * Defines the name of the control
  69017. */
  69018. name?: string | undefined, text?: string);
  69019. protected _getTypeName(): string;
  69020. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69021. private _drawText;
  69022. /** @hidden */
  69023. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69024. protected _applyStates(context: CanvasRenderingContext2D): void;
  69025. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  69026. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  69027. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  69028. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  69029. protected _renderLines(context: CanvasRenderingContext2D): void;
  69030. /**
  69031. * Given a width constraint applied on the text block, find the expected height
  69032. * @returns expected height
  69033. */
  69034. computeExpectedHeight(): number;
  69035. dispose(): void;
  69036. }
  69037. }
  69038. declare module BABYLON.GUI {
  69039. /**
  69040. * Class used to create 2D images
  69041. */
  69042. export class Image extends Control {
  69043. name?: string | undefined;
  69044. private _workingCanvas;
  69045. private _domImage;
  69046. private _imageWidth;
  69047. private _imageHeight;
  69048. private _loaded;
  69049. private _stretch;
  69050. private _source;
  69051. private _autoScale;
  69052. private _sourceLeft;
  69053. private _sourceTop;
  69054. private _sourceWidth;
  69055. private _sourceHeight;
  69056. private _cellWidth;
  69057. private _cellHeight;
  69058. private _cellId;
  69059. private _populateNinePatchSlicesFromImage;
  69060. private _sliceLeft;
  69061. private _sliceRight;
  69062. private _sliceTop;
  69063. private _sliceBottom;
  69064. private _detectPointerOnOpaqueOnly;
  69065. /**
  69066. * BABYLON.Observable notified when the content is loaded
  69067. */
  69068. onImageLoadedObservable: BABYLON.Observable<Image>;
  69069. /**
  69070. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  69071. */
  69072. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  69073. /**
  69074. * Gets a boolean indicating that the content is loaded
  69075. */
  69076. get isLoaded(): boolean;
  69077. /**
  69078. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  69079. */
  69080. get populateNinePatchSlicesFromImage(): boolean;
  69081. set populateNinePatchSlicesFromImage(value: boolean);
  69082. /**
  69083. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  69084. * Beware using this as this will comsume more memory as the image has to be stored twice
  69085. */
  69086. get detectPointerOnOpaqueOnly(): boolean;
  69087. set detectPointerOnOpaqueOnly(value: boolean);
  69088. /**
  69089. * Gets or sets the left value for slicing (9-patch)
  69090. */
  69091. get sliceLeft(): number;
  69092. set sliceLeft(value: number);
  69093. /**
  69094. * Gets or sets the right value for slicing (9-patch)
  69095. */
  69096. get sliceRight(): number;
  69097. set sliceRight(value: number);
  69098. /**
  69099. * Gets or sets the top value for slicing (9-patch)
  69100. */
  69101. get sliceTop(): number;
  69102. set sliceTop(value: number);
  69103. /**
  69104. * Gets or sets the bottom value for slicing (9-patch)
  69105. */
  69106. get sliceBottom(): number;
  69107. set sliceBottom(value: number);
  69108. /**
  69109. * Gets or sets the left coordinate in the source image
  69110. */
  69111. get sourceLeft(): number;
  69112. set sourceLeft(value: number);
  69113. /**
  69114. * Gets or sets the top coordinate in the source image
  69115. */
  69116. get sourceTop(): number;
  69117. set sourceTop(value: number);
  69118. /**
  69119. * Gets or sets the width to capture in the source image
  69120. */
  69121. get sourceWidth(): number;
  69122. set sourceWidth(value: number);
  69123. /**
  69124. * Gets or sets the height to capture in the source image
  69125. */
  69126. get sourceHeight(): number;
  69127. set sourceHeight(value: number);
  69128. /**
  69129. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69130. * @see http://doc.babylonjs.com/how_to/gui#image
  69131. */
  69132. get autoScale(): boolean;
  69133. set autoScale(value: boolean);
  69134. /** Gets or sets the streching mode used by the image */
  69135. get stretch(): number;
  69136. set stretch(value: number);
  69137. /** @hidden */
  69138. _rotate90(n: number): Image;
  69139. /**
  69140. * Gets or sets the internal DOM image used to render the control
  69141. */
  69142. set domImage(value: HTMLImageElement);
  69143. get domImage(): HTMLImageElement;
  69144. private _onImageLoaded;
  69145. private _extractNinePatchSliceDataFromImage;
  69146. /**
  69147. * Gets or sets image source url
  69148. */
  69149. set source(value: BABYLON.Nullable<string>);
  69150. /**
  69151. * Checks for svg document with icon id present
  69152. */
  69153. private _svgCheck;
  69154. /**
  69155. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69156. * given external svg file and icon id
  69157. */
  69158. private _getSVGAttribs;
  69159. /**
  69160. * Gets or sets the cell width to use when animation sheet is enabled
  69161. * @see http://doc.babylonjs.com/how_to/gui#image
  69162. */
  69163. get cellWidth(): number;
  69164. set cellWidth(value: number);
  69165. /**
  69166. * Gets or sets the cell height to use when animation sheet is enabled
  69167. * @see http://doc.babylonjs.com/how_to/gui#image
  69168. */
  69169. get cellHeight(): number;
  69170. set cellHeight(value: number);
  69171. /**
  69172. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69173. * @see http://doc.babylonjs.com/how_to/gui#image
  69174. */
  69175. get cellId(): number;
  69176. set cellId(value: number);
  69177. /**
  69178. * Creates a new Image
  69179. * @param name defines the control name
  69180. * @param url defines the image url
  69181. */
  69182. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69183. /**
  69184. * Tests if a given coordinates belong to the current control
  69185. * @param x defines x coordinate to test
  69186. * @param y defines y coordinate to test
  69187. * @returns true if the coordinates are inside the control
  69188. */
  69189. contains(x: number, y: number): boolean;
  69190. protected _getTypeName(): string;
  69191. /** Force the control to synchronize with its content */
  69192. synchronizeSizeWithContent(): void;
  69193. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69194. private _prepareWorkingCanvasForOpaqueDetection;
  69195. private _drawImage;
  69196. _draw(context: CanvasRenderingContext2D): void;
  69197. private _renderCornerPatch;
  69198. private _renderNinePatch;
  69199. dispose(): void;
  69200. /** STRETCH_NONE */
  69201. static readonly STRETCH_NONE: number;
  69202. /** STRETCH_FILL */
  69203. static readonly STRETCH_FILL: number;
  69204. /** STRETCH_UNIFORM */
  69205. static readonly STRETCH_UNIFORM: number;
  69206. /** STRETCH_EXTEND */
  69207. static readonly STRETCH_EXTEND: number;
  69208. /** NINE_PATCH */
  69209. static readonly STRETCH_NINE_PATCH: number;
  69210. }
  69211. }
  69212. declare module BABYLON.GUI {
  69213. /**
  69214. * Class used to create 2D buttons
  69215. */
  69216. export class Button extends Rectangle {
  69217. name?: string | undefined;
  69218. /**
  69219. * Function called to generate a pointer enter animation
  69220. */
  69221. pointerEnterAnimation: () => void;
  69222. /**
  69223. * Function called to generate a pointer out animation
  69224. */
  69225. pointerOutAnimation: () => void;
  69226. /**
  69227. * Function called to generate a pointer down animation
  69228. */
  69229. pointerDownAnimation: () => void;
  69230. /**
  69231. * Function called to generate a pointer up animation
  69232. */
  69233. pointerUpAnimation: () => void;
  69234. /**
  69235. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69236. */
  69237. delegatePickingToChildren: boolean;
  69238. private _image;
  69239. /**
  69240. * Returns the image part of the button (if any)
  69241. */
  69242. get image(): BABYLON.Nullable<Image>;
  69243. private _textBlock;
  69244. /**
  69245. * Returns the image part of the button (if any)
  69246. */
  69247. get textBlock(): BABYLON.Nullable<TextBlock>;
  69248. /**
  69249. * Creates a new Button
  69250. * @param name defines the name of the button
  69251. */
  69252. constructor(name?: string | undefined);
  69253. protected _getTypeName(): string;
  69254. /** @hidden */
  69255. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69256. /** @hidden */
  69257. _onPointerEnter(target: Control): boolean;
  69258. /** @hidden */
  69259. _onPointerOut(target: Control, force?: boolean): void;
  69260. /** @hidden */
  69261. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69262. /** @hidden */
  69263. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69264. /**
  69265. * Creates a new button made with an image and a text
  69266. * @param name defines the name of the button
  69267. * @param text defines the text of the button
  69268. * @param imageUrl defines the url of the image
  69269. * @returns a new Button
  69270. */
  69271. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69272. /**
  69273. * Creates a new button made with an image
  69274. * @param name defines the name of the button
  69275. * @param imageUrl defines the url of the image
  69276. * @returns a new Button
  69277. */
  69278. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69279. /**
  69280. * Creates a new button made with a text
  69281. * @param name defines the name of the button
  69282. * @param text defines the text of the button
  69283. * @returns a new Button
  69284. */
  69285. static CreateSimpleButton(name: string, text: string): Button;
  69286. /**
  69287. * Creates a new button made with an image and a centered text
  69288. * @param name defines the name of the button
  69289. * @param text defines the text of the button
  69290. * @param imageUrl defines the url of the image
  69291. * @returns a new Button
  69292. */
  69293. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69294. }
  69295. }
  69296. declare module BABYLON.GUI {
  69297. /**
  69298. * Class used to create a 2D stack panel container
  69299. */
  69300. export class StackPanel extends Container {
  69301. name?: string | undefined;
  69302. private _isVertical;
  69303. private _manualWidth;
  69304. private _manualHeight;
  69305. private _doNotTrackManualChanges;
  69306. /**
  69307. * Gets or sets a boolean indicating that layou warnings should be ignored
  69308. */
  69309. ignoreLayoutWarnings: boolean;
  69310. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69311. get isVertical(): boolean;
  69312. set isVertical(value: boolean);
  69313. /**
  69314. * Gets or sets panel width.
  69315. * This value should not be set when in horizontal mode as it will be computed automatically
  69316. */
  69317. set width(value: string | number);
  69318. get width(): string | number;
  69319. /**
  69320. * Gets or sets panel height.
  69321. * This value should not be set when in vertical mode as it will be computed automatically
  69322. */
  69323. set height(value: string | number);
  69324. get height(): string | number;
  69325. /**
  69326. * Creates a new StackPanel
  69327. * @param name defines control name
  69328. */
  69329. constructor(name?: string | undefined);
  69330. protected _getTypeName(): string;
  69331. /** @hidden */
  69332. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69333. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69334. protected _postMeasure(): void;
  69335. }
  69336. }
  69337. declare module BABYLON.GUI {
  69338. /**
  69339. * Class used to represent a 2D checkbox
  69340. */
  69341. export class Checkbox extends Control {
  69342. name?: string | undefined;
  69343. private _isChecked;
  69344. private _background;
  69345. private _checkSizeRatio;
  69346. private _thickness;
  69347. /** Gets or sets border thickness */
  69348. get thickness(): number;
  69349. set thickness(value: number);
  69350. /**
  69351. * BABYLON.Observable raised when isChecked property changes
  69352. */
  69353. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69354. /** Gets or sets a value indicating the ratio between overall size and check size */
  69355. get checkSizeRatio(): number;
  69356. set checkSizeRatio(value: number);
  69357. /** Gets or sets background color */
  69358. get background(): string;
  69359. set background(value: string);
  69360. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69361. get isChecked(): boolean;
  69362. set isChecked(value: boolean);
  69363. /**
  69364. * Creates a new CheckBox
  69365. * @param name defines the control name
  69366. */
  69367. constructor(name?: string | undefined);
  69368. protected _getTypeName(): string;
  69369. /** @hidden */
  69370. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69371. /** @hidden */
  69372. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69373. /**
  69374. * Utility function to easily create a checkbox with a header
  69375. * @param title defines the label to use for the header
  69376. * @param onValueChanged defines the callback to call when value changes
  69377. * @returns a StackPanel containing the checkbox and a textBlock
  69378. */
  69379. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  69380. }
  69381. }
  69382. declare module BABYLON.GUI {
  69383. /**
  69384. * Class used to store key control properties
  69385. */
  69386. export class KeyPropertySet {
  69387. /** Width */
  69388. width?: string;
  69389. /** Height */
  69390. height?: string;
  69391. /** Left padding */
  69392. paddingLeft?: string;
  69393. /** Right padding */
  69394. paddingRight?: string;
  69395. /** Top padding */
  69396. paddingTop?: string;
  69397. /** Bottom padding */
  69398. paddingBottom?: string;
  69399. /** Foreground color */
  69400. color?: string;
  69401. /** Background color */
  69402. background?: string;
  69403. }
  69404. /**
  69405. * Class used to create virtual keyboard
  69406. */
  69407. export class VirtualKeyboard extends StackPanel {
  69408. /** BABYLON.Observable raised when a key is pressed */
  69409. onKeyPressObservable: BABYLON.Observable<string>;
  69410. /** Gets or sets default key button width */
  69411. defaultButtonWidth: string;
  69412. /** Gets or sets default key button height */
  69413. defaultButtonHeight: string;
  69414. /** Gets or sets default key button left padding */
  69415. defaultButtonPaddingLeft: string;
  69416. /** Gets or sets default key button right padding */
  69417. defaultButtonPaddingRight: string;
  69418. /** Gets or sets default key button top padding */
  69419. defaultButtonPaddingTop: string;
  69420. /** Gets or sets default key button bottom padding */
  69421. defaultButtonPaddingBottom: string;
  69422. /** Gets or sets default key button foreground color */
  69423. defaultButtonColor: string;
  69424. /** Gets or sets default key button background color */
  69425. defaultButtonBackground: string;
  69426. /** Gets or sets shift button foreground color */
  69427. shiftButtonColor: string;
  69428. /** Gets or sets shift button thickness*/
  69429. selectedShiftThickness: number;
  69430. /** Gets shift key state */
  69431. shiftState: number;
  69432. protected _getTypeName(): string;
  69433. private _createKey;
  69434. /**
  69435. * Adds a new row of keys
  69436. * @param keys defines the list of keys to add
  69437. * @param propertySets defines the associated property sets
  69438. */
  69439. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  69440. /**
  69441. * Set the shift key to a specific state
  69442. * @param shiftState defines the new shift state
  69443. */
  69444. applyShiftState(shiftState: number): void;
  69445. private _currentlyConnectedInputText;
  69446. private _connectedInputTexts;
  69447. private _onKeyPressObserver;
  69448. /** Gets the input text control currently attached to the keyboard */
  69449. get connectedInputText(): BABYLON.Nullable<InputText>;
  69450. /**
  69451. * Connects the keyboard with an input text control
  69452. *
  69453. * @param input defines the target control
  69454. */
  69455. connect(input: InputText): void;
  69456. /**
  69457. * Disconnects the keyboard from connected InputText controls
  69458. *
  69459. * @param input optionally defines a target control, otherwise all are disconnected
  69460. */
  69461. disconnect(input?: InputText): void;
  69462. private _removeConnectedInputObservables;
  69463. /**
  69464. * Release all resources
  69465. */
  69466. dispose(): void;
  69467. /**
  69468. * Creates a new keyboard using a default layout
  69469. *
  69470. * @param name defines control name
  69471. * @returns a new VirtualKeyboard
  69472. */
  69473. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  69474. }
  69475. }
  69476. declare module BABYLON.GUI {
  69477. /**
  69478. * Class used to create input text control
  69479. */
  69480. export class InputText extends Control implements IFocusableControl {
  69481. name?: string | undefined;
  69482. private _text;
  69483. private _placeholderText;
  69484. private _background;
  69485. private _focusedBackground;
  69486. private _focusedColor;
  69487. private _placeholderColor;
  69488. private _thickness;
  69489. private _margin;
  69490. private _autoStretchWidth;
  69491. private _maxWidth;
  69492. private _isFocused;
  69493. private _blinkTimeout;
  69494. private _blinkIsEven;
  69495. private _cursorOffset;
  69496. private _scrollLeft;
  69497. private _textWidth;
  69498. private _clickedCoordinate;
  69499. private _deadKey;
  69500. private _addKey;
  69501. private _currentKey;
  69502. private _isTextHighlightOn;
  69503. private _textHighlightColor;
  69504. private _highligherOpacity;
  69505. private _highlightedText;
  69506. private _startHighlightIndex;
  69507. private _endHighlightIndex;
  69508. private _cursorIndex;
  69509. private _onFocusSelectAll;
  69510. private _isPointerDown;
  69511. private _onClipboardObserver;
  69512. private _onPointerDblTapObserver;
  69513. /** @hidden */
  69514. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  69515. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  69516. promptMessage: string;
  69517. /** Force disable prompt on mobile device */
  69518. disableMobilePrompt: boolean;
  69519. /** BABYLON.Observable raised when the text changes */
  69520. onTextChangedObservable: BABYLON.Observable<InputText>;
  69521. /** BABYLON.Observable raised just before an entered character is to be added */
  69522. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  69523. /** BABYLON.Observable raised when the control gets the focus */
  69524. onFocusObservable: BABYLON.Observable<InputText>;
  69525. /** BABYLON.Observable raised when the control loses the focus */
  69526. onBlurObservable: BABYLON.Observable<InputText>;
  69527. /**Observable raised when the text is highlighted */
  69528. onTextHighlightObservable: BABYLON.Observable<InputText>;
  69529. /**Observable raised when copy event is triggered */
  69530. onTextCopyObservable: BABYLON.Observable<InputText>;
  69531. /** BABYLON.Observable raised when cut event is triggered */
  69532. onTextCutObservable: BABYLON.Observable<InputText>;
  69533. /** BABYLON.Observable raised when paste event is triggered */
  69534. onTextPasteObservable: BABYLON.Observable<InputText>;
  69535. /** BABYLON.Observable raised when a key event was processed */
  69536. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  69537. /** Gets or sets the maximum width allowed by the control */
  69538. get maxWidth(): string | number;
  69539. /** Gets the maximum width allowed by the control in pixels */
  69540. get maxWidthInPixels(): number;
  69541. set maxWidth(value: string | number);
  69542. /** Gets or sets the text highlighter transparency; default: 0.4 */
  69543. get highligherOpacity(): number;
  69544. set highligherOpacity(value: number);
  69545. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  69546. get onFocusSelectAll(): boolean;
  69547. set onFocusSelectAll(value: boolean);
  69548. /** Gets or sets the text hightlight color */
  69549. get textHighlightColor(): string;
  69550. set textHighlightColor(value: string);
  69551. /** Gets or sets control margin */
  69552. get margin(): string;
  69553. /** Gets control margin in pixels */
  69554. get marginInPixels(): number;
  69555. set margin(value: string);
  69556. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  69557. get autoStretchWidth(): boolean;
  69558. set autoStretchWidth(value: boolean);
  69559. /** Gets or sets border thickness */
  69560. get thickness(): number;
  69561. set thickness(value: number);
  69562. /** Gets or sets the background color when focused */
  69563. get focusedBackground(): string;
  69564. set focusedBackground(value: string);
  69565. /** Gets or sets the background color when focused */
  69566. get focusedColor(): string;
  69567. set focusedColor(value: string);
  69568. /** Gets or sets the background color */
  69569. get background(): string;
  69570. set background(value: string);
  69571. /** Gets or sets the placeholder color */
  69572. get placeholderColor(): string;
  69573. set placeholderColor(value: string);
  69574. /** Gets or sets the text displayed when the control is empty */
  69575. get placeholderText(): string;
  69576. set placeholderText(value: string);
  69577. /** Gets or sets the dead key flag */
  69578. get deadKey(): boolean;
  69579. set deadKey(flag: boolean);
  69580. /** Gets or sets the highlight text */
  69581. get highlightedText(): string;
  69582. set highlightedText(text: string);
  69583. /** Gets or sets if the current key should be added */
  69584. get addKey(): boolean;
  69585. set addKey(flag: boolean);
  69586. /** Gets or sets the value of the current key being entered */
  69587. get currentKey(): string;
  69588. set currentKey(key: string);
  69589. /** Gets or sets the text displayed in the control */
  69590. get text(): string;
  69591. set text(value: string);
  69592. /** Gets or sets control width */
  69593. get width(): string | number;
  69594. set width(value: string | number);
  69595. /**
  69596. * Creates a new InputText
  69597. * @param name defines the control name
  69598. * @param text defines the text of the control
  69599. */
  69600. constructor(name?: string | undefined, text?: string);
  69601. /** @hidden */
  69602. onBlur(): void;
  69603. /** @hidden */
  69604. onFocus(): void;
  69605. protected _getTypeName(): string;
  69606. /**
  69607. * Function called to get the list of controls that should not steal the focus from this control
  69608. * @returns an array of controls
  69609. */
  69610. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69611. /** @hidden */
  69612. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  69613. /** @hidden */
  69614. private _updateValueFromCursorIndex;
  69615. /** @hidden */
  69616. private _processDblClick;
  69617. /** @hidden */
  69618. private _selectAllText;
  69619. /**
  69620. * Handles the keyboard event
  69621. * @param evt Defines the KeyboardEvent
  69622. */
  69623. processKeyboard(evt: KeyboardEvent): void;
  69624. /** @hidden */
  69625. private _onCopyText;
  69626. /** @hidden */
  69627. private _onCutText;
  69628. /** @hidden */
  69629. private _onPasteText;
  69630. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69631. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69632. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69633. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69634. protected _beforeRenderText(text: string): string;
  69635. dispose(): void;
  69636. }
  69637. }
  69638. declare module BABYLON.GUI {
  69639. /**
  69640. * Class used to create a 2D grid container
  69641. */
  69642. export class Grid extends Container {
  69643. name?: string | undefined;
  69644. private _rowDefinitions;
  69645. private _columnDefinitions;
  69646. private _cells;
  69647. private _childControls;
  69648. /**
  69649. * Gets the number of columns
  69650. */
  69651. get columnCount(): number;
  69652. /**
  69653. * Gets the number of rows
  69654. */
  69655. get rowCount(): number;
  69656. /** Gets the list of children */
  69657. get children(): Control[];
  69658. /** Gets the list of cells (e.g. the containers) */
  69659. get cells(): {
  69660. [key: string]: Container;
  69661. };
  69662. /**
  69663. * Gets the definition of a specific row
  69664. * @param index defines the index of the row
  69665. * @returns the row definition
  69666. */
  69667. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69668. /**
  69669. * Gets the definition of a specific column
  69670. * @param index defines the index of the column
  69671. * @returns the column definition
  69672. */
  69673. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69674. /**
  69675. * Adds a new row to the grid
  69676. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69677. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  69678. * @returns the current grid
  69679. */
  69680. addRowDefinition(height: number, isPixel?: boolean): Grid;
  69681. /**
  69682. * Adds a new column to the grid
  69683. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69684. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69685. * @returns the current grid
  69686. */
  69687. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  69688. /**
  69689. * Update a row definition
  69690. * @param index defines the index of the row to update
  69691. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69692. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  69693. * @returns the current grid
  69694. */
  69695. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  69696. /**
  69697. * Update a column definition
  69698. * @param index defines the index of the column to update
  69699. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69700. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69701. * @returns the current grid
  69702. */
  69703. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  69704. /**
  69705. * Gets the list of children stored in a specific cell
  69706. * @param row defines the row to check
  69707. * @param column defines the column to check
  69708. * @returns the list of controls
  69709. */
  69710. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  69711. /**
  69712. * Gets a string representing the child cell info (row x column)
  69713. * @param child defines the control to get info from
  69714. * @returns a string containing the child cell info (row x column)
  69715. */
  69716. getChildCellInfo(child: Control): string;
  69717. private _removeCell;
  69718. private _offsetCell;
  69719. /**
  69720. * Remove a column definition at specified index
  69721. * @param index defines the index of the column to remove
  69722. * @returns the current grid
  69723. */
  69724. removeColumnDefinition(index: number): Grid;
  69725. /**
  69726. * Remove a row definition at specified index
  69727. * @param index defines the index of the row to remove
  69728. * @returns the current grid
  69729. */
  69730. removeRowDefinition(index: number): Grid;
  69731. /**
  69732. * Adds a new control to the current grid
  69733. * @param control defines the control to add
  69734. * @param row defines the row where to add the control (0 by default)
  69735. * @param column defines the column where to add the control (0 by default)
  69736. * @returns the current grid
  69737. */
  69738. addControl(control: Control, row?: number, column?: number): Grid;
  69739. /**
  69740. * Removes a control from the current container
  69741. * @param control defines the control to remove
  69742. * @returns the current container
  69743. */
  69744. removeControl(control: Control): Container;
  69745. /**
  69746. * Creates a new Grid
  69747. * @param name defines control name
  69748. */
  69749. constructor(name?: string | undefined);
  69750. protected _getTypeName(): string;
  69751. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  69752. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69753. _flagDescendantsAsMatrixDirty(): void;
  69754. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69755. /** Releases associated resources */
  69756. dispose(): void;
  69757. }
  69758. }
  69759. declare module BABYLON.GUI {
  69760. /** Class used to create color pickers */
  69761. export class ColorPicker extends Control {
  69762. name?: string | undefined;
  69763. private static _Epsilon;
  69764. private _colorWheelCanvas;
  69765. private _value;
  69766. private _tmpColor;
  69767. private _pointerStartedOnSquare;
  69768. private _pointerStartedOnWheel;
  69769. private _squareLeft;
  69770. private _squareTop;
  69771. private _squareSize;
  69772. private _h;
  69773. private _s;
  69774. private _v;
  69775. private _lastPointerDownID;
  69776. /**
  69777. * BABYLON.Observable raised when the value changes
  69778. */
  69779. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  69780. /** Gets or sets the color of the color picker */
  69781. get value(): BABYLON.Color3;
  69782. set value(value: BABYLON.Color3);
  69783. /**
  69784. * Gets or sets control width
  69785. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69786. */
  69787. get width(): string | number;
  69788. set width(value: string | number);
  69789. /**
  69790. * Gets or sets control height
  69791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69792. */
  69793. get height(): string | number;
  69794. /** Gets or sets control height */
  69795. set height(value: string | number);
  69796. /** Gets or sets control size */
  69797. get size(): string | number;
  69798. set size(value: string | number);
  69799. /**
  69800. * Creates a new ColorPicker
  69801. * @param name defines the control name
  69802. */
  69803. constructor(name?: string | undefined);
  69804. protected _getTypeName(): string;
  69805. /** @hidden */
  69806. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69807. private _updateSquareProps;
  69808. private _drawGradientSquare;
  69809. private _drawCircle;
  69810. private _createColorWheelCanvas;
  69811. /** @hidden */
  69812. _draw(context: CanvasRenderingContext2D): void;
  69813. private _pointerIsDown;
  69814. private _updateValueFromPointer;
  69815. private _isPointOnSquare;
  69816. private _isPointOnWheel;
  69817. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69818. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69819. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69820. /**
  69821. * This function expands the color picker by creating a color picker dialog with manual
  69822. * color value input and the ability to save colors into an array to be used later in
  69823. * subsequent launches of the dialogue.
  69824. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69825. * @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.
  69826. * @returns picked color as a hex string and the saved colors array as hex strings.
  69827. */
  69828. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69829. pickerWidth?: string;
  69830. pickerHeight?: string;
  69831. headerHeight?: string;
  69832. lastColor?: string;
  69833. swatchLimit?: number;
  69834. numSwatchesPerLine?: number;
  69835. savedColors?: Array<string>;
  69836. }): Promise<{
  69837. savedColors?: string[];
  69838. pickedColor: string;
  69839. }>;
  69840. }
  69841. }
  69842. declare module BABYLON.GUI {
  69843. /** Class used to create 2D ellipse containers */
  69844. export class Ellipse extends Container {
  69845. name?: string | undefined;
  69846. private _thickness;
  69847. /** Gets or sets border thickness */
  69848. get thickness(): number;
  69849. set thickness(value: number);
  69850. /**
  69851. * Creates a new Ellipse
  69852. * @param name defines the control name
  69853. */
  69854. constructor(name?: string | undefined);
  69855. protected _getTypeName(): string;
  69856. protected _localDraw(context: CanvasRenderingContext2D): void;
  69857. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69858. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69859. }
  69860. }
  69861. declare module BABYLON.GUI {
  69862. /**
  69863. * Class used to create a password control
  69864. */
  69865. export class InputPassword extends InputText {
  69866. protected _beforeRenderText(text: string): string;
  69867. }
  69868. }
  69869. declare module BABYLON.GUI {
  69870. /** Class used to render 2D lines */
  69871. export class Line extends Control {
  69872. name?: string | undefined;
  69873. private _lineWidth;
  69874. private _x1;
  69875. private _y1;
  69876. private _x2;
  69877. private _y2;
  69878. private _dash;
  69879. private _connectedControl;
  69880. private _connectedControlDirtyObserver;
  69881. /** Gets or sets the dash pattern */
  69882. get dash(): Array<number>;
  69883. set dash(value: Array<number>);
  69884. /** Gets or sets the control connected with the line end */
  69885. get connectedControl(): Control;
  69886. set connectedControl(value: Control);
  69887. /** Gets or sets start coordinates on X axis */
  69888. get x1(): string | number;
  69889. set x1(value: string | number);
  69890. /** Gets or sets start coordinates on Y axis */
  69891. get y1(): string | number;
  69892. set y1(value: string | number);
  69893. /** Gets or sets end coordinates on X axis */
  69894. get x2(): string | number;
  69895. set x2(value: string | number);
  69896. /** Gets or sets end coordinates on Y axis */
  69897. get y2(): string | number;
  69898. set y2(value: string | number);
  69899. /** Gets or sets line width */
  69900. get lineWidth(): number;
  69901. set lineWidth(value: number);
  69902. /** Gets or sets horizontal alignment */
  69903. set horizontalAlignment(value: number);
  69904. /** Gets or sets vertical alignment */
  69905. set verticalAlignment(value: number);
  69906. private get _effectiveX2();
  69907. private get _effectiveY2();
  69908. /**
  69909. * Creates a new Line
  69910. * @param name defines the control name
  69911. */
  69912. constructor(name?: string | undefined);
  69913. protected _getTypeName(): string;
  69914. _draw(context: CanvasRenderingContext2D): void;
  69915. _measure(): void;
  69916. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69917. /**
  69918. * Move one end of the line given 3D cartesian coordinates.
  69919. * @param position Targeted world position
  69920. * @param scene BABYLON.Scene
  69921. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69922. */
  69923. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69924. /**
  69925. * Move one end of the line to a position in screen absolute space.
  69926. * @param projectedPosition Position in screen absolute space (X, Y)
  69927. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69928. */
  69929. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69930. }
  69931. }
  69932. declare module BABYLON.GUI {
  69933. /**
  69934. * Class used to store a point for a MultiLine object.
  69935. * The point can be pure 2D coordinates, a mesh or a control
  69936. */
  69937. export class MultiLinePoint {
  69938. private _multiLine;
  69939. private _x;
  69940. private _y;
  69941. private _control;
  69942. private _mesh;
  69943. private _controlObserver;
  69944. private _meshObserver;
  69945. /** @hidden */
  69946. _point: BABYLON.Vector2;
  69947. /**
  69948. * Creates a new MultiLinePoint
  69949. * @param multiLine defines the source MultiLine object
  69950. */
  69951. constructor(multiLine: MultiLine);
  69952. /** Gets or sets x coordinate */
  69953. get x(): string | number;
  69954. set x(value: string | number);
  69955. /** Gets or sets y coordinate */
  69956. get y(): string | number;
  69957. set y(value: string | number);
  69958. /** Gets or sets the control associated with this point */
  69959. get control(): BABYLON.Nullable<Control>;
  69960. set control(value: BABYLON.Nullable<Control>);
  69961. /** Gets or sets the mesh associated with this point */
  69962. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69963. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  69964. /** Resets links */
  69965. resetLinks(): void;
  69966. /**
  69967. * Gets a translation vector
  69968. * @returns the translation vector
  69969. */
  69970. translate(): BABYLON.Vector2;
  69971. private _translatePoint;
  69972. /** Release associated resources */
  69973. dispose(): void;
  69974. }
  69975. }
  69976. declare module BABYLON.GUI {
  69977. /**
  69978. * Class used to create multi line control
  69979. */
  69980. export class MultiLine extends Control {
  69981. name?: string | undefined;
  69982. private _lineWidth;
  69983. private _dash;
  69984. private _points;
  69985. private _minX;
  69986. private _minY;
  69987. private _maxX;
  69988. private _maxY;
  69989. /**
  69990. * Creates a new MultiLine
  69991. * @param name defines the control name
  69992. */
  69993. constructor(name?: string | undefined);
  69994. /** Gets or sets dash pattern */
  69995. get dash(): Array<number>;
  69996. set dash(value: Array<number>);
  69997. /**
  69998. * Gets point stored at specified index
  69999. * @param index defines the index to look for
  70000. * @returns the requested point if found
  70001. */
  70002. getAt(index: number): MultiLinePoint;
  70003. /** Function called when a point is updated */
  70004. onPointUpdate: () => void;
  70005. /**
  70006. * Adds new points to the point collection
  70007. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  70008. * @returns the list of created MultiLinePoint
  70009. */
  70010. add(...items: (AbstractMesh | Control | {
  70011. x: string | number;
  70012. y: string | number;
  70013. })[]): MultiLinePoint[];
  70014. /**
  70015. * Adds a new point to the point collection
  70016. * @param item defines the item (mesh, control or 2d coordiantes) to add
  70017. * @returns the created MultiLinePoint
  70018. */
  70019. push(item?: (AbstractMesh | Control | {
  70020. x: string | number;
  70021. y: string | number;
  70022. })): MultiLinePoint;
  70023. /**
  70024. * Remove a specific value or point from the active point collection
  70025. * @param value defines the value or point to remove
  70026. */
  70027. remove(value: number | MultiLinePoint): void;
  70028. /**
  70029. * Resets this object to initial state (no point)
  70030. */
  70031. reset(): void;
  70032. /**
  70033. * Resets all links
  70034. */
  70035. resetLinks(): void;
  70036. /** Gets or sets line width */
  70037. get lineWidth(): number;
  70038. set lineWidth(value: number);
  70039. set horizontalAlignment(value: number);
  70040. set verticalAlignment(value: number);
  70041. protected _getTypeName(): string;
  70042. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70043. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70044. _measure(): void;
  70045. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70046. dispose(): void;
  70047. }
  70048. }
  70049. declare module BABYLON.GUI {
  70050. /**
  70051. * Class used to create radio button controls
  70052. */
  70053. export class RadioButton extends Control {
  70054. name?: string | undefined;
  70055. private _isChecked;
  70056. private _background;
  70057. private _checkSizeRatio;
  70058. private _thickness;
  70059. /** Gets or sets border thickness */
  70060. get thickness(): number;
  70061. set thickness(value: number);
  70062. /** Gets or sets group name */
  70063. group: string;
  70064. /** BABYLON.Observable raised when isChecked is changed */
  70065. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  70066. /** Gets or sets a value indicating the ratio between overall size and check size */
  70067. get checkSizeRatio(): number;
  70068. set checkSizeRatio(value: number);
  70069. /** Gets or sets background color */
  70070. get background(): string;
  70071. set background(value: string);
  70072. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  70073. get isChecked(): boolean;
  70074. set isChecked(value: boolean);
  70075. /**
  70076. * Creates a new RadioButton
  70077. * @param name defines the control name
  70078. */
  70079. constructor(name?: string | undefined);
  70080. protected _getTypeName(): string;
  70081. _draw(context: CanvasRenderingContext2D): void;
  70082. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70083. /**
  70084. * Utility function to easily create a radio button with a header
  70085. * @param title defines the label to use for the header
  70086. * @param group defines the group to use for the radio button
  70087. * @param isChecked defines the initial state of the radio button
  70088. * @param onValueChanged defines the callback to call when value changes
  70089. * @returns a StackPanel containing the radio button and a textBlock
  70090. */
  70091. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  70092. }
  70093. }
  70094. declare module BABYLON.GUI {
  70095. /**
  70096. * Class used to create slider controls
  70097. */
  70098. export class BaseSlider extends Control {
  70099. name?: string | undefined;
  70100. protected _thumbWidth: ValueAndUnit;
  70101. private _minimum;
  70102. private _maximum;
  70103. private _value;
  70104. private _isVertical;
  70105. protected _barOffset: ValueAndUnit;
  70106. private _isThumbClamped;
  70107. protected _displayThumb: boolean;
  70108. private _step;
  70109. private _lastPointerDownID;
  70110. protected _effectiveBarOffset: number;
  70111. protected _renderLeft: number;
  70112. protected _renderTop: number;
  70113. protected _renderWidth: number;
  70114. protected _renderHeight: number;
  70115. protected _backgroundBoxLength: number;
  70116. protected _backgroundBoxThickness: number;
  70117. protected _effectiveThumbThickness: number;
  70118. /** BABYLON.Observable raised when the sldier value changes */
  70119. onValueChangedObservable: BABYLON.Observable<number>;
  70120. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70121. get displayThumb(): boolean;
  70122. set displayThumb(value: boolean);
  70123. /** Gets or sets a step to apply to values (0 by default) */
  70124. get step(): number;
  70125. set step(value: number);
  70126. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70127. get barOffset(): string | number;
  70128. /** Gets main bar offset in pixels*/
  70129. get barOffsetInPixels(): number;
  70130. set barOffset(value: string | number);
  70131. /** Gets or sets thumb width */
  70132. get thumbWidth(): string | number;
  70133. /** Gets thumb width in pixels */
  70134. get thumbWidthInPixels(): number;
  70135. set thumbWidth(value: string | number);
  70136. /** Gets or sets minimum value */
  70137. get minimum(): number;
  70138. set minimum(value: number);
  70139. /** Gets or sets maximum value */
  70140. get maximum(): number;
  70141. set maximum(value: number);
  70142. /** Gets or sets current value */
  70143. get value(): number;
  70144. set value(value: number);
  70145. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70146. get isVertical(): boolean;
  70147. set isVertical(value: boolean);
  70148. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70149. get isThumbClamped(): boolean;
  70150. set isThumbClamped(value: boolean);
  70151. /**
  70152. * Creates a new BaseSlider
  70153. * @param name defines the control name
  70154. */
  70155. constructor(name?: string | undefined);
  70156. protected _getTypeName(): string;
  70157. protected _getThumbPosition(): number;
  70158. protected _getThumbThickness(type: string): number;
  70159. protected _prepareRenderingData(type: string): void;
  70160. private _pointerIsDown;
  70161. /** @hidden */
  70162. protected _updateValueFromPointer(x: number, y: number): void;
  70163. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70164. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70165. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70166. }
  70167. }
  70168. declare module BABYLON.GUI {
  70169. /**
  70170. * Class used to create slider controls
  70171. */
  70172. export class Slider extends BaseSlider {
  70173. name?: string | undefined;
  70174. private _background;
  70175. private _borderColor;
  70176. private _isThumbCircle;
  70177. protected _displayValueBar: boolean;
  70178. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70179. get displayValueBar(): boolean;
  70180. set displayValueBar(value: boolean);
  70181. /** Gets or sets border color */
  70182. get borderColor(): string;
  70183. set borderColor(value: string);
  70184. /** Gets or sets background color */
  70185. get background(): string;
  70186. set background(value: string);
  70187. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70188. get isThumbCircle(): boolean;
  70189. set isThumbCircle(value: boolean);
  70190. /**
  70191. * Creates a new Slider
  70192. * @param name defines the control name
  70193. */
  70194. constructor(name?: string | undefined);
  70195. protected _getTypeName(): string;
  70196. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70197. }
  70198. }
  70199. declare module BABYLON.GUI {
  70200. /** Class used to create a RadioGroup
  70201. * which contains groups of radio buttons
  70202. */
  70203. export class SelectorGroup {
  70204. /** name of SelectorGroup */
  70205. name: string;
  70206. private _groupPanel;
  70207. private _selectors;
  70208. private _groupHeader;
  70209. /**
  70210. * Creates a new SelectorGroup
  70211. * @param name of group, used as a group heading
  70212. */
  70213. constructor(
  70214. /** name of SelectorGroup */
  70215. name: string);
  70216. /** Gets the groupPanel of the SelectorGroup */
  70217. get groupPanel(): StackPanel;
  70218. /** Gets the selectors array */
  70219. get selectors(): StackPanel[];
  70220. /** Gets and sets the group header */
  70221. get header(): string;
  70222. set header(label: string);
  70223. /** @hidden */
  70224. private _addGroupHeader;
  70225. /** @hidden*/
  70226. _getSelector(selectorNb: number): StackPanel | undefined;
  70227. /** Removes the selector at the given position
  70228. * @param selectorNb the position of the selector within the group
  70229. */
  70230. removeSelector(selectorNb: number): void;
  70231. }
  70232. /** Class used to create a CheckboxGroup
  70233. * which contains groups of checkbox buttons
  70234. */
  70235. export class CheckboxGroup extends SelectorGroup {
  70236. /** Adds a checkbox as a control
  70237. * @param text is the label for the selector
  70238. * @param func is the function called when the Selector is checked
  70239. * @param checked is true when Selector is checked
  70240. */
  70241. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70242. /** @hidden */
  70243. _setSelectorLabel(selectorNb: number, label: string): void;
  70244. /** @hidden */
  70245. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70246. /** @hidden */
  70247. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70248. /** @hidden */
  70249. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70250. }
  70251. /** Class used to create a RadioGroup
  70252. * which contains groups of radio buttons
  70253. */
  70254. export class RadioGroup extends SelectorGroup {
  70255. private _selectNb;
  70256. /** Adds a radio button as a control
  70257. * @param label is the label for the selector
  70258. * @param func is the function called when the Selector is checked
  70259. * @param checked is true when Selector is checked
  70260. */
  70261. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70262. /** @hidden */
  70263. _setSelectorLabel(selectorNb: number, label: string): void;
  70264. /** @hidden */
  70265. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70266. /** @hidden */
  70267. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70268. /** @hidden */
  70269. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70270. }
  70271. /** Class used to create a SliderGroup
  70272. * which contains groups of slider buttons
  70273. */
  70274. export class SliderGroup extends SelectorGroup {
  70275. /**
  70276. * Adds a slider to the SelectorGroup
  70277. * @param label is the label for the SliderBar
  70278. * @param func is the function called when the Slider moves
  70279. * @param unit is a string describing the units used, eg degrees or metres
  70280. * @param min is the minimum value for the Slider
  70281. * @param max is the maximum value for the Slider
  70282. * @param value is the start value for the Slider between min and max
  70283. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70284. */
  70285. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70286. /** @hidden */
  70287. _setSelectorLabel(selectorNb: number, label: string): void;
  70288. /** @hidden */
  70289. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70290. /** @hidden */
  70291. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70292. /** @hidden */
  70293. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70294. }
  70295. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70296. * @see http://doc.babylonjs.com/how_to/selector
  70297. */
  70298. export class SelectionPanel extends Rectangle {
  70299. /** name of SelectionPanel */
  70300. name: string;
  70301. /** an array of SelectionGroups */
  70302. groups: SelectorGroup[];
  70303. private _panel;
  70304. private _buttonColor;
  70305. private _buttonBackground;
  70306. private _headerColor;
  70307. private _barColor;
  70308. private _barHeight;
  70309. private _spacerHeight;
  70310. private _labelColor;
  70311. private _groups;
  70312. private _bars;
  70313. /**
  70314. * Creates a new SelectionPanel
  70315. * @param name of SelectionPanel
  70316. * @param groups is an array of SelectionGroups
  70317. */
  70318. constructor(
  70319. /** name of SelectionPanel */
  70320. name: string,
  70321. /** an array of SelectionGroups */
  70322. groups?: SelectorGroup[]);
  70323. protected _getTypeName(): string;
  70324. /** Gets or sets the headerColor */
  70325. get headerColor(): string;
  70326. set headerColor(color: string);
  70327. private _setHeaderColor;
  70328. /** Gets or sets the button color */
  70329. get buttonColor(): string;
  70330. set buttonColor(color: string);
  70331. private _setbuttonColor;
  70332. /** Gets or sets the label color */
  70333. get labelColor(): string;
  70334. set labelColor(color: string);
  70335. private _setLabelColor;
  70336. /** Gets or sets the button background */
  70337. get buttonBackground(): string;
  70338. set buttonBackground(color: string);
  70339. private _setButtonBackground;
  70340. /** Gets or sets the color of separator bar */
  70341. get barColor(): string;
  70342. set barColor(color: string);
  70343. private _setBarColor;
  70344. /** Gets or sets the height of separator bar */
  70345. get barHeight(): string;
  70346. set barHeight(value: string);
  70347. private _setBarHeight;
  70348. /** Gets or sets the height of spacers*/
  70349. get spacerHeight(): string;
  70350. set spacerHeight(value: string);
  70351. private _setSpacerHeight;
  70352. /** Adds a bar between groups */
  70353. private _addSpacer;
  70354. /** Add a group to the selection panel
  70355. * @param group is the selector group to add
  70356. */
  70357. addGroup(group: SelectorGroup): void;
  70358. /** Remove the group from the given position
  70359. * @param groupNb is the position of the group in the list
  70360. */
  70361. removeGroup(groupNb: number): void;
  70362. /** Change a group header label
  70363. * @param label is the new group header label
  70364. * @param groupNb is the number of the group to relabel
  70365. * */
  70366. setHeaderName(label: string, groupNb: number): void;
  70367. /** Change selector label to the one given
  70368. * @param label is the new selector label
  70369. * @param groupNb is the number of the groupcontaining the selector
  70370. * @param selectorNb is the number of the selector within a group to relabel
  70371. * */
  70372. relabel(label: string, groupNb: number, selectorNb: number): void;
  70373. /** For a given group position remove the selector at the given position
  70374. * @param groupNb is the number of the group to remove the selector from
  70375. * @param selectorNb is the number of the selector within the group
  70376. */
  70377. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  70378. /** For a given group position of correct type add a checkbox button
  70379. * @param groupNb is the number of the group to remove the selector from
  70380. * @param label is the label for the selector
  70381. * @param func is the function called when the Selector is checked
  70382. * @param checked is true when Selector is checked
  70383. */
  70384. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70385. /** For a given group position of correct type add a radio button
  70386. * @param groupNb is the number of the group to remove the selector from
  70387. * @param label is the label for the selector
  70388. * @param func is the function called when the Selector is checked
  70389. * @param checked is true when Selector is checked
  70390. */
  70391. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70392. /**
  70393. * For a given slider group add a slider
  70394. * @param groupNb is the number of the group to add the slider to
  70395. * @param label is the label for the Slider
  70396. * @param func is the function called when the Slider moves
  70397. * @param unit is a string describing the units used, eg degrees or metres
  70398. * @param min is the minimum value for the Slider
  70399. * @param max is the maximum value for the Slider
  70400. * @param value is the start value for the Slider between min and max
  70401. * @param onVal is the function used to format the value displayed, eg radians to degrees
  70402. */
  70403. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  70404. }
  70405. }
  70406. declare module BABYLON.GUI {
  70407. /**
  70408. * Class used to hold a the container for ScrollViewer
  70409. * @hidden
  70410. */
  70411. export class _ScrollViewerWindow extends Container {
  70412. parentClientWidth: number;
  70413. parentClientHeight: number;
  70414. /**
  70415. * Creates a new ScrollViewerWindow
  70416. * @param name of ScrollViewerWindow
  70417. */
  70418. constructor(name?: string);
  70419. protected _getTypeName(): string;
  70420. /** @hidden */
  70421. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70422. protected _postMeasure(): void;
  70423. }
  70424. }
  70425. declare module BABYLON.GUI {
  70426. /**
  70427. * Class used to create slider controls
  70428. */
  70429. export class ScrollBar extends BaseSlider {
  70430. name?: string | undefined;
  70431. private _background;
  70432. private _borderColor;
  70433. private _tempMeasure;
  70434. /** Gets or sets border color */
  70435. get borderColor(): string;
  70436. set borderColor(value: string);
  70437. /** Gets or sets background color */
  70438. get background(): string;
  70439. set background(value: string);
  70440. /**
  70441. * Creates a new Slider
  70442. * @param name defines the control name
  70443. */
  70444. constructor(name?: string | undefined);
  70445. protected _getTypeName(): string;
  70446. protected _getThumbThickness(): number;
  70447. _draw(context: CanvasRenderingContext2D): void;
  70448. private _first;
  70449. private _originX;
  70450. private _originY;
  70451. /** @hidden */
  70452. protected _updateValueFromPointer(x: number, y: number): void;
  70453. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70454. }
  70455. }
  70456. declare module BABYLON.GUI {
  70457. /**
  70458. * Class used to create slider controls
  70459. */
  70460. export class ImageScrollBar extends BaseSlider {
  70461. name?: string | undefined;
  70462. private _backgroundBaseImage;
  70463. private _backgroundImage;
  70464. private _thumbImage;
  70465. private _thumbBaseImage;
  70466. private _thumbLength;
  70467. private _thumbHeight;
  70468. private _barImageHeight;
  70469. private _tempMeasure;
  70470. /**
  70471. * Gets or sets the image used to render the background for horizontal bar
  70472. */
  70473. get backgroundImage(): Image;
  70474. set backgroundImage(value: Image);
  70475. /**
  70476. * Gets or sets the image used to render the thumb
  70477. */
  70478. get thumbImage(): Image;
  70479. set thumbImage(value: Image);
  70480. /**
  70481. * Gets or sets the length of the thumb
  70482. */
  70483. get thumbLength(): number;
  70484. set thumbLength(value: number);
  70485. /**
  70486. * Gets or sets the height of the thumb
  70487. */
  70488. get thumbHeight(): number;
  70489. set thumbHeight(value: number);
  70490. /**
  70491. * Gets or sets the height of the bar image
  70492. */
  70493. get barImageHeight(): number;
  70494. set barImageHeight(value: number);
  70495. /**
  70496. * Creates a new ImageScrollBar
  70497. * @param name defines the control name
  70498. */
  70499. constructor(name?: string | undefined);
  70500. protected _getTypeName(): string;
  70501. protected _getThumbThickness(): number;
  70502. _draw(context: CanvasRenderingContext2D): void;
  70503. private _first;
  70504. private _originX;
  70505. private _originY;
  70506. /** @hidden */
  70507. protected _updateValueFromPointer(x: number, y: number): void;
  70508. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70509. }
  70510. }
  70511. declare module BABYLON.GUI {
  70512. /**
  70513. * Class used to hold a viewer window and sliders in a grid
  70514. */
  70515. export class ScrollViewer extends Rectangle {
  70516. private _grid;
  70517. private _horizontalBarSpace;
  70518. private _verticalBarSpace;
  70519. private _dragSpace;
  70520. private _horizontalBar;
  70521. private _verticalBar;
  70522. private _barColor;
  70523. private _barBackground;
  70524. private _barImage;
  70525. private _barBackgroundImage;
  70526. private _barSize;
  70527. private _endLeft;
  70528. private _endTop;
  70529. private _window;
  70530. private _pointerIsOver;
  70531. private _wheelPrecision;
  70532. private _onPointerObserver;
  70533. private _clientWidth;
  70534. private _clientHeight;
  70535. private _useImageBar;
  70536. private _thumbLength;
  70537. private _thumbHeight;
  70538. private _barImageHeight;
  70539. /**
  70540. * Gets the horizontal scrollbar
  70541. */
  70542. get horizontalBar(): ScrollBar | ImageScrollBar;
  70543. /**
  70544. * Gets the vertical scrollbar
  70545. */
  70546. get verticalBar(): ScrollBar | ImageScrollBar;
  70547. /**
  70548. * Adds a new control to the current container
  70549. * @param control defines the control to add
  70550. * @returns the current container
  70551. */
  70552. addControl(control: BABYLON.Nullable<Control>): Container;
  70553. /**
  70554. * Removes a control from the current container
  70555. * @param control defines the control to remove
  70556. * @returns the current container
  70557. */
  70558. removeControl(control: Control): Container;
  70559. /** Gets the list of children */
  70560. get children(): Control[];
  70561. _flagDescendantsAsMatrixDirty(): void;
  70562. /**
  70563. * Creates a new ScrollViewer
  70564. * @param name of ScrollViewer
  70565. */
  70566. constructor(name?: string, isImageBased?: boolean);
  70567. /** Reset the scroll viewer window to initial size */
  70568. resetWindow(): void;
  70569. protected _getTypeName(): string;
  70570. private _buildClientSizes;
  70571. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70572. protected _postMeasure(): void;
  70573. /**
  70574. * Gets or sets the mouse wheel precision
  70575. * from 0 to 1 with a default value of 0.05
  70576. * */
  70577. get wheelPrecision(): number;
  70578. set wheelPrecision(value: number);
  70579. /** Gets or sets the scroll bar container background color */
  70580. get scrollBackground(): string;
  70581. set scrollBackground(color: string);
  70582. /** Gets or sets the bar color */
  70583. get barColor(): string;
  70584. set barColor(color: string);
  70585. /** Gets or sets the bar image */
  70586. get thumbImage(): Image;
  70587. set thumbImage(value: Image);
  70588. /** Gets or sets the size of the bar */
  70589. get barSize(): number;
  70590. set barSize(value: number);
  70591. /** Gets or sets the length of the thumb */
  70592. get thumbLength(): number;
  70593. set thumbLength(value: number);
  70594. /** Gets or sets the height of the thumb */
  70595. get thumbHeight(): number;
  70596. set thumbHeight(value: number);
  70597. /** Gets or sets the height of the bar image */
  70598. get barImageHeight(): number;
  70599. set barImageHeight(value: number);
  70600. /** Gets or sets the bar background */
  70601. get barBackground(): string;
  70602. set barBackground(color: string);
  70603. /** Gets or sets the bar background image */
  70604. get barImage(): Image;
  70605. set barImage(value: Image);
  70606. /** @hidden */
  70607. private _updateScroller;
  70608. _link(host: AdvancedDynamicTexture): void;
  70609. /** @hidden */
  70610. private _addBar;
  70611. /** @hidden */
  70612. private _attachWheel;
  70613. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70614. /** Releases associated resources */
  70615. dispose(): void;
  70616. }
  70617. }
  70618. declare module BABYLON.GUI {
  70619. /** Class used to render a grid */
  70620. export class DisplayGrid extends Control {
  70621. name?: string | undefined;
  70622. private _cellWidth;
  70623. private _cellHeight;
  70624. private _minorLineTickness;
  70625. private _minorLineColor;
  70626. private _majorLineTickness;
  70627. private _majorLineColor;
  70628. private _majorLineFrequency;
  70629. private _background;
  70630. private _displayMajorLines;
  70631. private _displayMinorLines;
  70632. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  70633. get displayMinorLines(): boolean;
  70634. set displayMinorLines(value: boolean);
  70635. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  70636. get displayMajorLines(): boolean;
  70637. set displayMajorLines(value: boolean);
  70638. /** Gets or sets background color (Black by default) */
  70639. get background(): string;
  70640. set background(value: string);
  70641. /** Gets or sets the width of each cell (20 by default) */
  70642. get cellWidth(): number;
  70643. set cellWidth(value: number);
  70644. /** Gets or sets the height of each cell (20 by default) */
  70645. get cellHeight(): number;
  70646. set cellHeight(value: number);
  70647. /** Gets or sets the tickness of minor lines (1 by default) */
  70648. get minorLineTickness(): number;
  70649. set minorLineTickness(value: number);
  70650. /** Gets or sets the color of minor lines (DarkGray by default) */
  70651. get minorLineColor(): string;
  70652. set minorLineColor(value: string);
  70653. /** Gets or sets the tickness of major lines (2 by default) */
  70654. get majorLineTickness(): number;
  70655. set majorLineTickness(value: number);
  70656. /** Gets or sets the color of major lines (White by default) */
  70657. get majorLineColor(): string;
  70658. set majorLineColor(value: string);
  70659. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  70660. get majorLineFrequency(): number;
  70661. set majorLineFrequency(value: number);
  70662. /**
  70663. * Creates a new GridDisplayRectangle
  70664. * @param name defines the control name
  70665. */
  70666. constructor(name?: string | undefined);
  70667. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70668. protected _getTypeName(): string;
  70669. }
  70670. }
  70671. declare module BABYLON.GUI {
  70672. /**
  70673. * Class used to create slider controls based on images
  70674. */
  70675. export class ImageBasedSlider extends BaseSlider {
  70676. name?: string | undefined;
  70677. private _backgroundImage;
  70678. private _thumbImage;
  70679. private _valueBarImage;
  70680. private _tempMeasure;
  70681. get displayThumb(): boolean;
  70682. set displayThumb(value: boolean);
  70683. /**
  70684. * Gets or sets the image used to render the background
  70685. */
  70686. get backgroundImage(): Image;
  70687. set backgroundImage(value: Image);
  70688. /**
  70689. * Gets or sets the image used to render the value bar
  70690. */
  70691. get valueBarImage(): Image;
  70692. set valueBarImage(value: Image);
  70693. /**
  70694. * Gets or sets the image used to render the thumb
  70695. */
  70696. get thumbImage(): Image;
  70697. set thumbImage(value: Image);
  70698. /**
  70699. * Creates a new ImageBasedSlider
  70700. * @param name defines the control name
  70701. */
  70702. constructor(name?: string | undefined);
  70703. protected _getTypeName(): string;
  70704. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70705. }
  70706. }
  70707. declare module BABYLON.GUI {
  70708. /**
  70709. * Forcing an export so that this code will execute
  70710. * @hidden
  70711. */
  70712. const name = "Statics";
  70713. }
  70714. declare module BABYLON.GUI {
  70715. /**
  70716. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  70717. */
  70718. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  70719. /**
  70720. * Define the instrumented AdvancedDynamicTexture.
  70721. */
  70722. texture: AdvancedDynamicTexture;
  70723. private _captureRenderTime;
  70724. private _renderTime;
  70725. private _captureLayoutTime;
  70726. private _layoutTime;
  70727. private _onBeginRenderObserver;
  70728. private _onEndRenderObserver;
  70729. private _onBeginLayoutObserver;
  70730. private _onEndLayoutObserver;
  70731. /**
  70732. * Gets the perf counter used to capture render time
  70733. */
  70734. get renderTimeCounter(): BABYLON.PerfCounter;
  70735. /**
  70736. * Gets the perf counter used to capture layout time
  70737. */
  70738. get layoutTimeCounter(): BABYLON.PerfCounter;
  70739. /**
  70740. * Enable or disable the render time capture
  70741. */
  70742. get captureRenderTime(): boolean;
  70743. set captureRenderTime(value: boolean);
  70744. /**
  70745. * Enable or disable the layout time capture
  70746. */
  70747. get captureLayoutTime(): boolean;
  70748. set captureLayoutTime(value: boolean);
  70749. /**
  70750. * Instantiates a new advanced dynamic texture instrumentation.
  70751. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  70752. * @param texture Defines the AdvancedDynamicTexture to instrument
  70753. */
  70754. constructor(
  70755. /**
  70756. * Define the instrumented AdvancedDynamicTexture.
  70757. */
  70758. texture: AdvancedDynamicTexture);
  70759. /**
  70760. * Dispose and release associated resources.
  70761. */
  70762. dispose(): void;
  70763. }
  70764. }
  70765. declare module BABYLON.GUI {
  70766. /**
  70767. * Class used to load GUI via XML.
  70768. */
  70769. export class XmlLoader {
  70770. private _nodes;
  70771. private _nodeTypes;
  70772. private _isLoaded;
  70773. private _objectAttributes;
  70774. private _parentClass;
  70775. /**
  70776. * Create a new xml loader
  70777. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  70778. */
  70779. constructor(parentClass?: null);
  70780. private _getChainElement;
  70781. private _getClassAttribute;
  70782. private _createGuiElement;
  70783. private _parseGrid;
  70784. private _parseElement;
  70785. private _prepareSourceElement;
  70786. private _parseElementsFromSource;
  70787. private _parseXml;
  70788. /**
  70789. * Gets if the loading has finished.
  70790. * @returns whether the loading has finished or not
  70791. */
  70792. isLoaded(): boolean;
  70793. /**
  70794. * Gets a loaded node / control by id.
  70795. * @param id the Controls id set in the xml
  70796. * @returns element of type Control
  70797. */
  70798. getNodeById(id: string): any;
  70799. /**
  70800. * Gets all loaded nodes / controls
  70801. * @returns Array of controls
  70802. */
  70803. getNodes(): any;
  70804. /**
  70805. * Initiates the xml layout loading
  70806. * @param xmlFile defines the xml layout to load
  70807. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  70808. * @param callback defines the callback called on layout load.
  70809. */
  70810. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  70811. }
  70812. }
  70813. declare module BABYLON.GUI {
  70814. /**
  70815. * Class used to create containers for controls
  70816. */
  70817. export class Container3D extends Control3D {
  70818. private _blockLayout;
  70819. /**
  70820. * Gets the list of child controls
  70821. */
  70822. protected _children: Control3D[];
  70823. /**
  70824. * Gets the list of child controls
  70825. */
  70826. get children(): Array<Control3D>;
  70827. /**
  70828. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  70829. * This is helpful to optimize layout operation when adding multiple children in a row
  70830. */
  70831. get blockLayout(): boolean;
  70832. set blockLayout(value: boolean);
  70833. /**
  70834. * Creates a new container
  70835. * @param name defines the container name
  70836. */
  70837. constructor(name?: string);
  70838. /**
  70839. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  70840. * @returns the current container
  70841. */
  70842. updateLayout(): Container3D;
  70843. /**
  70844. * Gets a boolean indicating if the given control is in the children of this control
  70845. * @param control defines the control to check
  70846. * @returns true if the control is in the child list
  70847. */
  70848. containsControl(control: Control3D): boolean;
  70849. /**
  70850. * Adds a control to the children of this control
  70851. * @param control defines the control to add
  70852. * @returns the current container
  70853. */
  70854. addControl(control: Control3D): Container3D;
  70855. /**
  70856. * This function will be called everytime a new control is added
  70857. */
  70858. protected _arrangeChildren(): void;
  70859. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70860. /**
  70861. * Removes a control from the children of this control
  70862. * @param control defines the control to remove
  70863. * @returns the current container
  70864. */
  70865. removeControl(control: Control3D): Container3D;
  70866. protected _getTypeName(): string;
  70867. /**
  70868. * Releases all associated resources
  70869. */
  70870. dispose(): void;
  70871. /** Control rotation will remain unchanged */
  70872. static readonly UNSET_ORIENTATION: number;
  70873. /** Control will rotate to make it look at sphere central axis */
  70874. static readonly FACEORIGIN_ORIENTATION: number;
  70875. /** Control will rotate to make it look back at sphere central axis */
  70876. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  70877. /** Control will rotate to look at z axis (0, 0, 1) */
  70878. static readonly FACEFORWARD_ORIENTATION: number;
  70879. /** Control will rotate to look at negative z axis (0, 0, -1) */
  70880. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  70881. }
  70882. }
  70883. declare module BABYLON.GUI {
  70884. /**
  70885. * Class used to manage 3D user interface
  70886. * @see http://doc.babylonjs.com/how_to/gui3d
  70887. */
  70888. export class GUI3DManager implements BABYLON.IDisposable {
  70889. private _scene;
  70890. private _sceneDisposeObserver;
  70891. private _utilityLayer;
  70892. private _rootContainer;
  70893. private _pointerObserver;
  70894. private _pointerOutObserver;
  70895. /** @hidden */
  70896. _lastPickedControl: Control3D;
  70897. /** @hidden */
  70898. _lastControlOver: {
  70899. [pointerId: number]: Control3D;
  70900. };
  70901. /** @hidden */
  70902. _lastControlDown: {
  70903. [pointerId: number]: Control3D;
  70904. };
  70905. /**
  70906. * BABYLON.Observable raised when the point picked by the pointer events changed
  70907. */
  70908. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70909. /** @hidden */
  70910. _sharedMaterials: {
  70911. [key: string]: BABYLON.Material;
  70912. };
  70913. /** Gets the hosting scene */
  70914. get scene(): BABYLON.Scene;
  70915. /** Gets associated utility layer */
  70916. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70917. /**
  70918. * Creates a new GUI3DManager
  70919. * @param scene
  70920. */
  70921. constructor(scene?: BABYLON.Scene);
  70922. private _handlePointerOut;
  70923. private _doPicking;
  70924. /**
  70925. * Gets the root container
  70926. */
  70927. get rootContainer(): Container3D;
  70928. /**
  70929. * Gets a boolean indicating if the given control is in the root child list
  70930. * @param control defines the control to check
  70931. * @returns true if the control is in the root child list
  70932. */
  70933. containsControl(control: Control3D): boolean;
  70934. /**
  70935. * Adds a control to the root child list
  70936. * @param control defines the control to add
  70937. * @returns the current manager
  70938. */
  70939. addControl(control: Control3D): GUI3DManager;
  70940. /**
  70941. * Removes a control from the root child list
  70942. * @param control defines the control to remove
  70943. * @returns the current container
  70944. */
  70945. removeControl(control: Control3D): GUI3DManager;
  70946. /**
  70947. * Releases all associated resources
  70948. */
  70949. dispose(): void;
  70950. }
  70951. }
  70952. declare module BABYLON.GUI {
  70953. /**
  70954. * Class used to transport BABYLON.Vector3 information for pointer events
  70955. */
  70956. export class Vector3WithInfo extends BABYLON.Vector3 {
  70957. /** defines the current mouse button index */
  70958. buttonIndex: number;
  70959. /**
  70960. * Creates a new Vector3WithInfo
  70961. * @param source defines the vector3 data to transport
  70962. * @param buttonIndex defines the current mouse button index
  70963. */
  70964. constructor(source: BABYLON.Vector3,
  70965. /** defines the current mouse button index */
  70966. buttonIndex?: number);
  70967. }
  70968. }
  70969. declare module BABYLON.GUI {
  70970. /**
  70971. * Class used as base class for controls
  70972. */
  70973. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70974. /** Defines the control name */
  70975. name?: string | undefined;
  70976. /** @hidden */
  70977. _host: GUI3DManager;
  70978. private _node;
  70979. private _downCount;
  70980. private _enterCount;
  70981. private _downPointerIds;
  70982. private _isVisible;
  70983. /** Gets or sets the control position in world space */
  70984. get position(): BABYLON.Vector3;
  70985. set position(value: BABYLON.Vector3);
  70986. /** Gets or sets the control scaling in world space */
  70987. get scaling(): BABYLON.Vector3;
  70988. set scaling(value: BABYLON.Vector3);
  70989. /** Callback used to start pointer enter animation */
  70990. pointerEnterAnimation: () => void;
  70991. /** Callback used to start pointer out animation */
  70992. pointerOutAnimation: () => void;
  70993. /** Callback used to start pointer down animation */
  70994. pointerDownAnimation: () => void;
  70995. /** Callback used to start pointer up animation */
  70996. pointerUpAnimation: () => void;
  70997. /**
  70998. * An event triggered when the pointer move over the control
  70999. */
  71000. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  71001. /**
  71002. * An event triggered when the pointer move out of the control
  71003. */
  71004. onPointerOutObservable: BABYLON.Observable<Control3D>;
  71005. /**
  71006. * An event triggered when the pointer taps the control
  71007. */
  71008. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  71009. /**
  71010. * An event triggered when pointer is up
  71011. */
  71012. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  71013. /**
  71014. * An event triggered when a control is clicked on (with a mouse)
  71015. */
  71016. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  71017. /**
  71018. * An event triggered when pointer enters the control
  71019. */
  71020. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  71021. /**
  71022. * Gets or sets the parent container
  71023. */
  71024. parent: BABYLON.Nullable<Container3D>;
  71025. private _behaviors;
  71026. /**
  71027. * Gets the list of attached behaviors
  71028. * @see http://doc.babylonjs.com/features/behaviour
  71029. */
  71030. get behaviors(): BABYLON.Behavior<Control3D>[];
  71031. /**
  71032. * Attach a behavior to the control
  71033. * @see http://doc.babylonjs.com/features/behaviour
  71034. * @param behavior defines the behavior to attach
  71035. * @returns the current control
  71036. */
  71037. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71038. /**
  71039. * Remove an attached behavior
  71040. * @see http://doc.babylonjs.com/features/behaviour
  71041. * @param behavior defines the behavior to attach
  71042. * @returns the current control
  71043. */
  71044. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71045. /**
  71046. * Gets an attached behavior by name
  71047. * @param name defines the name of the behavior to look for
  71048. * @see http://doc.babylonjs.com/features/behaviour
  71049. * @returns null if behavior was not found else the requested behavior
  71050. */
  71051. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  71052. /** Gets or sets a boolean indicating if the control is visible */
  71053. get isVisible(): boolean;
  71054. set isVisible(value: boolean);
  71055. /**
  71056. * Creates a new control
  71057. * @param name defines the control name
  71058. */
  71059. constructor(
  71060. /** Defines the control name */
  71061. name?: string | undefined);
  71062. /**
  71063. * Gets a string representing the class name
  71064. */
  71065. get typeName(): string;
  71066. /**
  71067. * Get the current class name of the control.
  71068. * @returns current class name
  71069. */
  71070. getClassName(): string;
  71071. protected _getTypeName(): string;
  71072. /**
  71073. * Gets the transform node used by this control
  71074. */
  71075. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  71076. /**
  71077. * Gets the mesh used to render this control
  71078. */
  71079. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71080. /**
  71081. * Link the control as child of the given node
  71082. * @param node defines the node to link to. Use null to unlink the control
  71083. * @returns the current control
  71084. */
  71085. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  71086. /** @hidden **/
  71087. _prepareNode(scene: BABYLON.Scene): void;
  71088. /**
  71089. * Node creation.
  71090. * Can be overriden by children
  71091. * @param scene defines the scene where the node must be attached
  71092. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  71093. */
  71094. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71095. /**
  71096. * Affect a material to the given mesh
  71097. * @param mesh defines the mesh which will represent the control
  71098. */
  71099. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71100. /** @hidden */
  71101. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71102. /** @hidden */
  71103. _onPointerEnter(target: Control3D): boolean;
  71104. /** @hidden */
  71105. _onPointerOut(target: Control3D): void;
  71106. /** @hidden */
  71107. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71108. /** @hidden */
  71109. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71110. /** @hidden */
  71111. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71112. /** @hidden */
  71113. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71114. /** @hidden */
  71115. _disposeNode(): void;
  71116. /**
  71117. * Releases all associated resources
  71118. */
  71119. dispose(): void;
  71120. }
  71121. }
  71122. declare module BABYLON.GUI {
  71123. /**
  71124. * Class used as a root to all buttons
  71125. */
  71126. export class AbstractButton3D extends Control3D {
  71127. /**
  71128. * Creates a new button
  71129. * @param name defines the control name
  71130. */
  71131. constructor(name?: string);
  71132. protected _getTypeName(): string;
  71133. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71134. }
  71135. }
  71136. declare module BABYLON.GUI {
  71137. /**
  71138. * Class used to create a button in 3D
  71139. */
  71140. export class Button3D extends AbstractButton3D {
  71141. /** @hidden */
  71142. protected _currentMaterial: BABYLON.Material;
  71143. private _facadeTexture;
  71144. private _content;
  71145. private _contentResolution;
  71146. private _contentScaleRatio;
  71147. /**
  71148. * Gets or sets the texture resolution used to render content (512 by default)
  71149. */
  71150. get contentResolution(): BABYLON.int;
  71151. set contentResolution(value: BABYLON.int);
  71152. /**
  71153. * Gets or sets the texture scale ratio used to render content (2 by default)
  71154. */
  71155. get contentScaleRatio(): number;
  71156. set contentScaleRatio(value: number);
  71157. protected _disposeFacadeTexture(): void;
  71158. protected _resetContent(): void;
  71159. /**
  71160. * Creates a new button
  71161. * @param name defines the control name
  71162. */
  71163. constructor(name?: string);
  71164. /**
  71165. * Gets or sets the GUI 2D content used to display the button's facade
  71166. */
  71167. get content(): Control;
  71168. set content(value: Control);
  71169. /**
  71170. * Apply the facade texture (created from the content property).
  71171. * This function can be overloaded by child classes
  71172. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71173. */
  71174. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71175. protected _getTypeName(): string;
  71176. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71177. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71178. /**
  71179. * Releases all associated resources
  71180. */
  71181. dispose(): void;
  71182. }
  71183. }
  71184. declare module BABYLON.GUI {
  71185. /**
  71186. * Abstract class used to create a container panel deployed on the surface of a volume
  71187. */
  71188. export abstract class VolumeBasedPanel extends Container3D {
  71189. private _columns;
  71190. private _rows;
  71191. private _rowThenColum;
  71192. private _orientation;
  71193. protected _cellWidth: number;
  71194. protected _cellHeight: number;
  71195. /**
  71196. * Gets or sets the distance between elements
  71197. */
  71198. margin: number;
  71199. /**
  71200. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71201. * | Value | Type | Description |
  71202. * | ----- | ----------------------------------- | ----------- |
  71203. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71204. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71205. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71206. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71207. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71208. */
  71209. get orientation(): number;
  71210. set orientation(value: number);
  71211. /**
  71212. * Gets or sets the number of columns requested (10 by default).
  71213. * The panel will automatically compute the number of rows based on number of child controls.
  71214. */
  71215. get columns(): BABYLON.int;
  71216. set columns(value: BABYLON.int);
  71217. /**
  71218. * Gets or sets a the number of rows requested.
  71219. * The panel will automatically compute the number of columns based on number of child controls.
  71220. */
  71221. get rows(): BABYLON.int;
  71222. set rows(value: BABYLON.int);
  71223. /**
  71224. * Creates new VolumeBasedPanel
  71225. */
  71226. constructor();
  71227. protected _arrangeChildren(): void;
  71228. /** Child classes must implement this function to provide correct control positioning */
  71229. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71230. /** Child classes can implement this function to provide additional processing */
  71231. protected _finalProcessing(): void;
  71232. }
  71233. }
  71234. declare module BABYLON.GUI {
  71235. /**
  71236. * Class used to create a container panel deployed on the surface of a cylinder
  71237. */
  71238. export class CylinderPanel extends VolumeBasedPanel {
  71239. private _radius;
  71240. /**
  71241. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71242. */
  71243. get radius(): BABYLON.float;
  71244. set radius(value: BABYLON.float);
  71245. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71246. private _cylindricalMapping;
  71247. }
  71248. }
  71249. declare module BABYLON.GUI {
  71250. /** @hidden */
  71251. export var fluentVertexShader: {
  71252. name: string;
  71253. shader: string;
  71254. };
  71255. }
  71256. declare module BABYLON.GUI {
  71257. /** @hidden */
  71258. export var fluentPixelShader: {
  71259. name: string;
  71260. shader: string;
  71261. };
  71262. }
  71263. declare module BABYLON.GUI {
  71264. /** @hidden */
  71265. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71266. INNERGLOW: boolean;
  71267. BORDER: boolean;
  71268. HOVERLIGHT: boolean;
  71269. TEXTURE: boolean;
  71270. constructor();
  71271. }
  71272. /**
  71273. * Class used to render controls with fluent desgin
  71274. */
  71275. export class FluentMaterial extends BABYLON.PushMaterial {
  71276. /**
  71277. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71278. */
  71279. innerGlowColorIntensity: number;
  71280. /**
  71281. * Gets or sets the inner glow color (white by default)
  71282. */
  71283. innerGlowColor: BABYLON.Color3;
  71284. /**
  71285. * Gets or sets alpha value (default is 1.0)
  71286. */
  71287. alpha: number;
  71288. /**
  71289. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71290. */
  71291. albedoColor: BABYLON.Color3;
  71292. /**
  71293. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71294. */
  71295. renderBorders: boolean;
  71296. /**
  71297. * Gets or sets border width (default is 0.5)
  71298. */
  71299. borderWidth: number;
  71300. /**
  71301. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71302. */
  71303. edgeSmoothingValue: number;
  71304. /**
  71305. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71306. */
  71307. borderMinValue: number;
  71308. /**
  71309. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71310. */
  71311. renderHoverLight: boolean;
  71312. /**
  71313. * Gets or sets the radius used to render the hover light (default is 1.0)
  71314. */
  71315. hoverRadius: number;
  71316. /**
  71317. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71318. */
  71319. hoverColor: BABYLON.Color4;
  71320. /**
  71321. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71322. */
  71323. hoverPosition: BABYLON.Vector3;
  71324. private _albedoTexture;
  71325. /** Gets or sets the texture to use for albedo color */
  71326. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71327. /**
  71328. * Creates a new Fluent material
  71329. * @param name defines the name of the material
  71330. * @param scene defines the hosting scene
  71331. */
  71332. constructor(name: string, scene: BABYLON.Scene);
  71333. needAlphaBlending(): boolean;
  71334. needAlphaTesting(): boolean;
  71335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71336. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71337. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71338. getActiveTextures(): BABYLON.BaseTexture[];
  71339. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71340. dispose(forceDisposeEffect?: boolean): void;
  71341. clone(name: string): FluentMaterial;
  71342. serialize(): any;
  71343. getClassName(): string;
  71344. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  71345. }
  71346. }
  71347. declare module BABYLON.GUI {
  71348. /**
  71349. * Class used to create a holographic button in 3D
  71350. */
  71351. export class HolographicButton extends Button3D {
  71352. private _backPlate;
  71353. private _textPlate;
  71354. private _frontPlate;
  71355. private _text;
  71356. private _imageUrl;
  71357. private _shareMaterials;
  71358. private _frontMaterial;
  71359. private _backMaterial;
  71360. private _plateMaterial;
  71361. private _pickedPointObserver;
  71362. private _tooltipFade;
  71363. private _tooltipTextBlock;
  71364. private _tooltipTexture;
  71365. private _tooltipMesh;
  71366. private _tooltipHoverObserver;
  71367. private _tooltipOutObserver;
  71368. private _disposeTooltip;
  71369. /**
  71370. * Rendering ground id of all the mesh in the button
  71371. */
  71372. set renderingGroupId(id: number);
  71373. get renderingGroupId(): number;
  71374. /**
  71375. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  71376. */
  71377. set tooltipText(text: BABYLON.Nullable<string>);
  71378. get tooltipText(): BABYLON.Nullable<string>;
  71379. /**
  71380. * Gets or sets text for the button
  71381. */
  71382. get text(): string;
  71383. set text(value: string);
  71384. /**
  71385. * Gets or sets the image url for the button
  71386. */
  71387. get imageUrl(): string;
  71388. set imageUrl(value: string);
  71389. /**
  71390. * Gets the back material used by this button
  71391. */
  71392. get backMaterial(): FluentMaterial;
  71393. /**
  71394. * Gets the front material used by this button
  71395. */
  71396. get frontMaterial(): FluentMaterial;
  71397. /**
  71398. * Gets the plate material used by this button
  71399. */
  71400. get plateMaterial(): BABYLON.StandardMaterial;
  71401. /**
  71402. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  71403. */
  71404. get shareMaterials(): boolean;
  71405. /**
  71406. * Creates a new button
  71407. * @param name defines the control name
  71408. */
  71409. constructor(name?: string, shareMaterials?: boolean);
  71410. protected _getTypeName(): string;
  71411. private _rebuildContent;
  71412. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71413. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71414. private _createBackMaterial;
  71415. private _createFrontMaterial;
  71416. private _createPlateMaterial;
  71417. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  71418. /**
  71419. * Releases all associated resources
  71420. */
  71421. dispose(): void;
  71422. }
  71423. }
  71424. declare module BABYLON.GUI {
  71425. /**
  71426. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  71427. */
  71428. export class MeshButton3D extends Button3D {
  71429. /** @hidden */
  71430. protected _currentMesh: BABYLON.Mesh;
  71431. /**
  71432. * Creates a new 3D button based on a mesh
  71433. * @param mesh mesh to become a 3D button
  71434. * @param name defines the control name
  71435. */
  71436. constructor(mesh: BABYLON.Mesh, name?: string);
  71437. protected _getTypeName(): string;
  71438. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71439. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71440. }
  71441. }
  71442. declare module BABYLON.GUI {
  71443. /**
  71444. * Class used to create a container panel deployed on the surface of a plane
  71445. */
  71446. export class PlanePanel extends VolumeBasedPanel {
  71447. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71448. }
  71449. }
  71450. declare module BABYLON.GUI {
  71451. /**
  71452. * Class used to create a container panel where items get randomized planar mapping
  71453. */
  71454. export class ScatterPanel extends VolumeBasedPanel {
  71455. private _iteration;
  71456. /**
  71457. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  71458. */
  71459. get iteration(): BABYLON.float;
  71460. set iteration(value: BABYLON.float);
  71461. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71462. private _scatterMapping;
  71463. protected _finalProcessing(): void;
  71464. }
  71465. }
  71466. declare module BABYLON.GUI {
  71467. /**
  71468. * Class used to create a container panel deployed on the surface of a sphere
  71469. */
  71470. export class SpherePanel extends VolumeBasedPanel {
  71471. private _radius;
  71472. /**
  71473. * Gets or sets the radius of the sphere where to project controls (5 by default)
  71474. */
  71475. get radius(): BABYLON.float;
  71476. set radius(value: BABYLON.float);
  71477. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71478. private _sphericalMapping;
  71479. }
  71480. }
  71481. declare module BABYLON.GUI {
  71482. /**
  71483. * Class used to create a stack panel in 3D on XY plane
  71484. */
  71485. export class StackPanel3D extends Container3D {
  71486. private _isVertical;
  71487. /**
  71488. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  71489. */
  71490. get isVertical(): boolean;
  71491. set isVertical(value: boolean);
  71492. /**
  71493. * Gets or sets the distance between elements
  71494. */
  71495. margin: number;
  71496. /**
  71497. * Creates new StackPanel
  71498. * @param isVertical
  71499. */
  71500. constructor(isVertical?: boolean);
  71501. protected _arrangeChildren(): void;
  71502. }
  71503. }
  71504. declare module BABYLON {
  71505. /**
  71506. * Configuration for glTF validation
  71507. */
  71508. export interface IGLTFValidationConfiguration {
  71509. /**
  71510. * The url of the glTF validator.
  71511. */
  71512. url: string;
  71513. }
  71514. /**
  71515. * glTF validation
  71516. */
  71517. export class GLTFValidation {
  71518. /**
  71519. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  71520. */
  71521. static Configuration: IGLTFValidationConfiguration;
  71522. private static _LoadScriptPromise;
  71523. /**
  71524. * Validate a glTF asset using the glTF-Validator.
  71525. * @param data The JSON of a glTF or the array buffer of a binary glTF
  71526. * @param rootUrl The root url for the glTF
  71527. * @param fileName The file name for the glTF
  71528. * @param getExternalResource The callback to get external resources for the glTF validator
  71529. * @returns A promise that resolves with the glTF validation results once complete
  71530. */
  71531. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  71532. }
  71533. }
  71534. declare module BABYLON {
  71535. /**
  71536. * Mode that determines the coordinate system to use.
  71537. */
  71538. export enum GLTFLoaderCoordinateSystemMode {
  71539. /**
  71540. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  71541. */
  71542. AUTO = 0,
  71543. /**
  71544. * Sets the useRightHandedSystem flag on the scene.
  71545. */
  71546. FORCE_RIGHT_HANDED = 1
  71547. }
  71548. /**
  71549. * Mode that determines what animations will start.
  71550. */
  71551. export enum GLTFLoaderAnimationStartMode {
  71552. /**
  71553. * No animation will start.
  71554. */
  71555. NONE = 0,
  71556. /**
  71557. * The first animation will start.
  71558. */
  71559. FIRST = 1,
  71560. /**
  71561. * All animations will start.
  71562. */
  71563. ALL = 2
  71564. }
  71565. /**
  71566. * Interface that contains the data for the glTF asset.
  71567. */
  71568. export interface IGLTFLoaderData {
  71569. /**
  71570. * The object that represents the glTF JSON.
  71571. */
  71572. json: Object;
  71573. /**
  71574. * The BIN chunk of a binary glTF.
  71575. */
  71576. bin: Nullable<IDataBuffer>;
  71577. }
  71578. /**
  71579. * Interface for extending the loader.
  71580. */
  71581. export interface IGLTFLoaderExtension {
  71582. /**
  71583. * The name of this extension.
  71584. */
  71585. readonly name: string;
  71586. /**
  71587. * Defines whether this extension is enabled.
  71588. */
  71589. enabled: boolean;
  71590. /**
  71591. * Defines the order of this extension.
  71592. * The loader sorts the extensions using these values when loading.
  71593. */
  71594. order?: number;
  71595. }
  71596. /**
  71597. * Loader state.
  71598. */
  71599. export enum GLTFLoaderState {
  71600. /**
  71601. * The asset is loading.
  71602. */
  71603. LOADING = 0,
  71604. /**
  71605. * The asset is ready for rendering.
  71606. */
  71607. READY = 1,
  71608. /**
  71609. * The asset is completely loaded.
  71610. */
  71611. COMPLETE = 2
  71612. }
  71613. /** @hidden */
  71614. export interface IGLTFLoader extends IDisposable {
  71615. readonly state: Nullable<GLTFLoaderState>;
  71616. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  71617. meshes: AbstractMesh[];
  71618. particleSystems: IParticleSystem[];
  71619. skeletons: Skeleton[];
  71620. animationGroups: AnimationGroup[];
  71621. }>;
  71622. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  71623. }
  71624. /**
  71625. * File loader for loading glTF files into a scene.
  71626. */
  71627. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71628. /** @hidden */
  71629. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71630. /** @hidden */
  71631. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71632. /**
  71633. * Raised when the asset has been parsed
  71634. */
  71635. onParsedObservable: Observable<IGLTFLoaderData>;
  71636. private _onParsedObserver;
  71637. /**
  71638. * Raised when the asset has been parsed
  71639. */
  71640. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  71641. /**
  71642. * 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.
  71643. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  71644. * Defaults to true.
  71645. * @hidden
  71646. */
  71647. static IncrementalLoading: boolean;
  71648. /**
  71649. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  71650. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  71651. * @hidden
  71652. */
  71653. static HomogeneousCoordinates: boolean;
  71654. /**
  71655. * The coordinate system mode. Defaults to AUTO.
  71656. */
  71657. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  71658. /**
  71659. * The animation start mode. Defaults to FIRST.
  71660. */
  71661. animationStartMode: GLTFLoaderAnimationStartMode;
  71662. /**
  71663. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  71664. */
  71665. compileMaterials: boolean;
  71666. /**
  71667. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  71668. */
  71669. useClipPlane: boolean;
  71670. /**
  71671. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  71672. */
  71673. compileShadowGenerators: boolean;
  71674. /**
  71675. * Defines if the Alpha blended materials are only applied as coverage.
  71676. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  71677. * If true, no extra effects are applied to transparent pixels.
  71678. */
  71679. transparencyAsCoverage: boolean;
  71680. /**
  71681. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  71682. * Enabling will disable offline support and glTF validator.
  71683. * Defaults to false.
  71684. */
  71685. useRangeRequests: boolean;
  71686. /**
  71687. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  71688. */
  71689. createInstances: boolean;
  71690. /**
  71691. * Function called before loading a url referenced by the asset.
  71692. */
  71693. preprocessUrlAsync: (url: string) => Promise<string>;
  71694. /**
  71695. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71696. */
  71697. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  71698. private _onMeshLoadedObserver;
  71699. /**
  71700. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71701. */
  71702. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  71703. /**
  71704. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  71705. */
  71706. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  71707. private _onTextureLoadedObserver;
  71708. /**
  71709. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  71710. */
  71711. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  71712. /**
  71713. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  71714. */
  71715. readonly onMaterialLoadedObservable: Observable<Material>;
  71716. private _onMaterialLoadedObserver;
  71717. /**
  71718. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  71719. */
  71720. set onMaterialLoaded(callback: (material: Material) => void);
  71721. /**
  71722. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  71723. */
  71724. readonly onCameraLoadedObservable: Observable<Camera>;
  71725. private _onCameraLoadedObserver;
  71726. /**
  71727. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  71728. */
  71729. set onCameraLoaded(callback: (camera: Camera) => void);
  71730. /**
  71731. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  71732. * For assets with LODs, raised when all of the LODs are complete.
  71733. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71734. */
  71735. readonly onCompleteObservable: Observable<void>;
  71736. private _onCompleteObserver;
  71737. /**
  71738. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  71739. * For assets with LODs, raised when all of the LODs are complete.
  71740. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71741. */
  71742. set onComplete(callback: () => void);
  71743. /**
  71744. * Observable raised when an error occurs.
  71745. */
  71746. readonly onErrorObservable: Observable<any>;
  71747. private _onErrorObserver;
  71748. /**
  71749. * Callback raised when an error occurs.
  71750. */
  71751. set onError(callback: (reason: any) => void);
  71752. /**
  71753. * Observable raised after the loader is disposed.
  71754. */
  71755. readonly onDisposeObservable: Observable<void>;
  71756. private _onDisposeObserver;
  71757. /**
  71758. * Callback raised after the loader is disposed.
  71759. */
  71760. set onDispose(callback: () => void);
  71761. /**
  71762. * Observable raised after a loader extension is created.
  71763. * Set additional options for a loader extension in this event.
  71764. */
  71765. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  71766. private _onExtensionLoadedObserver;
  71767. /**
  71768. * Callback raised after a loader extension is created.
  71769. */
  71770. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  71771. /**
  71772. * Defines if the loader logging is enabled.
  71773. */
  71774. get loggingEnabled(): boolean;
  71775. set loggingEnabled(value: boolean);
  71776. /**
  71777. * Defines if the loader should capture performance counters.
  71778. */
  71779. get capturePerformanceCounters(): boolean;
  71780. set capturePerformanceCounters(value: boolean);
  71781. /**
  71782. * Defines if the loader should validate the asset.
  71783. */
  71784. validate: boolean;
  71785. /**
  71786. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  71787. */
  71788. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  71789. private _onValidatedObserver;
  71790. /**
  71791. * Callback raised after a loader extension is created.
  71792. */
  71793. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  71794. private _loader;
  71795. /**
  71796. * Name of the loader ("gltf")
  71797. */
  71798. name: string;
  71799. /** @hidden */
  71800. extensions: ISceneLoaderPluginExtensions;
  71801. /**
  71802. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  71803. */
  71804. dispose(): void;
  71805. /** @hidden */
  71806. _clear(): void;
  71807. /** @hidden */
  71808. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71809. /** @hidden */
  71810. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71811. /** @hidden */
  71812. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71813. meshes: AbstractMesh[];
  71814. particleSystems: IParticleSystem[];
  71815. skeletons: Skeleton[];
  71816. animationGroups: AnimationGroup[];
  71817. }>;
  71818. /** @hidden */
  71819. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71820. /** @hidden */
  71821. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71822. /** @hidden */
  71823. canDirectLoad(data: string): boolean;
  71824. /** @hidden */
  71825. directLoad(scene: Scene, data: string): any;
  71826. /**
  71827. * The callback that allows custom handling of the root url based on the response url.
  71828. * @param rootUrl the original root url
  71829. * @param responseURL the response url if available
  71830. * @returns the new root url
  71831. */
  71832. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  71833. /** @hidden */
  71834. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  71835. /**
  71836. * The loader state or null if the loader is not active.
  71837. */
  71838. get loaderState(): Nullable<GLTFLoaderState>;
  71839. /**
  71840. * Returns a promise that resolves when the asset is completely loaded.
  71841. * @returns a promise that resolves when the asset is completely loaded.
  71842. */
  71843. whenCompleteAsync(): Promise<void>;
  71844. private _validate;
  71845. private _getLoader;
  71846. private _parseJson;
  71847. private _unpackBinaryAsync;
  71848. private _unpackBinaryV1Async;
  71849. private _unpackBinaryV2Async;
  71850. private static _parseVersion;
  71851. private static _compareVersion;
  71852. private static readonly _logSpaces;
  71853. private _logIndentLevel;
  71854. private _loggingEnabled;
  71855. /** @hidden */
  71856. _log: (message: string) => void;
  71857. /** @hidden */
  71858. _logOpen(message: string): void;
  71859. /** @hidden */
  71860. _logClose(): void;
  71861. private _logEnabled;
  71862. private _logDisabled;
  71863. private _capturePerformanceCounters;
  71864. /** @hidden */
  71865. _startPerformanceCounter: (counterName: string) => void;
  71866. /** @hidden */
  71867. _endPerformanceCounter: (counterName: string) => void;
  71868. private _startPerformanceCounterEnabled;
  71869. private _startPerformanceCounterDisabled;
  71870. private _endPerformanceCounterEnabled;
  71871. private _endPerformanceCounterDisabled;
  71872. }
  71873. }
  71874. declare module BABYLON.GLTF1 {
  71875. /**
  71876. * Enums
  71877. * @hidden
  71878. */
  71879. export enum EComponentType {
  71880. BYTE = 5120,
  71881. UNSIGNED_BYTE = 5121,
  71882. SHORT = 5122,
  71883. UNSIGNED_SHORT = 5123,
  71884. FLOAT = 5126
  71885. }
  71886. /** @hidden */
  71887. export enum EShaderType {
  71888. FRAGMENT = 35632,
  71889. VERTEX = 35633
  71890. }
  71891. /** @hidden */
  71892. export enum EParameterType {
  71893. BYTE = 5120,
  71894. UNSIGNED_BYTE = 5121,
  71895. SHORT = 5122,
  71896. UNSIGNED_SHORT = 5123,
  71897. INT = 5124,
  71898. UNSIGNED_INT = 5125,
  71899. FLOAT = 5126,
  71900. FLOAT_VEC2 = 35664,
  71901. FLOAT_VEC3 = 35665,
  71902. FLOAT_VEC4 = 35666,
  71903. INT_VEC2 = 35667,
  71904. INT_VEC3 = 35668,
  71905. INT_VEC4 = 35669,
  71906. BOOL = 35670,
  71907. BOOL_VEC2 = 35671,
  71908. BOOL_VEC3 = 35672,
  71909. BOOL_VEC4 = 35673,
  71910. FLOAT_MAT2 = 35674,
  71911. FLOAT_MAT3 = 35675,
  71912. FLOAT_MAT4 = 35676,
  71913. SAMPLER_2D = 35678
  71914. }
  71915. /** @hidden */
  71916. export enum ETextureWrapMode {
  71917. CLAMP_TO_EDGE = 33071,
  71918. MIRRORED_REPEAT = 33648,
  71919. REPEAT = 10497
  71920. }
  71921. /** @hidden */
  71922. export enum ETextureFilterType {
  71923. NEAREST = 9728,
  71924. LINEAR = 9728,
  71925. NEAREST_MIPMAP_NEAREST = 9984,
  71926. LINEAR_MIPMAP_NEAREST = 9985,
  71927. NEAREST_MIPMAP_LINEAR = 9986,
  71928. LINEAR_MIPMAP_LINEAR = 9987
  71929. }
  71930. /** @hidden */
  71931. export enum ETextureFormat {
  71932. ALPHA = 6406,
  71933. RGB = 6407,
  71934. RGBA = 6408,
  71935. LUMINANCE = 6409,
  71936. LUMINANCE_ALPHA = 6410
  71937. }
  71938. /** @hidden */
  71939. export enum ECullingType {
  71940. FRONT = 1028,
  71941. BACK = 1029,
  71942. FRONT_AND_BACK = 1032
  71943. }
  71944. /** @hidden */
  71945. export enum EBlendingFunction {
  71946. ZERO = 0,
  71947. ONE = 1,
  71948. SRC_COLOR = 768,
  71949. ONE_MINUS_SRC_COLOR = 769,
  71950. DST_COLOR = 774,
  71951. ONE_MINUS_DST_COLOR = 775,
  71952. SRC_ALPHA = 770,
  71953. ONE_MINUS_SRC_ALPHA = 771,
  71954. DST_ALPHA = 772,
  71955. ONE_MINUS_DST_ALPHA = 773,
  71956. CONSTANT_COLOR = 32769,
  71957. ONE_MINUS_CONSTANT_COLOR = 32770,
  71958. CONSTANT_ALPHA = 32771,
  71959. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71960. SRC_ALPHA_SATURATE = 776
  71961. }
  71962. /** @hidden */
  71963. export interface IGLTFProperty {
  71964. extensions?: {
  71965. [key: string]: any;
  71966. };
  71967. extras?: Object;
  71968. }
  71969. /** @hidden */
  71970. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71971. name?: string;
  71972. }
  71973. /** @hidden */
  71974. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71975. bufferView: string;
  71976. byteOffset: number;
  71977. byteStride: number;
  71978. count: number;
  71979. type: string;
  71980. componentType: EComponentType;
  71981. max?: number[];
  71982. min?: number[];
  71983. name?: string;
  71984. }
  71985. /** @hidden */
  71986. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71987. buffer: string;
  71988. byteOffset: number;
  71989. byteLength: number;
  71990. byteStride: number;
  71991. target?: number;
  71992. }
  71993. /** @hidden */
  71994. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71995. uri: string;
  71996. byteLength?: number;
  71997. type?: string;
  71998. }
  71999. /** @hidden */
  72000. export interface IGLTFShader extends IGLTFChildRootProperty {
  72001. uri: string;
  72002. type: EShaderType;
  72003. }
  72004. /** @hidden */
  72005. export interface IGLTFProgram extends IGLTFChildRootProperty {
  72006. attributes: string[];
  72007. fragmentShader: string;
  72008. vertexShader: string;
  72009. }
  72010. /** @hidden */
  72011. export interface IGLTFTechniqueParameter {
  72012. type: number;
  72013. count?: number;
  72014. semantic?: string;
  72015. node?: string;
  72016. value?: number | boolean | string | Array<any>;
  72017. source?: string;
  72018. babylonValue?: any;
  72019. }
  72020. /** @hidden */
  72021. export interface IGLTFTechniqueCommonProfile {
  72022. lightingModel: string;
  72023. texcoordBindings: Object;
  72024. parameters?: Array<any>;
  72025. }
  72026. /** @hidden */
  72027. export interface IGLTFTechniqueStatesFunctions {
  72028. blendColor?: number[];
  72029. blendEquationSeparate?: number[];
  72030. blendFuncSeparate?: number[];
  72031. colorMask: boolean[];
  72032. cullFace: number[];
  72033. }
  72034. /** @hidden */
  72035. export interface IGLTFTechniqueStates {
  72036. enable: number[];
  72037. functions: IGLTFTechniqueStatesFunctions;
  72038. }
  72039. /** @hidden */
  72040. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  72041. parameters: {
  72042. [key: string]: IGLTFTechniqueParameter;
  72043. };
  72044. program: string;
  72045. attributes: {
  72046. [key: string]: string;
  72047. };
  72048. uniforms: {
  72049. [key: string]: string;
  72050. };
  72051. states: IGLTFTechniqueStates;
  72052. }
  72053. /** @hidden */
  72054. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  72055. technique?: string;
  72056. values: string[];
  72057. }
  72058. /** @hidden */
  72059. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  72060. attributes: {
  72061. [key: string]: string;
  72062. };
  72063. indices: string;
  72064. material: string;
  72065. mode?: number;
  72066. }
  72067. /** @hidden */
  72068. export interface IGLTFMesh extends IGLTFChildRootProperty {
  72069. primitives: IGLTFMeshPrimitive[];
  72070. }
  72071. /** @hidden */
  72072. export interface IGLTFImage extends IGLTFChildRootProperty {
  72073. uri: string;
  72074. }
  72075. /** @hidden */
  72076. export interface IGLTFSampler extends IGLTFChildRootProperty {
  72077. magFilter?: number;
  72078. minFilter?: number;
  72079. wrapS?: number;
  72080. wrapT?: number;
  72081. }
  72082. /** @hidden */
  72083. export interface IGLTFTexture extends IGLTFChildRootProperty {
  72084. sampler: string;
  72085. source: string;
  72086. format?: ETextureFormat;
  72087. internalFormat?: ETextureFormat;
  72088. target?: number;
  72089. type?: number;
  72090. babylonTexture?: Texture;
  72091. }
  72092. /** @hidden */
  72093. export interface IGLTFAmbienLight {
  72094. color?: number[];
  72095. }
  72096. /** @hidden */
  72097. export interface IGLTFDirectionalLight {
  72098. color?: number[];
  72099. }
  72100. /** @hidden */
  72101. export interface IGLTFPointLight {
  72102. color?: number[];
  72103. constantAttenuation?: number;
  72104. linearAttenuation?: number;
  72105. quadraticAttenuation?: number;
  72106. }
  72107. /** @hidden */
  72108. export interface IGLTFSpotLight {
  72109. color?: number[];
  72110. constantAttenuation?: number;
  72111. fallOfAngle?: number;
  72112. fallOffExponent?: number;
  72113. linearAttenuation?: number;
  72114. quadraticAttenuation?: number;
  72115. }
  72116. /** @hidden */
  72117. export interface IGLTFLight extends IGLTFChildRootProperty {
  72118. type: string;
  72119. }
  72120. /** @hidden */
  72121. export interface IGLTFCameraOrthographic {
  72122. xmag: number;
  72123. ymag: number;
  72124. zfar: number;
  72125. znear: number;
  72126. }
  72127. /** @hidden */
  72128. export interface IGLTFCameraPerspective {
  72129. aspectRatio: number;
  72130. yfov: number;
  72131. zfar: number;
  72132. znear: number;
  72133. }
  72134. /** @hidden */
  72135. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72136. type: string;
  72137. }
  72138. /** @hidden */
  72139. export interface IGLTFAnimationChannelTarget {
  72140. id: string;
  72141. path: string;
  72142. }
  72143. /** @hidden */
  72144. export interface IGLTFAnimationChannel {
  72145. sampler: string;
  72146. target: IGLTFAnimationChannelTarget;
  72147. }
  72148. /** @hidden */
  72149. export interface IGLTFAnimationSampler {
  72150. input: string;
  72151. output: string;
  72152. interpolation?: string;
  72153. }
  72154. /** @hidden */
  72155. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72156. channels?: IGLTFAnimationChannel[];
  72157. parameters?: {
  72158. [key: string]: string;
  72159. };
  72160. samplers?: {
  72161. [key: string]: IGLTFAnimationSampler;
  72162. };
  72163. }
  72164. /** @hidden */
  72165. export interface IGLTFNodeInstanceSkin {
  72166. skeletons: string[];
  72167. skin: string;
  72168. meshes: string[];
  72169. }
  72170. /** @hidden */
  72171. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72172. bindShapeMatrix: number[];
  72173. inverseBindMatrices: string;
  72174. jointNames: string[];
  72175. babylonSkeleton?: Skeleton;
  72176. }
  72177. /** @hidden */
  72178. export interface IGLTFNode extends IGLTFChildRootProperty {
  72179. camera?: string;
  72180. children: string[];
  72181. skin?: string;
  72182. jointName?: string;
  72183. light?: string;
  72184. matrix: number[];
  72185. mesh?: string;
  72186. meshes?: string[];
  72187. rotation?: number[];
  72188. scale?: number[];
  72189. translation?: number[];
  72190. babylonNode?: Node;
  72191. }
  72192. /** @hidden */
  72193. export interface IGLTFScene extends IGLTFChildRootProperty {
  72194. nodes: string[];
  72195. }
  72196. /** @hidden */
  72197. export interface IGLTFRuntime {
  72198. extensions: {
  72199. [key: string]: any;
  72200. };
  72201. accessors: {
  72202. [key: string]: IGLTFAccessor;
  72203. };
  72204. buffers: {
  72205. [key: string]: IGLTFBuffer;
  72206. };
  72207. bufferViews: {
  72208. [key: string]: IGLTFBufferView;
  72209. };
  72210. meshes: {
  72211. [key: string]: IGLTFMesh;
  72212. };
  72213. lights: {
  72214. [key: string]: IGLTFLight;
  72215. };
  72216. cameras: {
  72217. [key: string]: IGLTFCamera;
  72218. };
  72219. nodes: {
  72220. [key: string]: IGLTFNode;
  72221. };
  72222. images: {
  72223. [key: string]: IGLTFImage;
  72224. };
  72225. textures: {
  72226. [key: string]: IGLTFTexture;
  72227. };
  72228. shaders: {
  72229. [key: string]: IGLTFShader;
  72230. };
  72231. programs: {
  72232. [key: string]: IGLTFProgram;
  72233. };
  72234. samplers: {
  72235. [key: string]: IGLTFSampler;
  72236. };
  72237. techniques: {
  72238. [key: string]: IGLTFTechnique;
  72239. };
  72240. materials: {
  72241. [key: string]: IGLTFMaterial;
  72242. };
  72243. animations: {
  72244. [key: string]: IGLTFAnimation;
  72245. };
  72246. skins: {
  72247. [key: string]: IGLTFSkins;
  72248. };
  72249. currentScene?: Object;
  72250. scenes: {
  72251. [key: string]: IGLTFScene;
  72252. };
  72253. extensionsUsed: string[];
  72254. extensionsRequired?: string[];
  72255. buffersCount: number;
  72256. shaderscount: number;
  72257. scene: Scene;
  72258. rootUrl: string;
  72259. loadedBufferCount: number;
  72260. loadedBufferViews: {
  72261. [name: string]: ArrayBufferView;
  72262. };
  72263. loadedShaderCount: number;
  72264. importOnlyMeshes: boolean;
  72265. importMeshesNames?: string[];
  72266. dummyNodes: Node[];
  72267. }
  72268. /** @hidden */
  72269. export interface INodeToRoot {
  72270. bone: Bone;
  72271. node: IGLTFNode;
  72272. id: string;
  72273. }
  72274. /** @hidden */
  72275. export interface IJointNode {
  72276. node: IGLTFNode;
  72277. id: string;
  72278. }
  72279. }
  72280. declare module BABYLON.GLTF1 {
  72281. /**
  72282. * Utils functions for GLTF
  72283. * @hidden
  72284. */
  72285. export class GLTFUtils {
  72286. /**
  72287. * Sets the given "parameter" matrix
  72288. * @param scene: the Scene object
  72289. * @param source: the source node where to pick the matrix
  72290. * @param parameter: the GLTF technique parameter
  72291. * @param uniformName: the name of the shader's uniform
  72292. * @param shaderMaterial: the shader material
  72293. */
  72294. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72295. /**
  72296. * Sets the given "parameter" matrix
  72297. * @param shaderMaterial: the shader material
  72298. * @param uniform: the name of the shader's uniform
  72299. * @param value: the value of the uniform
  72300. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72301. */
  72302. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72303. /**
  72304. * Returns the wrap mode of the texture
  72305. * @param mode: the mode value
  72306. */
  72307. static GetWrapMode(mode: number): number;
  72308. /**
  72309. * Returns the byte stride giving an accessor
  72310. * @param accessor: the GLTF accessor objet
  72311. */
  72312. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72313. /**
  72314. * Returns the texture filter mode giving a mode value
  72315. * @param mode: the filter mode value
  72316. */
  72317. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72318. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72319. /**
  72320. * Returns a buffer from its accessor
  72321. * @param gltfRuntime: the GLTF runtime
  72322. * @param accessor: the GLTF accessor
  72323. */
  72324. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  72325. /**
  72326. * Decodes a buffer view into a string
  72327. * @param view: the buffer view
  72328. */
  72329. static DecodeBufferToText(view: ArrayBufferView): string;
  72330. /**
  72331. * Returns the default material of gltf. Related to
  72332. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  72333. * @param scene: the Babylon.js scene
  72334. */
  72335. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  72336. private static _DefaultMaterial;
  72337. }
  72338. }
  72339. declare module BABYLON.GLTF1 {
  72340. /**
  72341. * Implementation of the base glTF spec
  72342. * @hidden
  72343. */
  72344. export class GLTFLoaderBase {
  72345. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  72346. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72347. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  72348. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72349. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  72350. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72351. }
  72352. /**
  72353. * glTF V1 Loader
  72354. * @hidden
  72355. */
  72356. export class GLTFLoader implements IGLTFLoader {
  72357. static Extensions: {
  72358. [name: string]: GLTFLoaderExtension;
  72359. };
  72360. static RegisterExtension(extension: GLTFLoaderExtension): void;
  72361. state: Nullable<GLTFLoaderState>;
  72362. dispose(): void;
  72363. private _importMeshAsync;
  72364. /**
  72365. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  72366. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72367. * @param scene the scene the meshes should be added to
  72368. * @param data gltf data containing information of the meshes in a loaded file
  72369. * @param rootUrl root url to load from
  72370. * @param onProgress event that fires when loading progress has occured
  72371. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72372. */
  72373. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  72374. meshes: AbstractMesh[];
  72375. particleSystems: IParticleSystem[];
  72376. skeletons: Skeleton[];
  72377. animationGroups: AnimationGroup[];
  72378. }>;
  72379. private _loadAsync;
  72380. /**
  72381. * Imports all objects from a loaded gltf file and adds them to the scene
  72382. * @param scene the scene the objects should be added to
  72383. * @param data gltf data containing information of the meshes in a loaded file
  72384. * @param rootUrl root url to load from
  72385. * @param onProgress event that fires when loading progress has occured
  72386. * @returns a promise which completes when objects have been loaded to the scene
  72387. */
  72388. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  72389. private _loadShadersAsync;
  72390. private _loadBuffersAsync;
  72391. private _createNodes;
  72392. }
  72393. /** @hidden */
  72394. export abstract class GLTFLoaderExtension {
  72395. private _name;
  72396. constructor(name: string);
  72397. get name(): string;
  72398. /**
  72399. * Defines an override for loading the runtime
  72400. * Return true to stop further extensions from loading the runtime
  72401. */
  72402. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  72403. /**
  72404. * Defines an onverride for creating gltf runtime
  72405. * Return true to stop further extensions from creating the runtime
  72406. */
  72407. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  72408. /**
  72409. * Defines an override for loading buffers
  72410. * Return true to stop further extensions from loading this buffer
  72411. */
  72412. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  72413. /**
  72414. * Defines an override for loading texture buffers
  72415. * Return true to stop further extensions from loading this texture data
  72416. */
  72417. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72418. /**
  72419. * Defines an override for creating textures
  72420. * Return true to stop further extensions from loading this texture
  72421. */
  72422. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  72423. /**
  72424. * Defines an override for loading shader strings
  72425. * Return true to stop further extensions from loading this shader data
  72426. */
  72427. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72428. /**
  72429. * Defines an override for loading materials
  72430. * Return true to stop further extensions from loading this material
  72431. */
  72432. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72433. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  72434. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  72435. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72436. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72437. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  72438. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72439. private static LoadTextureBufferAsync;
  72440. private static CreateTextureAsync;
  72441. private static ApplyExtensions;
  72442. }
  72443. }
  72444. declare module BABYLON.GLTF1 {
  72445. /** @hidden */
  72446. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  72447. private _bin;
  72448. constructor();
  72449. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  72450. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72451. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72452. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72453. }
  72454. }
  72455. declare module BABYLON.GLTF1 {
  72456. /** @hidden */
  72457. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  72458. constructor();
  72459. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  72460. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72461. private _loadTexture;
  72462. }
  72463. }
  72464. declare module BABYLON.GLTF2.Loader {
  72465. /**
  72466. * Loader interface with an index field.
  72467. */
  72468. export interface IArrayItem {
  72469. /**
  72470. * The index of this item in the array.
  72471. */
  72472. index: number;
  72473. }
  72474. /**
  72475. * Loader interface with additional members.
  72476. */
  72477. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  72478. /** @hidden */
  72479. _data?: Promise<ArrayBufferView>;
  72480. /** @hidden */
  72481. _babylonVertexBuffer?: Promise<VertexBuffer>;
  72482. }
  72483. /**
  72484. * Loader interface with additional members.
  72485. */
  72486. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  72487. }
  72488. /** @hidden */
  72489. export interface _IAnimationSamplerData {
  72490. input: Float32Array;
  72491. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  72492. output: Float32Array;
  72493. }
  72494. /**
  72495. * Loader interface with additional members.
  72496. */
  72497. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  72498. /** @hidden */
  72499. _data?: Promise<_IAnimationSamplerData>;
  72500. }
  72501. /**
  72502. * Loader interface with additional members.
  72503. */
  72504. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  72505. channels: IAnimationChannel[];
  72506. samplers: IAnimationSampler[];
  72507. /** @hidden */
  72508. _babylonAnimationGroup?: AnimationGroup;
  72509. }
  72510. /**
  72511. * Loader interface with additional members.
  72512. */
  72513. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  72514. /** @hidden */
  72515. _data?: Promise<ArrayBufferView>;
  72516. }
  72517. /**
  72518. * Loader interface with additional members.
  72519. */
  72520. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  72521. /** @hidden */
  72522. _data?: Promise<ArrayBufferView>;
  72523. /** @hidden */
  72524. _babylonBuffer?: Promise<Buffer>;
  72525. }
  72526. /**
  72527. * Loader interface with additional members.
  72528. */
  72529. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  72530. }
  72531. /**
  72532. * Loader interface with additional members.
  72533. */
  72534. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  72535. /** @hidden */
  72536. _data?: Promise<ArrayBufferView>;
  72537. }
  72538. /**
  72539. * Loader interface with additional members.
  72540. */
  72541. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  72542. }
  72543. /**
  72544. * Loader interface with additional members.
  72545. */
  72546. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  72547. }
  72548. /**
  72549. * Loader interface with additional members.
  72550. */
  72551. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  72552. baseColorTexture?: ITextureInfo;
  72553. metallicRoughnessTexture?: ITextureInfo;
  72554. }
  72555. /**
  72556. * Loader interface with additional members.
  72557. */
  72558. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  72559. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72560. normalTexture?: IMaterialNormalTextureInfo;
  72561. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72562. emissiveTexture?: ITextureInfo;
  72563. /** @hidden */
  72564. _data?: {
  72565. [babylonDrawMode: number]: {
  72566. babylonMaterial: Material;
  72567. babylonMeshes: AbstractMesh[];
  72568. promise: Promise<void>;
  72569. };
  72570. };
  72571. }
  72572. /**
  72573. * Loader interface with additional members.
  72574. */
  72575. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  72576. primitives: IMeshPrimitive[];
  72577. }
  72578. /**
  72579. * Loader interface with additional members.
  72580. */
  72581. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  72582. /** @hidden */
  72583. _instanceData?: {
  72584. babylonSourceMesh: Mesh;
  72585. promise: Promise<any>;
  72586. };
  72587. }
  72588. /**
  72589. * Loader interface with additional members.
  72590. */
  72591. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  72592. /**
  72593. * The parent glTF node.
  72594. */
  72595. parent?: INode;
  72596. /** @hidden */
  72597. _babylonTransformNode?: TransformNode;
  72598. /** @hidden */
  72599. _primitiveBabylonMeshes?: AbstractMesh[];
  72600. /** @hidden */
  72601. _babylonBones?: Bone[];
  72602. /** @hidden */
  72603. _numMorphTargets?: number;
  72604. }
  72605. /** @hidden */
  72606. export interface _ISamplerData {
  72607. noMipMaps: boolean;
  72608. samplingMode: number;
  72609. wrapU: number;
  72610. wrapV: number;
  72611. }
  72612. /**
  72613. * Loader interface with additional members.
  72614. */
  72615. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  72616. /** @hidden */
  72617. _data?: _ISamplerData;
  72618. }
  72619. /**
  72620. * Loader interface with additional members.
  72621. */
  72622. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  72623. }
  72624. /**
  72625. * Loader interface with additional members.
  72626. */
  72627. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  72628. /** @hidden */
  72629. _data?: {
  72630. babylonSkeleton: Skeleton;
  72631. promise: Promise<void>;
  72632. };
  72633. }
  72634. /**
  72635. * Loader interface with additional members.
  72636. */
  72637. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  72638. }
  72639. /**
  72640. * Loader interface with additional members.
  72641. */
  72642. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  72643. }
  72644. /**
  72645. * Loader interface with additional members.
  72646. */
  72647. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  72648. accessors?: IAccessor[];
  72649. animations?: IAnimation[];
  72650. buffers?: IBuffer[];
  72651. bufferViews?: IBufferView[];
  72652. cameras?: ICamera[];
  72653. images?: IImage[];
  72654. materials?: IMaterial[];
  72655. meshes?: IMesh[];
  72656. nodes?: INode[];
  72657. samplers?: ISampler[];
  72658. scenes?: IScene[];
  72659. skins?: ISkin[];
  72660. textures?: ITexture[];
  72661. }
  72662. }
  72663. declare module BABYLON.GLTF2 {
  72664. /**
  72665. * Interface for a glTF loader extension.
  72666. */
  72667. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  72668. /**
  72669. * Called after the loader state changes to LOADING.
  72670. */
  72671. onLoading?(): void;
  72672. /**
  72673. * Called after the loader state changes to READY.
  72674. */
  72675. onReady?(): void;
  72676. /**
  72677. * Define this method to modify the default behavior when loading scenes.
  72678. * @param context The context when loading the asset
  72679. * @param scene The glTF scene property
  72680. * @returns A promise that resolves when the load is complete or null if not handled
  72681. */
  72682. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  72683. /**
  72684. * Define this method to modify the default behavior when loading nodes.
  72685. * @param context The context when loading the asset
  72686. * @param node The glTF node property
  72687. * @param assign A function called synchronously after parsing the glTF properties
  72688. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  72689. */
  72690. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72691. /**
  72692. * Define this method to modify the default behavior when loading cameras.
  72693. * @param context The context when loading the asset
  72694. * @param camera The glTF camera property
  72695. * @param assign A function called synchronously after parsing the glTF properties
  72696. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  72697. */
  72698. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72699. /**
  72700. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  72701. * @param context The context when loading the asset
  72702. * @param primitive The glTF mesh primitive property
  72703. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  72704. */
  72705. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72706. /**
  72707. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72708. * @param context The context when loading the asset
  72709. * @param name The mesh name when loading the asset
  72710. * @param node The glTF node when loading the asset
  72711. * @param mesh The glTF mesh when loading the asset
  72712. * @param primitive The glTF mesh primitive property
  72713. * @param assign A function called synchronously after parsing the glTF properties
  72714. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72715. */
  72716. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72717. /**
  72718. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  72719. * @param context The context when loading the asset
  72720. * @param material The glTF material property
  72721. * @param assign A function called synchronously after parsing the glTF properties
  72722. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  72723. */
  72724. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72725. /**
  72726. * Define this method to modify the default behavior when creating materials.
  72727. * @param context The context when loading the asset
  72728. * @param material The glTF material property
  72729. * @param babylonDrawMode The draw mode for the Babylon material
  72730. * @returns The Babylon material or null if not handled
  72731. */
  72732. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72733. /**
  72734. * Define this method to modify the default behavior when loading material properties.
  72735. * @param context The context when loading the asset
  72736. * @param material The glTF material property
  72737. * @param babylonMaterial The Babylon material
  72738. * @returns A promise that resolves when the load is complete or null if not handled
  72739. */
  72740. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72741. /**
  72742. * Define this method to modify the default behavior when loading texture infos.
  72743. * @param context The context when loading the asset
  72744. * @param textureInfo The glTF texture info property
  72745. * @param assign A function called synchronously after parsing the glTF properties
  72746. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  72747. */
  72748. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72749. /**
  72750. * Define this method to modify the default behavior when loading animations.
  72751. * @param context The context when loading the asset
  72752. * @param animation The glTF animation property
  72753. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  72754. */
  72755. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72756. /**
  72757. * @hidden Define this method to modify the default behavior when loading skins.
  72758. * @param context The context when loading the asset
  72759. * @param node The glTF node property
  72760. * @param skin The glTF skin property
  72761. * @returns A promise that resolves when the load is complete or null if not handled
  72762. */
  72763. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  72764. /**
  72765. * @hidden Define this method to modify the default behavior when loading uris.
  72766. * @param context The context when loading the asset
  72767. * @param property The glTF property associated with the uri
  72768. * @param uri The uri to load
  72769. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72770. */
  72771. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72772. /**
  72773. * Define this method to modify the default behavior when loading buffer views.
  72774. * @param context The context when loading the asset
  72775. * @param bufferView The glTF buffer view property
  72776. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72777. */
  72778. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  72779. /**
  72780. * Define this method to modify the default behavior when loading buffers.
  72781. * @param context The context when loading the asset
  72782. * @param buffer The glTF buffer property
  72783. * @param byteOffset The byte offset to load
  72784. * @param byteLength The byte length to load
  72785. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72786. */
  72787. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72788. }
  72789. }
  72790. declare module BABYLON.GLTF2 {
  72791. /**
  72792. * Helper class for working with arrays when loading the glTF asset
  72793. */
  72794. export class ArrayItem {
  72795. /**
  72796. * Gets an item from the given array.
  72797. * @param context The context when loading the asset
  72798. * @param array The array to get the item from
  72799. * @param index The index to the array
  72800. * @returns The array item
  72801. */
  72802. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  72803. /**
  72804. * Assign an `index` field to each item of the given array.
  72805. * @param array The array of items
  72806. */
  72807. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  72808. }
  72809. /**
  72810. * The glTF 2.0 loader
  72811. */
  72812. export class GLTFLoader implements IGLTFLoader {
  72813. /** @hidden */
  72814. _completePromises: Promise<any>[];
  72815. private _disposed;
  72816. private _parent;
  72817. private _state;
  72818. private _extensions;
  72819. private _rootUrl;
  72820. private _fileName;
  72821. private _uniqueRootUrl;
  72822. private _gltf;
  72823. private _bin;
  72824. private _babylonScene;
  72825. private _rootBabylonMesh;
  72826. private _defaultBabylonMaterialData;
  72827. private _progressCallback?;
  72828. private _requests;
  72829. private static readonly _DefaultSampler;
  72830. private static _RegisteredExtensions;
  72831. /**
  72832. * Registers a loader extension.
  72833. * @param name The name of the loader extension.
  72834. * @param factory The factory function that creates the loader extension.
  72835. */
  72836. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  72837. /**
  72838. * Unregisters a loader extension.
  72839. * @param name The name of the loader extension.
  72840. * @returns A boolean indicating whether the extension has been unregistered
  72841. */
  72842. static UnregisterExtension(name: string): boolean;
  72843. /**
  72844. * Gets the loader state.
  72845. */
  72846. get state(): Nullable<GLTFLoaderState>;
  72847. /**
  72848. * The object that represents the glTF JSON.
  72849. */
  72850. get gltf(): IGLTF;
  72851. /**
  72852. * The BIN chunk of a binary glTF.
  72853. */
  72854. get bin(): Nullable<IDataBuffer>;
  72855. /**
  72856. * The parent file loader.
  72857. */
  72858. get parent(): GLTFFileLoader;
  72859. /**
  72860. * The Babylon scene when loading the asset.
  72861. */
  72862. get babylonScene(): Scene;
  72863. /**
  72864. * The root Babylon mesh when loading the asset.
  72865. */
  72866. get rootBabylonMesh(): Mesh;
  72867. /** @hidden */
  72868. constructor(parent: GLTFFileLoader);
  72869. /** @hidden */
  72870. dispose(): void;
  72871. /** @hidden */
  72872. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72873. meshes: AbstractMesh[];
  72874. particleSystems: IParticleSystem[];
  72875. skeletons: Skeleton[];
  72876. animationGroups: AnimationGroup[];
  72877. }>;
  72878. /** @hidden */
  72879. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72880. private _loadAsync;
  72881. private _loadData;
  72882. private _setupData;
  72883. private _loadExtensions;
  72884. private _checkExtensions;
  72885. private _setState;
  72886. private _createRootNode;
  72887. /**
  72888. * Loads a glTF scene.
  72889. * @param context The context when loading the asset
  72890. * @param scene The glTF scene property
  72891. * @returns A promise that resolves when the load is complete
  72892. */
  72893. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  72894. private _forEachPrimitive;
  72895. private _getMeshes;
  72896. private _getSkeletons;
  72897. private _getAnimationGroups;
  72898. private _startAnimations;
  72899. /**
  72900. * Loads a glTF node.
  72901. * @param context The context when loading the asset
  72902. * @param node The glTF node property
  72903. * @param assign A function called synchronously after parsing the glTF properties
  72904. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  72905. */
  72906. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  72907. private _loadMeshAsync;
  72908. /**
  72909. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72910. * @param context The context when loading the asset
  72911. * @param name The mesh name when loading the asset
  72912. * @param node The glTF node when loading the asset
  72913. * @param mesh The glTF mesh when loading the asset
  72914. * @param primitive The glTF mesh primitive property
  72915. * @param assign A function called synchronously after parsing the glTF properties
  72916. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72917. */
  72918. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72919. private _loadVertexDataAsync;
  72920. private _createMorphTargets;
  72921. private _loadMorphTargetsAsync;
  72922. private _loadMorphTargetVertexDataAsync;
  72923. private static _LoadTransform;
  72924. private _loadSkinAsync;
  72925. private _loadBones;
  72926. private _loadBone;
  72927. private _loadSkinInverseBindMatricesDataAsync;
  72928. private _updateBoneMatrices;
  72929. private _getNodeMatrix;
  72930. /**
  72931. * Loads a glTF camera.
  72932. * @param context The context when loading the asset
  72933. * @param camera The glTF camera property
  72934. * @param assign A function called synchronously after parsing the glTF properties
  72935. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  72936. */
  72937. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  72938. private _loadAnimationsAsync;
  72939. /**
  72940. * Loads a glTF animation.
  72941. * @param context The context when loading the asset
  72942. * @param animation The glTF animation property
  72943. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  72944. */
  72945. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72946. /**
  72947. * @hidden Loads a glTF animation channel.
  72948. * @param context The context when loading the asset
  72949. * @param animationContext The context of the animation when loading the asset
  72950. * @param animation The glTF animation property
  72951. * @param channel The glTF animation channel property
  72952. * @param babylonAnimationGroup The babylon animation group property
  72953. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72954. * @returns A void promise when the channel load is complete
  72955. */
  72956. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72957. private _loadAnimationSamplerAsync;
  72958. private _loadBufferAsync;
  72959. /**
  72960. * Loads a glTF buffer view.
  72961. * @param context The context when loading the asset
  72962. * @param bufferView The glTF buffer view property
  72963. * @returns A promise that resolves with the loaded data when the load is complete
  72964. */
  72965. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72966. private _loadAccessorAsync;
  72967. private _loadFloatAccessorAsync;
  72968. private _loadIndicesAccessorAsync;
  72969. private _loadVertexBufferViewAsync;
  72970. private _loadVertexAccessorAsync;
  72971. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72972. /** @hidden */
  72973. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72974. private _createDefaultMaterial;
  72975. /**
  72976. * Creates a Babylon material from a glTF material.
  72977. * @param context The context when loading the asset
  72978. * @param material The glTF material property
  72979. * @param babylonDrawMode The draw mode for the Babylon material
  72980. * @returns The Babylon material
  72981. */
  72982. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72983. /**
  72984. * Loads properties from a glTF material into a Babylon material.
  72985. * @param context The context when loading the asset
  72986. * @param material The glTF material property
  72987. * @param babylonMaterial The Babylon material
  72988. * @returns A promise that resolves when the load is complete
  72989. */
  72990. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72991. /**
  72992. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72993. * @param context The context when loading the asset
  72994. * @param material The glTF material property
  72995. * @param babylonMaterial The Babylon material
  72996. * @returns A promise that resolves when the load is complete
  72997. */
  72998. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72999. /**
  73000. * Loads the alpha properties from a glTF material into a Babylon material.
  73001. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  73002. * @param context The context when loading the asset
  73003. * @param material The glTF material property
  73004. * @param babylonMaterial The Babylon material
  73005. */
  73006. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  73007. /**
  73008. * Loads a glTF texture info.
  73009. * @param context The context when loading the asset
  73010. * @param textureInfo The glTF texture info property
  73011. * @param assign A function called synchronously after parsing the glTF properties
  73012. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  73013. */
  73014. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  73015. private _loadTextureAsync;
  73016. private _loadSampler;
  73017. /**
  73018. * Loads a glTF image.
  73019. * @param context The context when loading the asset
  73020. * @param image The glTF image property
  73021. * @returns A promise that resolves with the loaded data when the load is complete
  73022. */
  73023. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  73024. /**
  73025. * Loads a glTF uri.
  73026. * @param context The context when loading the asset
  73027. * @param property The glTF property associated with the uri
  73028. * @param uri The base64 or relative uri
  73029. * @returns A promise that resolves with the loaded data when the load is complete
  73030. */
  73031. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  73032. private _onProgress;
  73033. /**
  73034. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  73035. * @param babylonObject the Babylon object with metadata
  73036. * @param pointer the JSON pointer
  73037. */
  73038. static AddPointerMetadata(babylonObject: {
  73039. metadata: any;
  73040. }, pointer: string): void;
  73041. private static _GetTextureWrapMode;
  73042. private static _GetTextureSamplingMode;
  73043. private static _GetTypedArrayConstructor;
  73044. private static _GetTypedArray;
  73045. private static _GetNumComponents;
  73046. private static _ValidateUri;
  73047. private static _GetDrawMode;
  73048. private _compileMaterialsAsync;
  73049. private _compileShadowGeneratorsAsync;
  73050. private _forEachExtensions;
  73051. private _applyExtensions;
  73052. private _extensionsOnLoading;
  73053. private _extensionsOnReady;
  73054. private _extensionsLoadSceneAsync;
  73055. private _extensionsLoadNodeAsync;
  73056. private _extensionsLoadCameraAsync;
  73057. private _extensionsLoadVertexDataAsync;
  73058. private _extensionsLoadMeshPrimitiveAsync;
  73059. private _extensionsLoadMaterialAsync;
  73060. private _extensionsCreateMaterial;
  73061. private _extensionsLoadMaterialPropertiesAsync;
  73062. private _extensionsLoadTextureInfoAsync;
  73063. private _extensionsLoadAnimationAsync;
  73064. private _extensionsLoadSkinAsync;
  73065. private _extensionsLoadUriAsync;
  73066. private _extensionsLoadBufferViewAsync;
  73067. private _extensionsLoadBufferAsync;
  73068. /**
  73069. * Helper method called by a loader extension to load an glTF extension.
  73070. * @param context The context when loading the asset
  73071. * @param property The glTF property to load the extension from
  73072. * @param extensionName The name of the extension to load
  73073. * @param actionAsync The action to run
  73074. * @returns The promise returned by actionAsync or null if the extension does not exist
  73075. */
  73076. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73077. /**
  73078. * Helper method called by a loader extension to load a glTF extra.
  73079. * @param context The context when loading the asset
  73080. * @param property The glTF property to load the extra from
  73081. * @param extensionName The name of the extension to load
  73082. * @param actionAsync The action to run
  73083. * @returns The promise returned by actionAsync or null if the extra does not exist
  73084. */
  73085. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73086. /**
  73087. * Checks for presence of an extension.
  73088. * @param name The name of the extension to check
  73089. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  73090. */
  73091. isExtensionUsed(name: string): boolean;
  73092. /**
  73093. * Increments the indentation level and logs a message.
  73094. * @param message The message to log
  73095. */
  73096. logOpen(message: string): void;
  73097. /**
  73098. * Decrements the indentation level.
  73099. */
  73100. logClose(): void;
  73101. /**
  73102. * Logs a message
  73103. * @param message The message to log
  73104. */
  73105. log(message: string): void;
  73106. /**
  73107. * Starts a performance counter.
  73108. * @param counterName The name of the performance counter
  73109. */
  73110. startPerformanceCounter(counterName: string): void;
  73111. /**
  73112. * Ends a performance counter.
  73113. * @param counterName The name of the performance counter
  73114. */
  73115. endPerformanceCounter(counterName: string): void;
  73116. }
  73117. }
  73118. declare module BABYLON.GLTF2.Loader.Extensions {
  73119. /**
  73120. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  73121. */
  73122. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  73123. /**
  73124. * The name of this extension.
  73125. */
  73126. readonly name: string;
  73127. /**
  73128. * Defines whether this extension is enabled.
  73129. */
  73130. enabled: boolean;
  73131. private _loader;
  73132. private _lights?;
  73133. /** @hidden */
  73134. constructor(loader: GLTFLoader);
  73135. /** @hidden */
  73136. dispose(): void;
  73137. /** @hidden */
  73138. onLoading(): void;
  73139. /** @hidden */
  73140. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73141. private _loadLightAsync;
  73142. }
  73143. }
  73144. declare module BABYLON.GLTF2.Loader.Extensions {
  73145. /**
  73146. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73147. */
  73148. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73149. /**
  73150. * The name of this extension.
  73151. */
  73152. readonly name: string;
  73153. /**
  73154. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73155. */
  73156. dracoCompression?: DracoCompression;
  73157. /**
  73158. * Defines whether this extension is enabled.
  73159. */
  73160. enabled: boolean;
  73161. private _loader;
  73162. /** @hidden */
  73163. constructor(loader: GLTFLoader);
  73164. /** @hidden */
  73165. dispose(): void;
  73166. /** @hidden */
  73167. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73168. }
  73169. }
  73170. declare module BABYLON.GLTF2.Loader.Extensions {
  73171. /**
  73172. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73173. */
  73174. export class KHR_lights implements IGLTFLoaderExtension {
  73175. /**
  73176. * The name of this extension.
  73177. */
  73178. readonly name: string;
  73179. /**
  73180. * Defines whether this extension is enabled.
  73181. */
  73182. enabled: boolean;
  73183. private _loader;
  73184. private _lights?;
  73185. /** @hidden */
  73186. constructor(loader: GLTFLoader);
  73187. /** @hidden */
  73188. dispose(): void;
  73189. /** @hidden */
  73190. onLoading(): void;
  73191. /** @hidden */
  73192. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73193. }
  73194. }
  73195. declare module BABYLON.GLTF2.Loader.Extensions {
  73196. /**
  73197. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73198. */
  73199. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73200. /**
  73201. * The name of this extension.
  73202. */
  73203. readonly name: string;
  73204. /**
  73205. * Defines whether this extension is enabled.
  73206. */
  73207. enabled: boolean;
  73208. /**
  73209. * Defines a number that determines the order the extensions are applied.
  73210. */
  73211. order: number;
  73212. private _loader;
  73213. /** @hidden */
  73214. constructor(loader: GLTFLoader);
  73215. /** @hidden */
  73216. dispose(): void;
  73217. /** @hidden */
  73218. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73219. private _loadSpecularGlossinessPropertiesAsync;
  73220. }
  73221. }
  73222. declare module BABYLON.GLTF2.Loader.Extensions {
  73223. /**
  73224. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73225. */
  73226. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73227. /**
  73228. * The name of this extension.
  73229. */
  73230. readonly name: string;
  73231. /**
  73232. * Defines whether this extension is enabled.
  73233. */
  73234. enabled: boolean;
  73235. /**
  73236. * Defines a number that determines the order the extensions are applied.
  73237. */
  73238. order: number;
  73239. private _loader;
  73240. /** @hidden */
  73241. constructor(loader: GLTFLoader);
  73242. /** @hidden */
  73243. dispose(): void;
  73244. /** @hidden */
  73245. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73246. private _loadUnlitPropertiesAsync;
  73247. }
  73248. }
  73249. declare module BABYLON.GLTF2.Loader.Extensions {
  73250. /**
  73251. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73252. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73253. * !!! Experimental Extension Subject to Changes !!!
  73254. */
  73255. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73256. /**
  73257. * The name of this extension.
  73258. */
  73259. readonly name: string;
  73260. /**
  73261. * Defines whether this extension is enabled.
  73262. */
  73263. enabled: boolean;
  73264. /**
  73265. * Defines a number that determines the order the extensions are applied.
  73266. */
  73267. order: number;
  73268. private _loader;
  73269. /** @hidden */
  73270. constructor(loader: GLTFLoader);
  73271. /** @hidden */
  73272. dispose(): void;
  73273. /** @hidden */
  73274. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73275. private _loadClearCoatPropertiesAsync;
  73276. }
  73277. }
  73278. declare module BABYLON.GLTF2.Loader.Extensions {
  73279. /**
  73280. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73281. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73282. * !!! Experimental Extension Subject to Changes !!!
  73283. */
  73284. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73285. /**
  73286. * The name of this extension.
  73287. */
  73288. readonly name: string;
  73289. /**
  73290. * Defines whether this extension is enabled.
  73291. */
  73292. enabled: boolean;
  73293. /**
  73294. * Defines a number that determines the order the extensions are applied.
  73295. */
  73296. order: number;
  73297. private _loader;
  73298. /** @hidden */
  73299. constructor(loader: GLTFLoader);
  73300. /** @hidden */
  73301. dispose(): void;
  73302. /** @hidden */
  73303. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73304. private _loadSheenPropertiesAsync;
  73305. }
  73306. }
  73307. declare module BABYLON.GLTF2.Loader.Extensions {
  73308. /**
  73309. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73310. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73311. * !!! Experimental Extension Subject to Changes !!!
  73312. */
  73313. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73314. /**
  73315. * The name of this extension.
  73316. */
  73317. readonly name: string;
  73318. /**
  73319. * Defines whether this extension is enabled.
  73320. */
  73321. enabled: boolean;
  73322. /**
  73323. * Defines a number that determines the order the extensions are applied.
  73324. */
  73325. order: number;
  73326. private _loader;
  73327. /** @hidden */
  73328. constructor(loader: GLTFLoader);
  73329. /** @hidden */
  73330. dispose(): void;
  73331. /** @hidden */
  73332. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73333. private _loadSpecularPropertiesAsync;
  73334. }
  73335. }
  73336. declare module BABYLON.GLTF2.Loader.Extensions {
  73337. /**
  73338. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  73339. */
  73340. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  73341. /**
  73342. * The name of this extension.
  73343. */
  73344. readonly name: string;
  73345. /**
  73346. * Defines whether this extension is enabled.
  73347. */
  73348. enabled: boolean;
  73349. /** @hidden */
  73350. constructor(loader: GLTFLoader);
  73351. /** @hidden */
  73352. dispose(): void;
  73353. }
  73354. }
  73355. declare module BABYLON.GLTF2.Loader.Extensions {
  73356. /**
  73357. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  73358. */
  73359. export class KHR_texture_transform implements IGLTFLoaderExtension {
  73360. /**
  73361. * The name of this extension.
  73362. */
  73363. readonly name: string;
  73364. /**
  73365. * Defines whether this extension is enabled.
  73366. */
  73367. enabled: boolean;
  73368. private _loader;
  73369. /** @hidden */
  73370. constructor(loader: GLTFLoader);
  73371. /** @hidden */
  73372. dispose(): void;
  73373. /** @hidden */
  73374. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73375. }
  73376. }
  73377. declare module BABYLON.GLTF2.Loader.Extensions {
  73378. /**
  73379. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  73380. */
  73381. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  73382. /**
  73383. * The name of this extension.
  73384. */
  73385. readonly name: string;
  73386. /**
  73387. * Defines whether this extension is enabled.
  73388. */
  73389. enabled: boolean;
  73390. private _loader;
  73391. private _clips;
  73392. private _emitters;
  73393. /** @hidden */
  73394. constructor(loader: GLTFLoader);
  73395. /** @hidden */
  73396. dispose(): void;
  73397. /** @hidden */
  73398. onLoading(): void;
  73399. /** @hidden */
  73400. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73401. /** @hidden */
  73402. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73403. /** @hidden */
  73404. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73405. private _loadClipAsync;
  73406. private _loadEmitterAsync;
  73407. private _getEventAction;
  73408. private _loadAnimationEventAsync;
  73409. }
  73410. }
  73411. declare module BABYLON.GLTF2.Loader.Extensions {
  73412. /**
  73413. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  73414. */
  73415. export class MSFT_lod implements IGLTFLoaderExtension {
  73416. /**
  73417. * The name of this extension.
  73418. */
  73419. readonly name: string;
  73420. /**
  73421. * Defines whether this extension is enabled.
  73422. */
  73423. enabled: boolean;
  73424. /**
  73425. * Defines a number that determines the order the extensions are applied.
  73426. */
  73427. order: number;
  73428. /**
  73429. * Maximum number of LODs to load, starting from the lowest LOD.
  73430. */
  73431. maxLODsToLoad: number;
  73432. /**
  73433. * Observable raised when all node LODs of one level are loaded.
  73434. * The event data is the index of the loaded LOD starting from zero.
  73435. * Dispose the loader to cancel the loading of the next level of LODs.
  73436. */
  73437. onNodeLODsLoadedObservable: Observable<number>;
  73438. /**
  73439. * Observable raised when all material LODs of one level are loaded.
  73440. * The event data is the index of the loaded LOD starting from zero.
  73441. * Dispose the loader to cancel the loading of the next level of LODs.
  73442. */
  73443. onMaterialLODsLoadedObservable: Observable<number>;
  73444. private _loader;
  73445. private _nodeIndexLOD;
  73446. private _nodeSignalLODs;
  73447. private _nodePromiseLODs;
  73448. private _materialIndexLOD;
  73449. private _materialSignalLODs;
  73450. private _materialPromiseLODs;
  73451. private _indexLOD;
  73452. private _bufferLODs;
  73453. /** @hidden */
  73454. constructor(loader: GLTFLoader);
  73455. /** @hidden */
  73456. dispose(): void;
  73457. /** @hidden */
  73458. onReady(): void;
  73459. /** @hidden */
  73460. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73461. /** @hidden */
  73462. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73463. /** @hidden */
  73464. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73465. /** @hidden */
  73466. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73467. private _loadBufferLOD;
  73468. /**
  73469. * Gets an array of LOD properties from lowest to highest.
  73470. */
  73471. private _getLODs;
  73472. private _disposeUnusedMaterials;
  73473. }
  73474. }
  73475. declare module BABYLON.GLTF2.Loader.Extensions {
  73476. /** @hidden */
  73477. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  73478. readonly name: string;
  73479. enabled: boolean;
  73480. private _loader;
  73481. constructor(loader: GLTFLoader);
  73482. dispose(): void;
  73483. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73484. }
  73485. }
  73486. declare module BABYLON.GLTF2.Loader.Extensions {
  73487. /** @hidden */
  73488. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  73489. readonly name: string;
  73490. enabled: boolean;
  73491. private _loader;
  73492. constructor(loader: GLTFLoader);
  73493. dispose(): void;
  73494. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73495. }
  73496. }
  73497. declare module BABYLON.GLTF2.Loader.Extensions {
  73498. /**
  73499. * Store glTF extras (if present) in BJS objects' metadata
  73500. */
  73501. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  73502. /**
  73503. * The name of this extension.
  73504. */
  73505. readonly name: string;
  73506. /**
  73507. * Defines whether this extension is enabled.
  73508. */
  73509. enabled: boolean;
  73510. private _loader;
  73511. private _assignExtras;
  73512. /** @hidden */
  73513. constructor(loader: GLTFLoader);
  73514. /** @hidden */
  73515. dispose(): void;
  73516. /** @hidden */
  73517. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73518. /** @hidden */
  73519. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73520. /** @hidden */
  73521. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73522. }
  73523. }
  73524. declare module BABYLON {
  73525. /**
  73526. * Class reading and parsing the MTL file bundled with the obj file.
  73527. */
  73528. export class MTLFileLoader {
  73529. /**
  73530. * All material loaded from the mtl will be set here
  73531. */
  73532. materials: StandardMaterial[];
  73533. /**
  73534. * This function will read the mtl file and create each material described inside
  73535. * This function could be improve by adding :
  73536. * -some component missing (Ni, Tf...)
  73537. * -including the specific options available
  73538. *
  73539. * @param scene defines the scene the material will be created in
  73540. * @param data defines the mtl data to parse
  73541. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  73542. */
  73543. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  73544. /**
  73545. * Gets the texture for the material.
  73546. *
  73547. * If the material is imported from input file,
  73548. * We sanitize the url to ensure it takes the textre from aside the material.
  73549. *
  73550. * @param rootUrl The root url to load from
  73551. * @param value The value stored in the mtl
  73552. * @return The Texture
  73553. */
  73554. private static _getTexture;
  73555. }
  73556. /**
  73557. * Options for loading OBJ/MTL files
  73558. */
  73559. type MeshLoadOptions = {
  73560. /**
  73561. * Defines if UVs are optimized by default during load.
  73562. */
  73563. OptimizeWithUV: boolean;
  73564. /**
  73565. * Defines custom scaling of UV coordinates of loaded meshes.
  73566. */
  73567. UVScaling: Vector2;
  73568. /**
  73569. * Invert model on y-axis (does a model scaling inversion)
  73570. */
  73571. InvertY: boolean;
  73572. /**
  73573. * Invert Y-Axis of referenced textures on load
  73574. */
  73575. InvertTextureY: boolean;
  73576. /**
  73577. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73578. */
  73579. ImportVertexColors: boolean;
  73580. /**
  73581. * Compute the normals for the model, even if normals are present in the file.
  73582. */
  73583. ComputeNormals: boolean;
  73584. /**
  73585. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73586. */
  73587. SkipMaterials: boolean;
  73588. /**
  73589. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73590. */
  73591. MaterialLoadingFailsSilently: boolean;
  73592. };
  73593. /**
  73594. * OBJ file type loader.
  73595. * This is a babylon scene loader plugin.
  73596. */
  73597. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73598. /**
  73599. * Defines if UVs are optimized by default during load.
  73600. */
  73601. static OPTIMIZE_WITH_UV: boolean;
  73602. /**
  73603. * Invert model on y-axis (does a model scaling inversion)
  73604. */
  73605. static INVERT_Y: boolean;
  73606. /**
  73607. * Invert Y-Axis of referenced textures on load
  73608. */
  73609. static INVERT_TEXTURE_Y: boolean;
  73610. /**
  73611. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73612. */
  73613. static IMPORT_VERTEX_COLORS: boolean;
  73614. /**
  73615. * Compute the normals for the model, even if normals are present in the file.
  73616. */
  73617. static COMPUTE_NORMALS: boolean;
  73618. /**
  73619. * Defines custom scaling of UV coordinates of loaded meshes.
  73620. */
  73621. static UV_SCALING: Vector2;
  73622. /**
  73623. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73624. */
  73625. static SKIP_MATERIALS: boolean;
  73626. /**
  73627. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73628. *
  73629. * Defaults to true for backwards compatibility.
  73630. */
  73631. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  73632. /**
  73633. * Defines the name of the plugin.
  73634. */
  73635. name: string;
  73636. /**
  73637. * Defines the extension the plugin is able to load.
  73638. */
  73639. extensions: string;
  73640. /** @hidden */
  73641. obj: RegExp;
  73642. /** @hidden */
  73643. group: RegExp;
  73644. /** @hidden */
  73645. mtllib: RegExp;
  73646. /** @hidden */
  73647. usemtl: RegExp;
  73648. /** @hidden */
  73649. smooth: RegExp;
  73650. /** @hidden */
  73651. vertexPattern: RegExp;
  73652. /** @hidden */
  73653. normalPattern: RegExp;
  73654. /** @hidden */
  73655. uvPattern: RegExp;
  73656. /** @hidden */
  73657. facePattern1: RegExp;
  73658. /** @hidden */
  73659. facePattern2: RegExp;
  73660. /** @hidden */
  73661. facePattern3: RegExp;
  73662. /** @hidden */
  73663. facePattern4: RegExp;
  73664. /** @hidden */
  73665. facePattern5: RegExp;
  73666. private _meshLoadOptions;
  73667. /**
  73668. * Creates loader for .OBJ files
  73669. *
  73670. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  73671. */
  73672. constructor(meshLoadOptions?: MeshLoadOptions);
  73673. private static get currentMeshLoadOptions();
  73674. /**
  73675. * Calls synchronously the MTL file attached to this obj.
  73676. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  73677. * Without this function materials are not displayed in the first frame (but displayed after).
  73678. * In consequence it is impossible to get material information in your HTML file
  73679. *
  73680. * @param url The URL of the MTL file
  73681. * @param rootUrl
  73682. * @param onSuccess Callback function to be called when the MTL file is loaded
  73683. * @private
  73684. */
  73685. private _loadMTL;
  73686. /**
  73687. * Instantiates a OBJ file loader plugin.
  73688. * @returns the created plugin
  73689. */
  73690. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  73691. /**
  73692. * If the data string can be loaded directly.
  73693. *
  73694. * @param data string containing the file data
  73695. * @returns if the data can be loaded directly
  73696. */
  73697. canDirectLoad(data: string): boolean;
  73698. /**
  73699. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73700. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73701. * @param scene the scene the meshes should be added to
  73702. * @param data the OBJ data to load
  73703. * @param rootUrl root url to load from
  73704. * @param onProgress event that fires when loading progress has occured
  73705. * @param fileName Defines the name of the file to load
  73706. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73707. */
  73708. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73709. meshes: AbstractMesh[];
  73710. particleSystems: IParticleSystem[];
  73711. skeletons: Skeleton[];
  73712. animationGroups: AnimationGroup[];
  73713. }>;
  73714. /**
  73715. * Imports all objects from the loaded OBJ data and adds them to the scene
  73716. * @param scene the scene the objects should be added to
  73717. * @param data the OBJ data to load
  73718. * @param rootUrl root url to load from
  73719. * @param onProgress event that fires when loading progress has occured
  73720. * @param fileName Defines the name of the file to load
  73721. * @returns a promise which completes when objects have been loaded to the scene
  73722. */
  73723. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73724. /**
  73725. * Load into an asset container.
  73726. * @param scene The scene to load into
  73727. * @param data The data to import
  73728. * @param rootUrl The root url for scene and resources
  73729. * @param onProgress The callback when the load progresses
  73730. * @param fileName Defines the name of the file to load
  73731. * @returns The loaded asset container
  73732. */
  73733. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73734. /**
  73735. * Read the OBJ file and create an Array of meshes.
  73736. * Each mesh contains all information given by the OBJ and the MTL file.
  73737. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  73738. *
  73739. * @param meshesNames
  73740. * @param scene Scene The scene where are displayed the data
  73741. * @param data String The content of the obj file
  73742. * @param rootUrl String The path to the folder
  73743. * @returns Array<AbstractMesh>
  73744. * @private
  73745. */
  73746. private _parseSolid;
  73747. }
  73748. }
  73749. declare module BABYLON {
  73750. /**
  73751. * STL file type loader.
  73752. * This is a babylon scene loader plugin.
  73753. */
  73754. export class STLFileLoader implements ISceneLoaderPlugin {
  73755. /** @hidden */
  73756. solidPattern: RegExp;
  73757. /** @hidden */
  73758. facetsPattern: RegExp;
  73759. /** @hidden */
  73760. normalPattern: RegExp;
  73761. /** @hidden */
  73762. vertexPattern: RegExp;
  73763. /**
  73764. * Defines the name of the plugin.
  73765. */
  73766. name: string;
  73767. /**
  73768. * Defines the extensions the stl loader is able to load.
  73769. * force data to come in as an ArrayBuffer
  73770. * we'll convert to string if it looks like it's an ASCII .stl
  73771. */
  73772. extensions: ISceneLoaderPluginExtensions;
  73773. /**
  73774. * Import meshes into a scene.
  73775. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  73776. * @param scene The scene to import into
  73777. * @param data The data to import
  73778. * @param rootUrl The root url for scene and resources
  73779. * @param meshes The meshes array to import into
  73780. * @param particleSystems The particle systems array to import into
  73781. * @param skeletons The skeletons array to import into
  73782. * @param onError The callback when import fails
  73783. * @returns True if successful or false otherwise
  73784. */
  73785. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  73786. /**
  73787. * Load into a scene.
  73788. * @param scene The scene to load into
  73789. * @param data The data to import
  73790. * @param rootUrl The root url for scene and resources
  73791. * @param onError The callback when import fails
  73792. * @returns true if successful or false otherwise
  73793. */
  73794. load(scene: Scene, data: any, rootUrl: string): boolean;
  73795. /**
  73796. * Load into an asset container.
  73797. * @param scene The scene to load into
  73798. * @param data The data to import
  73799. * @param rootUrl The root url for scene and resources
  73800. * @param onError The callback when import fails
  73801. * @returns The loaded asset container
  73802. */
  73803. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  73804. private _isBinary;
  73805. private _parseBinary;
  73806. private _parseASCII;
  73807. }
  73808. }
  73809. declare module BABYLON {
  73810. /**
  73811. * Class for generating OBJ data from a Babylon scene.
  73812. */
  73813. export class OBJExport {
  73814. /**
  73815. * Exports the geometry of a Mesh array in .OBJ file format (text)
  73816. * @param mesh defines the list of meshes to serialize
  73817. * @param materials defines if materials should be exported
  73818. * @param matlibname defines the name of the associated mtl file
  73819. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  73820. * @returns the OBJ content
  73821. */
  73822. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  73823. /**
  73824. * Exports the material(s) of a mesh in .MTL file format (text)
  73825. * @param mesh defines the mesh to extract the material from
  73826. * @returns the mtl content
  73827. */
  73828. static MTL(mesh: Mesh): string;
  73829. }
  73830. }
  73831. declare module BABYLON {
  73832. /** @hidden */
  73833. export var __IGLTFExporterExtension: number;
  73834. /**
  73835. * Interface for extending the exporter
  73836. * @hidden
  73837. */
  73838. export interface IGLTFExporterExtension {
  73839. /**
  73840. * The name of this extension
  73841. */
  73842. readonly name: string;
  73843. /**
  73844. * Defines whether this extension is enabled
  73845. */
  73846. enabled: boolean;
  73847. /**
  73848. * Defines whether this extension is required
  73849. */
  73850. required: boolean;
  73851. }
  73852. }
  73853. declare module BABYLON.GLTF2.Exporter {
  73854. /** @hidden */
  73855. export var __IGLTFExporterExtensionV2: number;
  73856. /**
  73857. * Interface for a glTF exporter extension
  73858. * @hidden
  73859. */
  73860. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  73861. /**
  73862. * Define this method to modify the default behavior before exporting a texture
  73863. * @param context The context when loading the asset
  73864. * @param babylonTexture The Babylon.js texture
  73865. * @param mimeType The mime-type of the generated image
  73866. * @returns A promise that resolves with the exported texture
  73867. */
  73868. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73869. /**
  73870. * Define this method to get notified when a texture info is created
  73871. * @param context The context when loading the asset
  73872. * @param textureInfo The glTF texture info
  73873. * @param babylonTexture The Babylon.js texture
  73874. */
  73875. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73876. /**
  73877. * Define this method to modify the default behavior when exporting texture info
  73878. * @param context The context when loading the asset
  73879. * @param meshPrimitive glTF mesh primitive
  73880. * @param babylonSubMesh Babylon submesh
  73881. * @param binaryWriter glTF serializer binary writer instance
  73882. * @returns nullable IMeshPrimitive promise
  73883. */
  73884. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  73885. /**
  73886. * Define this method to modify the default behavior when exporting a node
  73887. * @param context The context when exporting the node
  73888. * @param node glTF node
  73889. * @param babylonNode BabylonJS node
  73890. * @returns nullable INode promise
  73891. */
  73892. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73893. /**
  73894. * Define this method to modify the default behavior when exporting a material
  73895. * @param material glTF material
  73896. * @param babylonMaterial BabylonJS material
  73897. * @returns nullable IMaterial promise
  73898. */
  73899. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73900. /**
  73901. * Define this method to return additional textures to export from a material
  73902. * @param material glTF material
  73903. * @param babylonMaterial BabylonJS material
  73904. * @returns List of textures
  73905. */
  73906. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73907. /** Gets a boolean indicating that this extension was used */
  73908. wasUsed: boolean;
  73909. /** Gets a boolean indicating that this extension is required for the file to work */
  73910. required: boolean;
  73911. /**
  73912. * Called after the exporter state changes to EXPORTING
  73913. */
  73914. onExporting?(): void;
  73915. }
  73916. }
  73917. declare module BABYLON.GLTF2.Exporter {
  73918. /**
  73919. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  73920. * @hidden
  73921. */
  73922. export class _GLTFMaterialExporter {
  73923. /**
  73924. * Represents the dielectric specular values for R, G and B
  73925. */
  73926. private static readonly _DielectricSpecular;
  73927. /**
  73928. * Allows the maximum specular power to be defined for material calculations
  73929. */
  73930. private static readonly _MaxSpecularPower;
  73931. /**
  73932. * Mapping to store textures
  73933. */
  73934. private _textureMap;
  73935. /**
  73936. * Numeric tolerance value
  73937. */
  73938. private static readonly _Epsilon;
  73939. /**
  73940. * Reference to the glTF Exporter
  73941. */
  73942. private _exporter;
  73943. constructor(exporter: _Exporter);
  73944. /**
  73945. * Specifies if two colors are approximately equal in value
  73946. * @param color1 first color to compare to
  73947. * @param color2 second color to compare to
  73948. * @param epsilon threshold value
  73949. */
  73950. private static FuzzyEquals;
  73951. /**
  73952. * Gets the materials from a Babylon scene and converts them to glTF materials
  73953. * @param scene babylonjs scene
  73954. * @param mimeType texture mime type
  73955. * @param images array of images
  73956. * @param textures array of textures
  73957. * @param materials array of materials
  73958. * @param imageData mapping of texture names to base64 textures
  73959. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73960. */
  73961. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73962. /**
  73963. * Makes a copy of the glTF material without the texture parameters
  73964. * @param originalMaterial original glTF material
  73965. * @returns glTF material without texture parameters
  73966. */
  73967. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73968. /**
  73969. * Specifies if the material has any texture parameters present
  73970. * @param material glTF Material
  73971. * @returns boolean specifying if texture parameters are present
  73972. */
  73973. _hasTexturesPresent(material: IMaterial): boolean;
  73974. /**
  73975. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73976. * @param babylonStandardMaterial
  73977. * @returns glTF Metallic Roughness Material representation
  73978. */
  73979. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73980. /**
  73981. * Computes the metallic factor
  73982. * @param diffuse diffused value
  73983. * @param specular specular value
  73984. * @param oneMinusSpecularStrength one minus the specular strength
  73985. * @returns metallic value
  73986. */
  73987. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73988. /**
  73989. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73990. * @param glTFMaterial glTF material
  73991. * @param babylonMaterial Babylon material
  73992. */
  73993. private static _SetAlphaMode;
  73994. /**
  73995. * Converts a Babylon Standard Material to a glTF Material
  73996. * @param babylonStandardMaterial BJS Standard Material
  73997. * @param mimeType mime type to use for the textures
  73998. * @param images array of glTF image interfaces
  73999. * @param textures array of glTF texture interfaces
  74000. * @param materials array of glTF material interfaces
  74001. * @param imageData map of image file name to data
  74002. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74003. */
  74004. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74005. private _finishMaterial;
  74006. /**
  74007. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74008. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  74009. * @param mimeType mime type to use for the textures
  74010. * @param images array of glTF image interfaces
  74011. * @param textures array of glTF texture interfaces
  74012. * @param materials array of glTF material interfaces
  74013. * @param imageData map of image file name to data
  74014. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74015. */
  74016. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74017. /**
  74018. * Converts an image typed array buffer to a base64 image
  74019. * @param buffer typed array buffer
  74020. * @param width width of the image
  74021. * @param height height of the image
  74022. * @param mimeType mimetype of the image
  74023. * @returns base64 image string
  74024. */
  74025. private _createBase64FromCanvasAsync;
  74026. /**
  74027. * Generates a white texture based on the specified width and height
  74028. * @param width width of the texture in pixels
  74029. * @param height height of the texture in pixels
  74030. * @param scene babylonjs scene
  74031. * @returns white texture
  74032. */
  74033. private _createWhiteTexture;
  74034. /**
  74035. * 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
  74036. * @param texture1 first texture to resize
  74037. * @param texture2 second texture to resize
  74038. * @param scene babylonjs scene
  74039. * @returns resized textures or null
  74040. */
  74041. private _resizeTexturesToSameDimensions;
  74042. /**
  74043. * Converts an array of pixels to a Float32Array
  74044. * Throws an error if the pixel format is not supported
  74045. * @param pixels - array buffer containing pixel values
  74046. * @returns Float32 of pixels
  74047. */
  74048. private _convertPixelArrayToFloat32;
  74049. /**
  74050. * Convert Specular Glossiness Textures to Metallic Roughness
  74051. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  74052. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  74053. * @param diffuseTexture texture used to store diffuse information
  74054. * @param specularGlossinessTexture texture used to store specular and glossiness information
  74055. * @param factors specular glossiness material factors
  74056. * @param mimeType the mime type to use for the texture
  74057. * @returns pbr metallic roughness interface or null
  74058. */
  74059. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  74060. /**
  74061. * Converts specular glossiness material properties to metallic roughness
  74062. * @param specularGlossiness interface with specular glossiness material properties
  74063. * @returns interface with metallic roughness material properties
  74064. */
  74065. private _convertSpecularGlossinessToMetallicRoughness;
  74066. /**
  74067. * Calculates the surface reflectance, independent of lighting conditions
  74068. * @param color Color source to calculate brightness from
  74069. * @returns number representing the perceived brightness, or zero if color is undefined
  74070. */
  74071. private _getPerceivedBrightness;
  74072. /**
  74073. * Returns the maximum color component value
  74074. * @param color
  74075. * @returns maximum color component value, or zero if color is null or undefined
  74076. */
  74077. private _getMaxComponent;
  74078. /**
  74079. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  74080. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74081. * @param mimeType mime type to use for the textures
  74082. * @param images array of glTF image interfaces
  74083. * @param textures array of glTF texture interfaces
  74084. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74085. * @param imageData map of image file name to data
  74086. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74087. * @returns glTF PBR Metallic Roughness factors
  74088. */
  74089. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  74090. private _getGLTFTextureSampler;
  74091. private _getGLTFTextureWrapMode;
  74092. private _getGLTFTextureWrapModesSampler;
  74093. /**
  74094. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  74095. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74096. * @param mimeType mime type to use for the textures
  74097. * @param images array of glTF image interfaces
  74098. * @param textures array of glTF texture interfaces
  74099. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74100. * @param imageData map of image file name to data
  74101. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74102. * @returns glTF PBR Metallic Roughness factors
  74103. */
  74104. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  74105. /**
  74106. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74107. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74108. * @param mimeType mime type to use for the textures
  74109. * @param images array of glTF image interfaces
  74110. * @param textures array of glTF texture interfaces
  74111. * @param materials array of glTF material interfaces
  74112. * @param imageData map of image file name to data
  74113. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74114. */
  74115. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74116. private setMetallicRoughnessPbrMaterial;
  74117. private getPixelsFromTexture;
  74118. /**
  74119. * Extracts a texture from a Babylon texture into file data and glTF data
  74120. * @param babylonTexture Babylon texture to extract
  74121. * @param mimeType Mime Type of the babylonTexture
  74122. * @return glTF texture info, or null if the texture format is not supported
  74123. */
  74124. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74125. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74126. /**
  74127. * Builds a texture from base64 string
  74128. * @param base64Texture base64 texture string
  74129. * @param baseTextureName Name to use for the texture
  74130. * @param mimeType image mime type for the texture
  74131. * @param images array of images
  74132. * @param textures array of textures
  74133. * @param imageData map of image data
  74134. * @returns glTF texture info, or null if the texture format is not supported
  74135. */
  74136. private _getTextureInfoFromBase64;
  74137. }
  74138. }
  74139. declare module BABYLON {
  74140. /**
  74141. * Class for holding and downloading glTF file data
  74142. */
  74143. export class GLTFData {
  74144. /**
  74145. * Object which contains the file name as the key and its data as the value
  74146. */
  74147. glTFFiles: {
  74148. [fileName: string]: string | Blob;
  74149. };
  74150. /**
  74151. * Initializes the glTF file object
  74152. */
  74153. constructor();
  74154. /**
  74155. * Downloads the glTF data as files based on their names and data
  74156. */
  74157. downloadFiles(): void;
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. /**
  74162. * Holds a collection of exporter options and parameters
  74163. */
  74164. export interface IExportOptions {
  74165. /**
  74166. * Function which indicates whether a babylon node should be exported or not
  74167. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74168. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74169. */
  74170. shouldExportNode?(node: Node): boolean;
  74171. /**
  74172. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74173. * @param metadata source metadata to read from
  74174. * @returns the data to store to glTF node extras
  74175. */
  74176. metadataSelector?(metadata: any): any;
  74177. /**
  74178. * The sample rate to bake animation curves
  74179. */
  74180. animationSampleRate?: number;
  74181. /**
  74182. * Begin serialization without waiting for the scene to be ready
  74183. */
  74184. exportWithoutWaitingForScene?: boolean;
  74185. }
  74186. /**
  74187. * Class for generating glTF data from a Babylon scene.
  74188. */
  74189. export class GLTF2Export {
  74190. /**
  74191. * Exports the geometry of the scene to .gltf file format asynchronously
  74192. * @param scene Babylon scene with scene hierarchy information
  74193. * @param filePrefix File prefix to use when generating the glTF file
  74194. * @param options Exporter options
  74195. * @returns Returns an object with a .gltf file and associates texture names
  74196. * as keys and their data and paths as values
  74197. */
  74198. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74199. private static _PreExportAsync;
  74200. private static _PostExportAsync;
  74201. /**
  74202. * Exports the geometry of the scene to .glb file format asychronously
  74203. * @param scene Babylon scene with scene hierarchy information
  74204. * @param filePrefix File prefix to use when generating glb file
  74205. * @param options Exporter options
  74206. * @returns Returns an object with a .glb filename as key and data as value
  74207. */
  74208. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74209. }
  74210. }
  74211. declare module BABYLON.GLTF2.Exporter {
  74212. /**
  74213. * @hidden
  74214. */
  74215. export class _GLTFUtilities {
  74216. /**
  74217. * Creates a buffer view based on the supplied arguments
  74218. * @param bufferIndex index value of the specified buffer
  74219. * @param byteOffset byte offset value
  74220. * @param byteLength byte length of the bufferView
  74221. * @param byteStride byte distance between conequential elements
  74222. * @param name name of the buffer view
  74223. * @returns bufferView for glTF
  74224. */
  74225. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74226. /**
  74227. * Creates an accessor based on the supplied arguments
  74228. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74229. * @param name The name of the accessor
  74230. * @param type The type of the accessor
  74231. * @param componentType The datatype of components in the attribute
  74232. * @param count The number of attributes referenced by this accessor
  74233. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74234. * @param min Minimum value of each component in this attribute
  74235. * @param max Maximum value of each component in this attribute
  74236. * @returns accessor for glTF
  74237. */
  74238. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74239. /**
  74240. * Calculates the minimum and maximum values of an array of position floats
  74241. * @param positions Positions array of a mesh
  74242. * @param vertexStart Starting vertex offset to calculate min and max values
  74243. * @param vertexCount Number of vertices to check for min and max values
  74244. * @returns min number array and max number array
  74245. */
  74246. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74247. min: number[];
  74248. max: number[];
  74249. };
  74250. /**
  74251. * Converts a new right-handed Vector3
  74252. * @param vector vector3 array
  74253. * @returns right-handed Vector3
  74254. */
  74255. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74256. /**
  74257. * Converts a Vector3 to right-handed
  74258. * @param vector Vector3 to convert to right-handed
  74259. */
  74260. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74261. /**
  74262. * Converts a three element number array to right-handed
  74263. * @param vector number array to convert to right-handed
  74264. */
  74265. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74266. /**
  74267. * Converts a new right-handed Vector3
  74268. * @param vector vector3 array
  74269. * @returns right-handed Vector3
  74270. */
  74271. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74272. /**
  74273. * Converts a Vector3 to right-handed
  74274. * @param vector Vector3 to convert to right-handed
  74275. */
  74276. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74277. /**
  74278. * Converts a three element number array to right-handed
  74279. * @param vector number array to convert to right-handed
  74280. */
  74281. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74282. /**
  74283. * Converts a Vector4 to right-handed
  74284. * @param vector Vector4 to convert to right-handed
  74285. */
  74286. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74287. /**
  74288. * Converts a Vector4 to right-handed
  74289. * @param vector Vector4 to convert to right-handed
  74290. */
  74291. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74292. /**
  74293. * Converts a Quaternion to right-handed
  74294. * @param quaternion Source quaternion to convert to right-handed
  74295. */
  74296. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74297. /**
  74298. * Converts a Quaternion to right-handed
  74299. * @param quaternion Source quaternion to convert to right-handed
  74300. */
  74301. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74302. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74303. }
  74304. }
  74305. declare module BABYLON.GLTF2.Exporter {
  74306. /**
  74307. * Converts Babylon Scene into glTF 2.0.
  74308. * @hidden
  74309. */
  74310. export class _Exporter {
  74311. /**
  74312. * Stores the glTF to export
  74313. */
  74314. _glTF: IGLTF;
  74315. /**
  74316. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74317. */
  74318. _bufferViews: IBufferView[];
  74319. /**
  74320. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  74321. */
  74322. _accessors: IAccessor[];
  74323. /**
  74324. * Stores all the generated nodes, which contains transform and/or mesh information per node
  74325. */
  74326. private _nodes;
  74327. /**
  74328. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  74329. */
  74330. private _scenes;
  74331. /**
  74332. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  74333. */
  74334. private _meshes;
  74335. /**
  74336. * Stores all the generated material information, which represents the appearance of each primitive
  74337. */
  74338. _materials: IMaterial[];
  74339. _materialMap: {
  74340. [materialID: number]: number;
  74341. };
  74342. /**
  74343. * Stores all the generated texture information, which is referenced by glTF materials
  74344. */
  74345. _textures: ITexture[];
  74346. /**
  74347. * Stores all the generated image information, which is referenced by glTF textures
  74348. */
  74349. _images: IImage[];
  74350. /**
  74351. * Stores all the texture samplers
  74352. */
  74353. _samplers: ISampler[];
  74354. /**
  74355. * Stores all the generated animation samplers, which is referenced by glTF animations
  74356. */
  74357. /**
  74358. * Stores the animations for glTF models
  74359. */
  74360. private _animations;
  74361. /**
  74362. * Stores the total amount of bytes stored in the glTF buffer
  74363. */
  74364. private _totalByteLength;
  74365. /**
  74366. * Stores a reference to the Babylon scene containing the source geometry and material information
  74367. */
  74368. _babylonScene: Scene;
  74369. /**
  74370. * Stores a map of the image data, where the key is the file name and the value
  74371. * is the image data
  74372. */
  74373. _imageData: {
  74374. [fileName: string]: {
  74375. data: Uint8Array;
  74376. mimeType: ImageMimeType;
  74377. };
  74378. };
  74379. /**
  74380. * Stores a map of the unique id of a node to its index in the node array
  74381. */
  74382. private _nodeMap;
  74383. /**
  74384. * Specifies if the Babylon scene should be converted to right-handed on export
  74385. */
  74386. _convertToRightHandedSystem: boolean;
  74387. /**
  74388. * Baked animation sample rate
  74389. */
  74390. private _animationSampleRate;
  74391. private _options;
  74392. private _localEngine;
  74393. _glTFMaterialExporter: _GLTFMaterialExporter;
  74394. private _extensions;
  74395. private static _ExtensionNames;
  74396. private static _ExtensionFactories;
  74397. private _applyExtension;
  74398. private _applyExtensions;
  74399. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  74400. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  74401. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  74402. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  74403. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  74404. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74405. private _forEachExtensions;
  74406. private _extensionsOnExporting;
  74407. /**
  74408. * Load glTF serializer extensions
  74409. */
  74410. private _loadExtensions;
  74411. /**
  74412. * Creates a glTF Exporter instance, which can accept optional exporter options
  74413. * @param babylonScene Babylon scene object
  74414. * @param options Options to modify the behavior of the exporter
  74415. */
  74416. constructor(babylonScene: Scene, options?: IExportOptions);
  74417. dispose(): void;
  74418. /**
  74419. * Registers a glTF exporter extension
  74420. * @param name Name of the extension to export
  74421. * @param factory The factory function that creates the exporter extension
  74422. */
  74423. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  74424. /**
  74425. * Un-registers an exporter extension
  74426. * @param name The name fo the exporter extension
  74427. * @returns A boolean indicating whether the extension has been un-registered
  74428. */
  74429. static UnregisterExtension(name: string): boolean;
  74430. /**
  74431. * Lazy load a local engine
  74432. */
  74433. _getLocalEngine(): Engine;
  74434. private reorderIndicesBasedOnPrimitiveMode;
  74435. /**
  74436. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  74437. * clock-wise during export to glTF
  74438. * @param submesh BabylonJS submesh
  74439. * @param primitiveMode Primitive mode of the mesh
  74440. * @param sideOrientation the winding order of the submesh
  74441. * @param vertexBufferKind The type of vertex attribute
  74442. * @param meshAttributeArray The vertex attribute data
  74443. * @param byteOffset The offset to the binary data
  74444. * @param binaryWriter The binary data for the glTF file
  74445. */
  74446. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  74447. /**
  74448. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  74449. * clock-wise during export to glTF
  74450. * @param submesh BabylonJS submesh
  74451. * @param primitiveMode Primitive mode of the mesh
  74452. * @param sideOrientation the winding order of the submesh
  74453. * @param vertexBufferKind The type of vertex attribute
  74454. * @param meshAttributeArray The vertex attribute data
  74455. * @param byteOffset The offset to the binary data
  74456. * @param binaryWriter The binary data for the glTF file
  74457. */
  74458. private reorderTriangleFillMode;
  74459. /**
  74460. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  74461. * clock-wise during export to glTF
  74462. * @param submesh BabylonJS submesh
  74463. * @param primitiveMode Primitive mode of the mesh
  74464. * @param sideOrientation the winding order of the submesh
  74465. * @param vertexBufferKind The type of vertex attribute
  74466. * @param meshAttributeArray The vertex attribute data
  74467. * @param byteOffset The offset to the binary data
  74468. * @param binaryWriter The binary data for the glTF file
  74469. */
  74470. private reorderTriangleStripDrawMode;
  74471. /**
  74472. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  74473. * clock-wise during export to glTF
  74474. * @param submesh BabylonJS submesh
  74475. * @param primitiveMode Primitive mode of the mesh
  74476. * @param sideOrientation the winding order of the submesh
  74477. * @param vertexBufferKind The type of vertex attribute
  74478. * @param meshAttributeArray The vertex attribute data
  74479. * @param byteOffset The offset to the binary data
  74480. * @param binaryWriter The binary data for the glTF file
  74481. */
  74482. private reorderTriangleFanMode;
  74483. /**
  74484. * Writes the vertex attribute data to binary
  74485. * @param vertices The vertices to write to the binary writer
  74486. * @param byteOffset The offset into the binary writer to overwrite binary data
  74487. * @param vertexAttributeKind The vertex attribute type
  74488. * @param meshAttributeArray The vertex attribute data
  74489. * @param binaryWriter The writer containing the binary data
  74490. */
  74491. private writeVertexAttributeData;
  74492. /**
  74493. * Writes mesh attribute data to a data buffer
  74494. * Returns the bytelength of the data
  74495. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  74496. * @param meshAttributeArray Array containing the attribute data
  74497. * @param binaryWriter The buffer to write the binary data to
  74498. * @param indices Used to specify the order of the vertex data
  74499. */
  74500. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  74501. /**
  74502. * Generates glTF json data
  74503. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  74504. * @param glTFPrefix Text to use when prefixing a glTF file
  74505. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  74506. * @returns json data as string
  74507. */
  74508. private generateJSON;
  74509. /**
  74510. * Generates data for .gltf and .bin files based on the glTF prefix string
  74511. * @param glTFPrefix Text to use when prefixing a glTF file
  74512. * @param dispose Dispose the exporter
  74513. * @returns GLTFData with glTF file data
  74514. */
  74515. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74516. /**
  74517. * Creates a binary buffer for glTF
  74518. * @returns array buffer for binary data
  74519. */
  74520. private _generateBinaryAsync;
  74521. /**
  74522. * Pads the number to a multiple of 4
  74523. * @param num number to pad
  74524. * @returns padded number
  74525. */
  74526. private _getPadding;
  74527. /**
  74528. * @hidden
  74529. */
  74530. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74531. /**
  74532. * Sets the TRS for each node
  74533. * @param node glTF Node for storing the transformation data
  74534. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  74535. */
  74536. private setNodeTransformation;
  74537. private getVertexBufferFromMesh;
  74538. /**
  74539. * Creates a bufferview based on the vertices type for the Babylon mesh
  74540. * @param kind Indicates the type of vertices data
  74541. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  74542. * @param binaryWriter The buffer to write the bufferview data to
  74543. */
  74544. private createBufferViewKind;
  74545. /**
  74546. * The primitive mode of the Babylon mesh
  74547. * @param babylonMesh The BabylonJS mesh
  74548. */
  74549. private getMeshPrimitiveMode;
  74550. /**
  74551. * Sets the primitive mode of the glTF mesh primitive
  74552. * @param meshPrimitive glTF mesh primitive
  74553. * @param primitiveMode The primitive mode
  74554. */
  74555. private setPrimitiveMode;
  74556. /**
  74557. * Sets the vertex attribute accessor based of the glTF mesh primitive
  74558. * @param meshPrimitive glTF mesh primitive
  74559. * @param attributeKind vertex attribute
  74560. * @returns boolean specifying if uv coordinates are present
  74561. */
  74562. private setAttributeKind;
  74563. /**
  74564. * Sets data for the primitive attributes of each submesh
  74565. * @param mesh glTF Mesh object to store the primitive attribute information
  74566. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  74567. * @param binaryWriter Buffer to write the attribute data to
  74568. */
  74569. private setPrimitiveAttributesAsync;
  74570. /**
  74571. * Creates a glTF scene based on the array of meshes
  74572. * Returns the the total byte offset
  74573. * @param babylonScene Babylon scene to get the mesh data from
  74574. * @param binaryWriter Buffer to write binary data to
  74575. */
  74576. private createSceneAsync;
  74577. /**
  74578. * Creates a mapping of Node unique id to node index and handles animations
  74579. * @param babylonScene Babylon Scene
  74580. * @param nodes Babylon transform nodes
  74581. * @param binaryWriter Buffer to write binary data to
  74582. * @returns Node mapping of unique id to index
  74583. */
  74584. private createNodeMapAndAnimationsAsync;
  74585. /**
  74586. * Creates a glTF node from a Babylon mesh
  74587. * @param babylonMesh Source Babylon mesh
  74588. * @param binaryWriter Buffer for storing geometry data
  74589. * @returns glTF node
  74590. */
  74591. private createNodeAsync;
  74592. }
  74593. /**
  74594. * @hidden
  74595. *
  74596. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  74597. */
  74598. export class _BinaryWriter {
  74599. /**
  74600. * Array buffer which stores all binary data
  74601. */
  74602. private _arrayBuffer;
  74603. /**
  74604. * View of the array buffer
  74605. */
  74606. private _dataView;
  74607. /**
  74608. * byte offset of data in array buffer
  74609. */
  74610. private _byteOffset;
  74611. /**
  74612. * Initialize binary writer with an initial byte length
  74613. * @param byteLength Initial byte length of the array buffer
  74614. */
  74615. constructor(byteLength: number);
  74616. /**
  74617. * Resize the array buffer to the specified byte length
  74618. * @param byteLength
  74619. */
  74620. private resizeBuffer;
  74621. /**
  74622. * Get an array buffer with the length of the byte offset
  74623. * @returns ArrayBuffer resized to the byte offset
  74624. */
  74625. getArrayBuffer(): ArrayBuffer;
  74626. /**
  74627. * Get the byte offset of the array buffer
  74628. * @returns byte offset
  74629. */
  74630. getByteOffset(): number;
  74631. /**
  74632. * Stores an UInt8 in the array buffer
  74633. * @param entry
  74634. * @param byteOffset If defined, specifies where to set the value as an offset.
  74635. */
  74636. setUInt8(entry: number, byteOffset?: number): void;
  74637. /**
  74638. * Gets an UInt32 in the array buffer
  74639. * @param entry
  74640. * @param byteOffset If defined, specifies where to set the value as an offset.
  74641. */
  74642. getUInt32(byteOffset: number): number;
  74643. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74644. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74645. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74646. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74647. /**
  74648. * Stores a Float32 in the array buffer
  74649. * @param entry
  74650. */
  74651. setFloat32(entry: number, byteOffset?: number): void;
  74652. /**
  74653. * Stores an UInt32 in the array buffer
  74654. * @param entry
  74655. * @param byteOffset If defined, specifies where to set the value as an offset.
  74656. */
  74657. setUInt32(entry: number, byteOffset?: number): void;
  74658. }
  74659. }
  74660. declare module BABYLON.GLTF2.Exporter {
  74661. /**
  74662. * @hidden
  74663. * Interface to store animation data.
  74664. */
  74665. export interface _IAnimationData {
  74666. /**
  74667. * Keyframe data.
  74668. */
  74669. inputs: number[];
  74670. /**
  74671. * Value data.
  74672. */
  74673. outputs: number[][];
  74674. /**
  74675. * Animation interpolation data.
  74676. */
  74677. samplerInterpolation: AnimationSamplerInterpolation;
  74678. /**
  74679. * Minimum keyframe value.
  74680. */
  74681. inputsMin: number;
  74682. /**
  74683. * Maximum keyframe value.
  74684. */
  74685. inputsMax: number;
  74686. }
  74687. /**
  74688. * @hidden
  74689. */
  74690. export interface _IAnimationInfo {
  74691. /**
  74692. * The target channel for the animation
  74693. */
  74694. animationChannelTargetPath: AnimationChannelTargetPath;
  74695. /**
  74696. * The glTF accessor type for the data.
  74697. */
  74698. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  74699. /**
  74700. * Specifies if quaternions should be used.
  74701. */
  74702. useQuaternion: boolean;
  74703. }
  74704. /**
  74705. * @hidden
  74706. * Utility class for generating glTF animation data from BabylonJS.
  74707. */
  74708. export class _GLTFAnimation {
  74709. /**
  74710. * @ignore
  74711. *
  74712. * Creates glTF channel animation from BabylonJS animation.
  74713. * @param babylonTransformNode - BabylonJS mesh.
  74714. * @param animation - animation.
  74715. * @param animationChannelTargetPath - The target animation channel.
  74716. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  74717. * @param useQuaternion - Specifies if quaternions are used.
  74718. * @returns nullable IAnimationData
  74719. */
  74720. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  74721. private static _DeduceAnimationInfo;
  74722. /**
  74723. * @ignore
  74724. * Create node animations from the transform node animations
  74725. * @param babylonNode
  74726. * @param runtimeGLTFAnimation
  74727. * @param idleGLTFAnimations
  74728. * @param nodeMap
  74729. * @param nodes
  74730. * @param binaryWriter
  74731. * @param bufferViews
  74732. * @param accessors
  74733. * @param convertToRightHandedSystem
  74734. */
  74735. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  74736. [key: number]: number;
  74737. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74738. /**
  74739. * @ignore
  74740. * Create node animations from the animation groups
  74741. * @param babylonScene
  74742. * @param glTFAnimations
  74743. * @param nodeMap
  74744. * @param nodes
  74745. * @param binaryWriter
  74746. * @param bufferViews
  74747. * @param accessors
  74748. * @param convertToRightHandedSystem
  74749. */
  74750. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  74751. [key: number]: number;
  74752. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74753. private static AddAnimation;
  74754. /**
  74755. * Create a baked animation
  74756. * @param babylonTransformNode BabylonJS mesh
  74757. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  74758. * @param animationChannelTargetPath animation target channel
  74759. * @param minFrame minimum animation frame
  74760. * @param maxFrame maximum animation frame
  74761. * @param fps frames per second of the animation
  74762. * @param inputs input key frames of the animation
  74763. * @param outputs output key frame data of the animation
  74764. * @param convertToRightHandedSystem converts the values to right-handed
  74765. * @param useQuaternion specifies if quaternions should be used
  74766. */
  74767. private static _CreateBakedAnimation;
  74768. private static _ConvertFactorToVector3OrQuaternion;
  74769. private static _SetInterpolatedValue;
  74770. /**
  74771. * Creates linear animation from the animation key frames
  74772. * @param babylonTransformNode BabylonJS mesh
  74773. * @param animation BabylonJS animation
  74774. * @param animationChannelTargetPath The target animation channel
  74775. * @param frameDelta The difference between the last and first frame of the animation
  74776. * @param inputs Array to store the key frame times
  74777. * @param outputs Array to store the key frame data
  74778. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74779. * @param useQuaternion Specifies if quaternions are used in the animation
  74780. */
  74781. private static _CreateLinearOrStepAnimation;
  74782. /**
  74783. * Creates cubic spline animation from the animation key frames
  74784. * @param babylonTransformNode BabylonJS mesh
  74785. * @param animation BabylonJS animation
  74786. * @param animationChannelTargetPath The target animation channel
  74787. * @param frameDelta The difference between the last and first frame of the animation
  74788. * @param inputs Array to store the key frame times
  74789. * @param outputs Array to store the key frame data
  74790. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74791. * @param useQuaternion Specifies if quaternions are used in the animation
  74792. */
  74793. private static _CreateCubicSplineAnimation;
  74794. private static _GetBasePositionRotationOrScale;
  74795. /**
  74796. * Adds a key frame value
  74797. * @param keyFrame
  74798. * @param animation
  74799. * @param outputs
  74800. * @param animationChannelTargetPath
  74801. * @param basePositionRotationOrScale
  74802. * @param convertToRightHandedSystem
  74803. * @param useQuaternion
  74804. */
  74805. private static _AddKeyframeValue;
  74806. /**
  74807. * Determine the interpolation based on the key frames
  74808. * @param keyFrames
  74809. * @param animationChannelTargetPath
  74810. * @param useQuaternion
  74811. */
  74812. private static _DeduceInterpolation;
  74813. /**
  74814. * Adds an input tangent or output tangent to the output data
  74815. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  74816. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  74817. * @param outputs The animation data by keyframe
  74818. * @param animationChannelTargetPath The target animation channel
  74819. * @param interpolation The interpolation type
  74820. * @param keyFrame The key frame with the animation data
  74821. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  74822. * @param useQuaternion Specifies if quaternions are used
  74823. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  74824. */
  74825. private static AddSplineTangent;
  74826. /**
  74827. * Get the minimum and maximum key frames' frame values
  74828. * @param keyFrames animation key frames
  74829. * @returns the minimum and maximum key frame value
  74830. */
  74831. private static calculateMinMaxKeyFrames;
  74832. }
  74833. }
  74834. declare module BABYLON.GLTF2.Exporter {
  74835. /** @hidden */
  74836. export var textureTransformPixelShader: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module BABYLON.GLTF2.Exporter.Extensions {
  74842. /**
  74843. * @hidden
  74844. */
  74845. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  74846. private _recordedTextures;
  74847. /** Name of this extension */
  74848. readonly name: string;
  74849. /** Defines whether this extension is enabled */
  74850. enabled: boolean;
  74851. /** Defines whether this extension is required */
  74852. required: boolean;
  74853. /** Reference to the glTF exporter */
  74854. private _wasUsed;
  74855. constructor(exporter: _Exporter);
  74856. dispose(): void;
  74857. /** @hidden */
  74858. get wasUsed(): boolean;
  74859. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74860. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74861. /**
  74862. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  74863. * @param babylonTexture
  74864. * @param offset
  74865. * @param rotation
  74866. * @param scale
  74867. * @param scene
  74868. */
  74869. private _textureTransformTextureAsync;
  74870. }
  74871. }
  74872. declare module BABYLON.GLTF2.Exporter.Extensions {
  74873. /**
  74874. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74875. */
  74876. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  74877. /** The name of this extension. */
  74878. readonly name: string;
  74879. /** Defines whether this extension is enabled. */
  74880. enabled: boolean;
  74881. /** Defines whether this extension is required */
  74882. required: boolean;
  74883. /** Reference to the glTF exporter */
  74884. private _exporter;
  74885. private _lights;
  74886. /** @hidden */
  74887. constructor(exporter: _Exporter);
  74888. /** @hidden */
  74889. dispose(): void;
  74890. /** @hidden */
  74891. get wasUsed(): boolean;
  74892. /** @hidden */
  74893. onExporting(): void;
  74894. /**
  74895. * Define this method to modify the default behavior when exporting a node
  74896. * @param context The context when exporting the node
  74897. * @param node glTF node
  74898. * @param babylonNode BabylonJS node
  74899. * @returns nullable INode promise
  74900. */
  74901. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74902. }
  74903. }
  74904. declare module BABYLON.GLTF2.Exporter.Extensions {
  74905. /**
  74906. * @hidden
  74907. */
  74908. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  74909. /** Name of this extension */
  74910. readonly name: string;
  74911. /** Defines whether this extension is enabled */
  74912. enabled: boolean;
  74913. /** Defines whether this extension is required */
  74914. required: boolean;
  74915. /** Reference to the glTF exporter */
  74916. private _textureInfos;
  74917. private _exportedTextures;
  74918. private _wasUsed;
  74919. constructor(exporter: _Exporter);
  74920. dispose(): void;
  74921. /** @hidden */
  74922. get wasUsed(): boolean;
  74923. private _getTextureIndex;
  74924. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74925. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74926. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74927. }
  74928. }
  74929. declare module BABYLON {
  74930. /**
  74931. * Class for generating STL data from a Babylon scene.
  74932. */
  74933. export class STLExport {
  74934. /**
  74935. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  74936. * @param meshes list defines the mesh to serialize
  74937. * @param download triggers the automatic download of the file.
  74938. * @param fileName changes the downloads fileName.
  74939. * @param binary changes the STL to a binary type.
  74940. * @param isLittleEndian toggle for binary type exporter.
  74941. * @returns the STL as UTF8 string
  74942. */
  74943. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  74944. }
  74945. }
  74946. declare module "babylonjs-gltf2interface" {
  74947. export = BABYLON.GLTF2;
  74948. }
  74949. /**
  74950. * Module for glTF 2.0 Interface
  74951. */
  74952. declare module BABYLON.GLTF2 {
  74953. /**
  74954. * The datatype of the components in the attribute
  74955. */
  74956. const enum AccessorComponentType {
  74957. /**
  74958. * Byte
  74959. */
  74960. BYTE = 5120,
  74961. /**
  74962. * Unsigned Byte
  74963. */
  74964. UNSIGNED_BYTE = 5121,
  74965. /**
  74966. * Short
  74967. */
  74968. SHORT = 5122,
  74969. /**
  74970. * Unsigned Short
  74971. */
  74972. UNSIGNED_SHORT = 5123,
  74973. /**
  74974. * Unsigned Int
  74975. */
  74976. UNSIGNED_INT = 5125,
  74977. /**
  74978. * Float
  74979. */
  74980. FLOAT = 5126,
  74981. }
  74982. /**
  74983. * Specifies if the attirbute is a scalar, vector, or matrix
  74984. */
  74985. const enum AccessorType {
  74986. /**
  74987. * Scalar
  74988. */
  74989. SCALAR = "SCALAR",
  74990. /**
  74991. * Vector2
  74992. */
  74993. VEC2 = "VEC2",
  74994. /**
  74995. * Vector3
  74996. */
  74997. VEC3 = "VEC3",
  74998. /**
  74999. * Vector4
  75000. */
  75001. VEC4 = "VEC4",
  75002. /**
  75003. * Matrix2x2
  75004. */
  75005. MAT2 = "MAT2",
  75006. /**
  75007. * Matrix3x3
  75008. */
  75009. MAT3 = "MAT3",
  75010. /**
  75011. * Matrix4x4
  75012. */
  75013. MAT4 = "MAT4",
  75014. }
  75015. /**
  75016. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75017. */
  75018. const enum AnimationChannelTargetPath {
  75019. /**
  75020. * Translation
  75021. */
  75022. TRANSLATION = "translation",
  75023. /**
  75024. * Rotation
  75025. */
  75026. ROTATION = "rotation",
  75027. /**
  75028. * Scale
  75029. */
  75030. SCALE = "scale",
  75031. /**
  75032. * Weights
  75033. */
  75034. WEIGHTS = "weights",
  75035. }
  75036. /**
  75037. * Interpolation algorithm
  75038. */
  75039. const enum AnimationSamplerInterpolation {
  75040. /**
  75041. * The animated values are linearly interpolated between keyframes
  75042. */
  75043. LINEAR = "LINEAR",
  75044. /**
  75045. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  75046. */
  75047. STEP = "STEP",
  75048. /**
  75049. * The animation's interpolation is computed using a cubic spline with specified tangents
  75050. */
  75051. CUBICSPLINE = "CUBICSPLINE",
  75052. }
  75053. /**
  75054. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75055. */
  75056. const enum CameraType {
  75057. /**
  75058. * A perspective camera containing properties to create a perspective projection matrix
  75059. */
  75060. PERSPECTIVE = "perspective",
  75061. /**
  75062. * An orthographic camera containing properties to create an orthographic projection matrix
  75063. */
  75064. ORTHOGRAPHIC = "orthographic",
  75065. }
  75066. /**
  75067. * The mime-type of the image
  75068. */
  75069. const enum ImageMimeType {
  75070. /**
  75071. * JPEG Mime-type
  75072. */
  75073. JPEG = "image/jpeg",
  75074. /**
  75075. * PNG Mime-type
  75076. */
  75077. PNG = "image/png",
  75078. }
  75079. /**
  75080. * The alpha rendering mode of the material
  75081. */
  75082. const enum MaterialAlphaMode {
  75083. /**
  75084. * The alpha value is ignored and the rendered output is fully opaque
  75085. */
  75086. OPAQUE = "OPAQUE",
  75087. /**
  75088. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  75089. */
  75090. MASK = "MASK",
  75091. /**
  75092. * 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)
  75093. */
  75094. BLEND = "BLEND",
  75095. }
  75096. /**
  75097. * The type of the primitives to render
  75098. */
  75099. const enum MeshPrimitiveMode {
  75100. /**
  75101. * Points
  75102. */
  75103. POINTS = 0,
  75104. /**
  75105. * Lines
  75106. */
  75107. LINES = 1,
  75108. /**
  75109. * Line Loop
  75110. */
  75111. LINE_LOOP = 2,
  75112. /**
  75113. * Line Strip
  75114. */
  75115. LINE_STRIP = 3,
  75116. /**
  75117. * Triangles
  75118. */
  75119. TRIANGLES = 4,
  75120. /**
  75121. * Triangle Strip
  75122. */
  75123. TRIANGLE_STRIP = 5,
  75124. /**
  75125. * Triangle Fan
  75126. */
  75127. TRIANGLE_FAN = 6,
  75128. }
  75129. /**
  75130. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75131. */
  75132. const enum TextureMagFilter {
  75133. /**
  75134. * Nearest
  75135. */
  75136. NEAREST = 9728,
  75137. /**
  75138. * Linear
  75139. */
  75140. LINEAR = 9729,
  75141. }
  75142. /**
  75143. * Minification filter. All valid values correspond to WebGL enums
  75144. */
  75145. const enum TextureMinFilter {
  75146. /**
  75147. * Nearest
  75148. */
  75149. NEAREST = 9728,
  75150. /**
  75151. * Linear
  75152. */
  75153. LINEAR = 9729,
  75154. /**
  75155. * Nearest Mip-Map Nearest
  75156. */
  75157. NEAREST_MIPMAP_NEAREST = 9984,
  75158. /**
  75159. * Linear Mipmap Nearest
  75160. */
  75161. LINEAR_MIPMAP_NEAREST = 9985,
  75162. /**
  75163. * Nearest Mipmap Linear
  75164. */
  75165. NEAREST_MIPMAP_LINEAR = 9986,
  75166. /**
  75167. * Linear Mipmap Linear
  75168. */
  75169. LINEAR_MIPMAP_LINEAR = 9987,
  75170. }
  75171. /**
  75172. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75173. */
  75174. const enum TextureWrapMode {
  75175. /**
  75176. * Clamp to Edge
  75177. */
  75178. CLAMP_TO_EDGE = 33071,
  75179. /**
  75180. * Mirrored Repeat
  75181. */
  75182. MIRRORED_REPEAT = 33648,
  75183. /**
  75184. * Repeat
  75185. */
  75186. REPEAT = 10497,
  75187. }
  75188. /**
  75189. * glTF Property
  75190. */
  75191. interface IProperty {
  75192. /**
  75193. * Dictionary object with extension-specific objects
  75194. */
  75195. extensions?: {
  75196. [key: string]: any;
  75197. };
  75198. /**
  75199. * Application-Specific data
  75200. */
  75201. extras?: any;
  75202. }
  75203. /**
  75204. * glTF Child of Root Property
  75205. */
  75206. interface IChildRootProperty extends IProperty {
  75207. /**
  75208. * The user-defined name of this object
  75209. */
  75210. name?: string;
  75211. }
  75212. /**
  75213. * Indices of those attributes that deviate from their initialization value
  75214. */
  75215. interface IAccessorSparseIndices extends IProperty {
  75216. /**
  75217. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75218. */
  75219. bufferView: number;
  75220. /**
  75221. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75222. */
  75223. byteOffset?: number;
  75224. /**
  75225. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75226. */
  75227. componentType: AccessorComponentType;
  75228. }
  75229. /**
  75230. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75231. */
  75232. interface IAccessorSparseValues extends IProperty {
  75233. /**
  75234. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75235. */
  75236. bufferView: number;
  75237. /**
  75238. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75239. */
  75240. byteOffset?: number;
  75241. }
  75242. /**
  75243. * Sparse storage of attributes that deviate from their initialization value
  75244. */
  75245. interface IAccessorSparse extends IProperty {
  75246. /**
  75247. * The number of attributes encoded in this sparse accessor
  75248. */
  75249. count: number;
  75250. /**
  75251. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75252. */
  75253. indices: IAccessorSparseIndices;
  75254. /**
  75255. * 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
  75256. */
  75257. values: IAccessorSparseValues;
  75258. }
  75259. /**
  75260. * 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
  75261. */
  75262. interface IAccessor extends IChildRootProperty {
  75263. /**
  75264. * The index of the bufferview
  75265. */
  75266. bufferView?: number;
  75267. /**
  75268. * The offset relative to the start of the bufferView in bytes
  75269. */
  75270. byteOffset?: number;
  75271. /**
  75272. * The datatype of components in the attribute
  75273. */
  75274. componentType: AccessorComponentType;
  75275. /**
  75276. * Specifies whether integer data values should be normalized
  75277. */
  75278. normalized?: boolean;
  75279. /**
  75280. * The number of attributes referenced by this accessor
  75281. */
  75282. count: number;
  75283. /**
  75284. * Specifies if the attribute is a scalar, vector, or matrix
  75285. */
  75286. type: AccessorType;
  75287. /**
  75288. * Maximum value of each component in this attribute
  75289. */
  75290. max?: number[];
  75291. /**
  75292. * Minimum value of each component in this attribute
  75293. */
  75294. min?: number[];
  75295. /**
  75296. * Sparse storage of attributes that deviate from their initialization value
  75297. */
  75298. sparse?: IAccessorSparse;
  75299. }
  75300. /**
  75301. * Targets an animation's sampler at a node's property
  75302. */
  75303. interface IAnimationChannel extends IProperty {
  75304. /**
  75305. * The index of a sampler in this animation used to compute the value for the target
  75306. */
  75307. sampler: number;
  75308. /**
  75309. * The index of the node and TRS property to target
  75310. */
  75311. target: IAnimationChannelTarget;
  75312. }
  75313. /**
  75314. * The index of the node and TRS property that an animation channel targets
  75315. */
  75316. interface IAnimationChannelTarget extends IProperty {
  75317. /**
  75318. * The index of the node to target
  75319. */
  75320. node: number;
  75321. /**
  75322. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75323. */
  75324. path: AnimationChannelTargetPath;
  75325. }
  75326. /**
  75327. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75328. */
  75329. interface IAnimationSampler extends IProperty {
  75330. /**
  75331. * The index of an accessor containing keyframe input values, e.g., time
  75332. */
  75333. input: number;
  75334. /**
  75335. * Interpolation algorithm
  75336. */
  75337. interpolation?: AnimationSamplerInterpolation;
  75338. /**
  75339. * The index of an accessor, containing keyframe output values
  75340. */
  75341. output: number;
  75342. }
  75343. /**
  75344. * A keyframe animation
  75345. */
  75346. interface IAnimation extends IChildRootProperty {
  75347. /**
  75348. * An array of channels, each of which targets an animation's sampler at a node's property
  75349. */
  75350. channels: IAnimationChannel[];
  75351. /**
  75352. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75353. */
  75354. samplers: IAnimationSampler[];
  75355. }
  75356. /**
  75357. * Metadata about the glTF asset
  75358. */
  75359. interface IAsset extends IChildRootProperty {
  75360. /**
  75361. * A copyright message suitable for display to credit the content creator
  75362. */
  75363. copyright?: string;
  75364. /**
  75365. * Tool that generated this glTF model. Useful for debugging
  75366. */
  75367. generator?: string;
  75368. /**
  75369. * The glTF version that this asset targets
  75370. */
  75371. version: string;
  75372. /**
  75373. * The minimum glTF version that this asset targets
  75374. */
  75375. minVersion?: string;
  75376. }
  75377. /**
  75378. * A buffer points to binary geometry, animation, or skins
  75379. */
  75380. interface IBuffer extends IChildRootProperty {
  75381. /**
  75382. * 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
  75383. */
  75384. uri?: string;
  75385. /**
  75386. * The length of the buffer in bytes
  75387. */
  75388. byteLength: number;
  75389. }
  75390. /**
  75391. * A view into a buffer generally representing a subset of the buffer
  75392. */
  75393. interface IBufferView extends IChildRootProperty {
  75394. /**
  75395. * The index of the buffer
  75396. */
  75397. buffer: number;
  75398. /**
  75399. * The offset into the buffer in bytes
  75400. */
  75401. byteOffset?: number;
  75402. /**
  75403. * The lenth of the bufferView in bytes
  75404. */
  75405. byteLength: number;
  75406. /**
  75407. * The stride, in bytes
  75408. */
  75409. byteStride?: number;
  75410. }
  75411. /**
  75412. * An orthographic camera containing properties to create an orthographic projection matrix
  75413. */
  75414. interface ICameraOrthographic extends IProperty {
  75415. /**
  75416. * The floating-point horizontal magnification of the view. Must not be zero
  75417. */
  75418. xmag: number;
  75419. /**
  75420. * The floating-point vertical magnification of the view. Must not be zero
  75421. */
  75422. ymag: number;
  75423. /**
  75424. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  75425. */
  75426. zfar: number;
  75427. /**
  75428. * The floating-point distance to the near clipping plane
  75429. */
  75430. znear: number;
  75431. }
  75432. /**
  75433. * A perspective camera containing properties to create a perspective projection matrix
  75434. */
  75435. interface ICameraPerspective extends IProperty {
  75436. /**
  75437. * The floating-point aspect ratio of the field of view
  75438. */
  75439. aspectRatio?: number;
  75440. /**
  75441. * The floating-point vertical field of view in radians
  75442. */
  75443. yfov: number;
  75444. /**
  75445. * The floating-point distance to the far clipping plane
  75446. */
  75447. zfar?: number;
  75448. /**
  75449. * The floating-point distance to the near clipping plane
  75450. */
  75451. znear: number;
  75452. }
  75453. /**
  75454. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75455. */
  75456. interface ICamera extends IChildRootProperty {
  75457. /**
  75458. * An orthographic camera containing properties to create an orthographic projection matrix
  75459. */
  75460. orthographic?: ICameraOrthographic;
  75461. /**
  75462. * A perspective camera containing properties to create a perspective projection matrix
  75463. */
  75464. perspective?: ICameraPerspective;
  75465. /**
  75466. * Specifies if the camera uses a perspective or orthographic projection
  75467. */
  75468. type: CameraType;
  75469. }
  75470. /**
  75471. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  75472. */
  75473. interface IImage extends IChildRootProperty {
  75474. /**
  75475. * 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
  75476. */
  75477. uri?: string;
  75478. /**
  75479. * The image's MIME type
  75480. */
  75481. mimeType?: ImageMimeType;
  75482. /**
  75483. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  75484. */
  75485. bufferView?: number;
  75486. }
  75487. /**
  75488. * Material Normal Texture Info
  75489. */
  75490. interface IMaterialNormalTextureInfo extends ITextureInfo {
  75491. /**
  75492. * The scalar multiplier applied to each normal vector of the normal texture
  75493. */
  75494. scale?: number;
  75495. }
  75496. /**
  75497. * Material Occlusion Texture Info
  75498. */
  75499. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  75500. /**
  75501. * A scalar multiplier controlling the amount of occlusion applied
  75502. */
  75503. strength?: number;
  75504. }
  75505. /**
  75506. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  75507. */
  75508. interface IMaterialPbrMetallicRoughness {
  75509. /**
  75510. * The material's base color factor
  75511. */
  75512. baseColorFactor?: number[];
  75513. /**
  75514. * The base color texture
  75515. */
  75516. baseColorTexture?: ITextureInfo;
  75517. /**
  75518. * The metalness of the material
  75519. */
  75520. metallicFactor?: number;
  75521. /**
  75522. * The roughness of the material
  75523. */
  75524. roughnessFactor?: number;
  75525. /**
  75526. * The metallic-roughness texture
  75527. */
  75528. metallicRoughnessTexture?: ITextureInfo;
  75529. }
  75530. /**
  75531. * The material appearance of a primitive
  75532. */
  75533. interface IMaterial extends IChildRootProperty {
  75534. /**
  75535. * 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
  75536. */
  75537. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75538. /**
  75539. * The normal map texture
  75540. */
  75541. normalTexture?: IMaterialNormalTextureInfo;
  75542. /**
  75543. * The occlusion map texture
  75544. */
  75545. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75546. /**
  75547. * The emissive map texture
  75548. */
  75549. emissiveTexture?: ITextureInfo;
  75550. /**
  75551. * 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
  75552. */
  75553. emissiveFactor?: number[];
  75554. /**
  75555. * The alpha rendering mode of the material
  75556. */
  75557. alphaMode?: MaterialAlphaMode;
  75558. /**
  75559. * The alpha cutoff value of the material
  75560. */
  75561. alphaCutoff?: number;
  75562. /**
  75563. * Specifies whether the material is double sided
  75564. */
  75565. doubleSided?: boolean;
  75566. }
  75567. /**
  75568. * Geometry to be rendered with the given material
  75569. */
  75570. interface IMeshPrimitive extends IProperty {
  75571. /**
  75572. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  75573. */
  75574. attributes: {
  75575. [name: string]: number;
  75576. };
  75577. /**
  75578. * The index of the accessor that contains the indices
  75579. */
  75580. indices?: number;
  75581. /**
  75582. * The index of the material to apply to this primitive when rendering
  75583. */
  75584. material?: number;
  75585. /**
  75586. * The type of primitives to render. All valid values correspond to WebGL enums
  75587. */
  75588. mode?: MeshPrimitiveMode;
  75589. /**
  75590. * 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
  75591. */
  75592. targets?: {
  75593. [name: string]: number;
  75594. }[];
  75595. }
  75596. /**
  75597. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  75598. */
  75599. interface IMesh extends IChildRootProperty {
  75600. /**
  75601. * An array of primitives, each defining geometry to be rendered with a material
  75602. */
  75603. primitives: IMeshPrimitive[];
  75604. /**
  75605. * Array of weights to be applied to the Morph Targets
  75606. */
  75607. weights?: number[];
  75608. }
  75609. /**
  75610. * A node in the node hierarchy
  75611. */
  75612. interface INode extends IChildRootProperty {
  75613. /**
  75614. * The index of the camera referenced by this node
  75615. */
  75616. camera?: number;
  75617. /**
  75618. * The indices of this node's children
  75619. */
  75620. children?: number[];
  75621. /**
  75622. * The index of the skin referenced by this node
  75623. */
  75624. skin?: number;
  75625. /**
  75626. * A floating-point 4x4 transformation matrix stored in column-major order
  75627. */
  75628. matrix?: number[];
  75629. /**
  75630. * The index of the mesh in this node
  75631. */
  75632. mesh?: number;
  75633. /**
  75634. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  75635. */
  75636. rotation?: number[];
  75637. /**
  75638. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  75639. */
  75640. scale?: number[];
  75641. /**
  75642. * The node's translation along the x, y, and z axes
  75643. */
  75644. translation?: number[];
  75645. /**
  75646. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  75647. */
  75648. weights?: number[];
  75649. }
  75650. /**
  75651. * Texture sampler properties for filtering and wrapping modes
  75652. */
  75653. interface ISampler extends IChildRootProperty {
  75654. /**
  75655. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75656. */
  75657. magFilter?: TextureMagFilter;
  75658. /**
  75659. * Minification filter. All valid values correspond to WebGL enums
  75660. */
  75661. minFilter?: TextureMinFilter;
  75662. /**
  75663. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75664. */
  75665. wrapS?: TextureWrapMode;
  75666. /**
  75667. * T (V) wrapping mode. All valid values correspond to WebGL enums
  75668. */
  75669. wrapT?: TextureWrapMode;
  75670. }
  75671. /**
  75672. * The root nodes of a scene
  75673. */
  75674. interface IScene extends IChildRootProperty {
  75675. /**
  75676. * The indices of each root node
  75677. */
  75678. nodes: number[];
  75679. }
  75680. /**
  75681. * Joints and matrices defining a skin
  75682. */
  75683. interface ISkin extends IChildRootProperty {
  75684. /**
  75685. * 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
  75686. */
  75687. inverseBindMatrices?: number;
  75688. /**
  75689. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  75690. */
  75691. skeleton?: number;
  75692. /**
  75693. * 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)
  75694. */
  75695. joints: number[];
  75696. }
  75697. /**
  75698. * A texture and its sampler
  75699. */
  75700. interface ITexture extends IChildRootProperty {
  75701. /**
  75702. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  75703. */
  75704. sampler?: number;
  75705. /**
  75706. * The index of the image used by this texture
  75707. */
  75708. source: number;
  75709. }
  75710. /**
  75711. * Reference to a texture
  75712. */
  75713. interface ITextureInfo extends IProperty {
  75714. /**
  75715. * The index of the texture
  75716. */
  75717. index: number;
  75718. /**
  75719. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  75720. */
  75721. texCoord?: number;
  75722. }
  75723. /**
  75724. * The root object for a glTF asset
  75725. */
  75726. interface IGLTF extends IProperty {
  75727. /**
  75728. * An array of accessors. An accessor is a typed view into a bufferView
  75729. */
  75730. accessors?: IAccessor[];
  75731. /**
  75732. * An array of keyframe animations
  75733. */
  75734. animations?: IAnimation[];
  75735. /**
  75736. * Metadata about the glTF asset
  75737. */
  75738. asset: IAsset;
  75739. /**
  75740. * An array of buffers. A buffer points to binary geometry, animation, or skins
  75741. */
  75742. buffers?: IBuffer[];
  75743. /**
  75744. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  75745. */
  75746. bufferViews?: IBufferView[];
  75747. /**
  75748. * An array of cameras
  75749. */
  75750. cameras?: ICamera[];
  75751. /**
  75752. * Names of glTF extensions used somewhere in this asset
  75753. */
  75754. extensionsUsed?: string[];
  75755. /**
  75756. * Names of glTF extensions required to properly load this asset
  75757. */
  75758. extensionsRequired?: string[];
  75759. /**
  75760. * An array of images. An image defines data used to create a texture
  75761. */
  75762. images?: IImage[];
  75763. /**
  75764. * An array of materials. A material defines the appearance of a primitive
  75765. */
  75766. materials?: IMaterial[];
  75767. /**
  75768. * An array of meshes. A mesh is a set of primitives to be rendered
  75769. */
  75770. meshes?: IMesh[];
  75771. /**
  75772. * An array of nodes
  75773. */
  75774. nodes?: INode[];
  75775. /**
  75776. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  75777. */
  75778. samplers?: ISampler[];
  75779. /**
  75780. * The index of the default scene
  75781. */
  75782. scene?: number;
  75783. /**
  75784. * An array of scenes
  75785. */
  75786. scenes?: IScene[];
  75787. /**
  75788. * An array of skins. A skin is defined by joints and matrices
  75789. */
  75790. skins?: ISkin[];
  75791. /**
  75792. * An array of textures
  75793. */
  75794. textures?: ITexture[];
  75795. }
  75796. /**
  75797. * The glTF validation results
  75798. * @ignore
  75799. */
  75800. interface IGLTFValidationResults {
  75801. info: {
  75802. generator: string;
  75803. hasAnimations: boolean;
  75804. hasDefaultScene: boolean;
  75805. hasMaterials: boolean;
  75806. hasMorphTargets: boolean;
  75807. hasSkins: boolean;
  75808. hasTextures: boolean;
  75809. maxAttributesUsed: number;
  75810. primitivesCount: number
  75811. };
  75812. issues: {
  75813. messages: Array<string>;
  75814. numErrors: number;
  75815. numHints: number;
  75816. numInfos: number;
  75817. numWarnings: number;
  75818. truncated: boolean
  75819. };
  75820. mimeType: string;
  75821. uri: string;
  75822. validatedAt: string;
  75823. validatorVersion: string;
  75824. }
  75825. /**
  75826. * The glTF validation options
  75827. */
  75828. interface IGLTFValidationOptions {
  75829. /** Uri to use */
  75830. uri?: string;
  75831. /** Function used to load external resources */
  75832. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  75833. /** Boolean indicating that we need to validate accessor data */
  75834. validateAccessorData?: boolean;
  75835. /** max number of issues allowed */
  75836. maxIssues?: number;
  75837. /** Ignored issues */
  75838. ignoredIssues?: Array<string>;
  75839. /** Value to override severy settings */
  75840. severityOverrides?: Object;
  75841. }
  75842. /**
  75843. * The glTF validator object
  75844. * @ignore
  75845. */
  75846. interface IGLTFValidator {
  75847. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75848. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75849. }
  75850. }
  75851. declare module BABYLON {
  75852. /** @hidden */
  75853. export var cellPixelShader: {
  75854. name: string;
  75855. shader: string;
  75856. };
  75857. }
  75858. declare module BABYLON {
  75859. /** @hidden */
  75860. export var cellVertexShader: {
  75861. name: string;
  75862. shader: string;
  75863. };
  75864. }
  75865. declare module BABYLON {
  75866. export class CellMaterial extends BABYLON.PushMaterial {
  75867. private _diffuseTexture;
  75868. diffuseTexture: BABYLON.BaseTexture;
  75869. diffuseColor: BABYLON.Color3;
  75870. _computeHighLevel: boolean;
  75871. computeHighLevel: boolean;
  75872. private _disableLighting;
  75873. disableLighting: boolean;
  75874. private _maxSimultaneousLights;
  75875. maxSimultaneousLights: number;
  75876. private _renderId;
  75877. constructor(name: string, scene: BABYLON.Scene);
  75878. needAlphaBlending(): boolean;
  75879. needAlphaTesting(): boolean;
  75880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75881. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75882. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75883. getAnimatables(): BABYLON.IAnimatable[];
  75884. getActiveTextures(): BABYLON.BaseTexture[];
  75885. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75886. dispose(forceDisposeEffect?: boolean): void;
  75887. getClassName(): string;
  75888. clone(name: string): CellMaterial;
  75889. serialize(): any;
  75890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  75891. }
  75892. }
  75893. declare module BABYLON {
  75894. export class CustomShaderStructure {
  75895. FragmentStore: string;
  75896. VertexStore: string;
  75897. constructor();
  75898. }
  75899. export class ShaderSpecialParts {
  75900. constructor();
  75901. Fragment_Begin: string;
  75902. Fragment_Definitions: string;
  75903. Fragment_MainBegin: string;
  75904. Fragment_Custom_Diffuse: string;
  75905. Fragment_Before_Lights: string;
  75906. Fragment_Before_Fog: string;
  75907. Fragment_Custom_Alpha: string;
  75908. Fragment_Before_FragColor: string;
  75909. Vertex_Begin: string;
  75910. Vertex_Definitions: string;
  75911. Vertex_MainBegin: string;
  75912. Vertex_Before_PositionUpdated: string;
  75913. Vertex_Before_NormalUpdated: string;
  75914. Vertex_MainEnd: string;
  75915. }
  75916. export class CustomMaterial extends BABYLON.StandardMaterial {
  75917. static ShaderIndexer: number;
  75918. CustomParts: ShaderSpecialParts;
  75919. _isCreatedShader: boolean;
  75920. _createdShaderName: string;
  75921. _customUniform: string[];
  75922. _newUniforms: string[];
  75923. _newUniformInstances: any[];
  75924. _newSamplerInstances: BABYLON.Texture[];
  75925. FragmentShader: string;
  75926. VertexShader: string;
  75927. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75928. ReviewUniform(name: string, arr: string[]): string[];
  75929. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  75930. constructor(name: string, scene: BABYLON.Scene);
  75931. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  75932. Fragment_Begin(shaderPart: string): CustomMaterial;
  75933. Fragment_Definitions(shaderPart: string): CustomMaterial;
  75934. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  75935. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  75936. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  75937. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  75938. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  75939. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  75940. Vertex_Begin(shaderPart: string): CustomMaterial;
  75941. Vertex_Definitions(shaderPart: string): CustomMaterial;
  75942. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  75943. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  75944. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  75945. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75946. }
  75947. }
  75948. declare module BABYLON {
  75949. export class ShaderAlebdoParts {
  75950. constructor();
  75951. Fragment_Begin: string;
  75952. Fragment_Definitions: string;
  75953. Fragment_MainBegin: string;
  75954. Fragment_Custom_Albedo: string;
  75955. Fragment_Before_Lights: string;
  75956. Fragment_Custom_MetallicRoughness: string;
  75957. Fragment_Custom_MicroSurface: string;
  75958. Fragment_Before_Fog: string;
  75959. Fragment_Custom_Alpha: string;
  75960. Fragment_Before_FragColor: string;
  75961. Vertex_Begin: string;
  75962. Vertex_Definitions: string;
  75963. Vertex_MainBegin: string;
  75964. Vertex_Before_PositionUpdated: string;
  75965. Vertex_Before_NormalUpdated: string;
  75966. Vertex_MainEnd: string;
  75967. }
  75968. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75969. static ShaderIndexer: number;
  75970. CustomParts: ShaderAlebdoParts;
  75971. _isCreatedShader: boolean;
  75972. _createdShaderName: string;
  75973. _customUniform: string[];
  75974. _newUniforms: string[];
  75975. _newUniformInstances: any[];
  75976. _newSamplerInstances: BABYLON.Texture[];
  75977. FragmentShader: string;
  75978. VertexShader: string;
  75979. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75980. ReviewUniform(name: string, arr: string[]): string[];
  75981. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75982. constructor(name: string, scene: BABYLON.Scene);
  75983. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75984. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75985. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75986. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75987. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75988. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75989. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75990. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75991. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75992. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75993. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75994. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75995. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75996. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75997. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75998. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75999. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  76000. }
  76001. }
  76002. declare module BABYLON {
  76003. /** @hidden */
  76004. export var firePixelShader: {
  76005. name: string;
  76006. shader: string;
  76007. };
  76008. }
  76009. declare module BABYLON {
  76010. /** @hidden */
  76011. export var fireVertexShader: {
  76012. name: string;
  76013. shader: string;
  76014. };
  76015. }
  76016. declare module BABYLON {
  76017. export class FireMaterial extends BABYLON.PushMaterial {
  76018. private _diffuseTexture;
  76019. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76020. private _distortionTexture;
  76021. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76022. private _opacityTexture;
  76023. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76024. diffuseColor: BABYLON.Color3;
  76025. speed: number;
  76026. private _scaledDiffuse;
  76027. private _renderId;
  76028. private _lastTime;
  76029. constructor(name: string, scene: BABYLON.Scene);
  76030. needAlphaBlending(): boolean;
  76031. needAlphaTesting(): boolean;
  76032. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76033. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76034. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76035. getAnimatables(): BABYLON.IAnimatable[];
  76036. getActiveTextures(): BABYLON.BaseTexture[];
  76037. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76038. getClassName(): string;
  76039. dispose(forceDisposeEffect?: boolean): void;
  76040. clone(name: string): FireMaterial;
  76041. serialize(): any;
  76042. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  76043. }
  76044. }
  76045. declare module BABYLON {
  76046. /** @hidden */
  76047. export var furPixelShader: {
  76048. name: string;
  76049. shader: string;
  76050. };
  76051. }
  76052. declare module BABYLON {
  76053. /** @hidden */
  76054. export var furVertexShader: {
  76055. name: string;
  76056. shader: string;
  76057. };
  76058. }
  76059. declare module BABYLON {
  76060. export class FurMaterial extends BABYLON.PushMaterial {
  76061. private _diffuseTexture;
  76062. diffuseTexture: BABYLON.BaseTexture;
  76063. private _heightTexture;
  76064. heightTexture: BABYLON.BaseTexture;
  76065. diffuseColor: BABYLON.Color3;
  76066. furLength: number;
  76067. furAngle: number;
  76068. furColor: BABYLON.Color3;
  76069. furOffset: number;
  76070. furSpacing: number;
  76071. furGravity: BABYLON.Vector3;
  76072. furSpeed: number;
  76073. furDensity: number;
  76074. furOcclusion: number;
  76075. furTexture: BABYLON.DynamicTexture;
  76076. private _disableLighting;
  76077. disableLighting: boolean;
  76078. private _maxSimultaneousLights;
  76079. maxSimultaneousLights: number;
  76080. highLevelFur: boolean;
  76081. _meshes: BABYLON.AbstractMesh[];
  76082. private _renderId;
  76083. private _furTime;
  76084. constructor(name: string, scene: BABYLON.Scene);
  76085. get furTime(): number;
  76086. set furTime(furTime: number);
  76087. needAlphaBlending(): boolean;
  76088. needAlphaTesting(): boolean;
  76089. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76090. updateFur(): void;
  76091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76093. getAnimatables(): BABYLON.IAnimatable[];
  76094. getActiveTextures(): BABYLON.BaseTexture[];
  76095. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76096. dispose(forceDisposeEffect?: boolean): void;
  76097. clone(name: string): FurMaterial;
  76098. serialize(): any;
  76099. getClassName(): string;
  76100. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  76101. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  76102. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  76103. }
  76104. }
  76105. declare module BABYLON {
  76106. /** @hidden */
  76107. export var gradientPixelShader: {
  76108. name: string;
  76109. shader: string;
  76110. };
  76111. }
  76112. declare module BABYLON {
  76113. /** @hidden */
  76114. export var gradientVertexShader: {
  76115. name: string;
  76116. shader: string;
  76117. };
  76118. }
  76119. declare module BABYLON {
  76120. export class GradientMaterial extends BABYLON.PushMaterial {
  76121. private _maxSimultaneousLights;
  76122. maxSimultaneousLights: number;
  76123. topColor: BABYLON.Color3;
  76124. topColorAlpha: number;
  76125. bottomColor: BABYLON.Color3;
  76126. bottomColorAlpha: number;
  76127. offset: number;
  76128. scale: number;
  76129. smoothness: number;
  76130. private _disableLighting;
  76131. disableLighting: boolean;
  76132. private _renderId;
  76133. constructor(name: string, scene: BABYLON.Scene);
  76134. needAlphaBlending(): boolean;
  76135. needAlphaTesting(): boolean;
  76136. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76137. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76138. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76139. getAnimatables(): BABYLON.IAnimatable[];
  76140. dispose(forceDisposeEffect?: boolean): void;
  76141. clone(name: string): GradientMaterial;
  76142. serialize(): any;
  76143. getClassName(): string;
  76144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76145. }
  76146. }
  76147. declare module BABYLON {
  76148. /** @hidden */
  76149. export var gridPixelShader: {
  76150. name: string;
  76151. shader: string;
  76152. };
  76153. }
  76154. declare module BABYLON {
  76155. /** @hidden */
  76156. export var gridVertexShader: {
  76157. name: string;
  76158. shader: string;
  76159. };
  76160. }
  76161. declare module BABYLON {
  76162. /**
  76163. * The grid materials allows you to wrap any shape with a grid.
  76164. * Colors are customizable.
  76165. */
  76166. export class GridMaterial extends BABYLON.PushMaterial {
  76167. /**
  76168. * Main color of the grid (e.g. between lines)
  76169. */
  76170. mainColor: BABYLON.Color3;
  76171. /**
  76172. * Color of the grid lines.
  76173. */
  76174. lineColor: BABYLON.Color3;
  76175. /**
  76176. * The scale of the grid compared to unit.
  76177. */
  76178. gridRatio: number;
  76179. /**
  76180. * Allows setting an offset for the grid lines.
  76181. */
  76182. gridOffset: BABYLON.Vector3;
  76183. /**
  76184. * The frequency of thicker lines.
  76185. */
  76186. majorUnitFrequency: number;
  76187. /**
  76188. * The visibility of minor units in the grid.
  76189. */
  76190. minorUnitVisibility: number;
  76191. /**
  76192. * The grid opacity outside of the lines.
  76193. */
  76194. opacity: number;
  76195. /**
  76196. * Determine RBG output is premultiplied by alpha value.
  76197. */
  76198. preMultiplyAlpha: boolean;
  76199. private _opacityTexture;
  76200. opacityTexture: BABYLON.BaseTexture;
  76201. private _gridControl;
  76202. private _renderId;
  76203. /**
  76204. * constructor
  76205. * @param name The name given to the material in order to identify it afterwards.
  76206. * @param scene The scene the material is used in.
  76207. */
  76208. constructor(name: string, scene: BABYLON.Scene);
  76209. /**
  76210. * Returns wehter or not the grid requires alpha blending.
  76211. */
  76212. needAlphaBlending(): boolean;
  76213. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76214. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76215. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76216. /**
  76217. * Dispose the material and its associated resources.
  76218. * @param forceDisposeEffect will also dispose the used effect when true
  76219. */
  76220. dispose(forceDisposeEffect?: boolean): void;
  76221. clone(name: string): GridMaterial;
  76222. serialize(): any;
  76223. getClassName(): string;
  76224. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76225. }
  76226. }
  76227. declare module BABYLON {
  76228. /** @hidden */
  76229. export var lavaPixelShader: {
  76230. name: string;
  76231. shader: string;
  76232. };
  76233. }
  76234. declare module BABYLON {
  76235. /** @hidden */
  76236. export var lavaVertexShader: {
  76237. name: string;
  76238. shader: string;
  76239. };
  76240. }
  76241. declare module BABYLON {
  76242. export class LavaMaterial extends BABYLON.PushMaterial {
  76243. private _diffuseTexture;
  76244. diffuseTexture: BABYLON.BaseTexture;
  76245. noiseTexture: BABYLON.BaseTexture;
  76246. fogColor: BABYLON.Color3;
  76247. speed: number;
  76248. movingSpeed: number;
  76249. lowFrequencySpeed: number;
  76250. fogDensity: number;
  76251. private _lastTime;
  76252. diffuseColor: BABYLON.Color3;
  76253. private _disableLighting;
  76254. disableLighting: boolean;
  76255. private _unlit;
  76256. unlit: boolean;
  76257. private _maxSimultaneousLights;
  76258. maxSimultaneousLights: number;
  76259. private _scaledDiffuse;
  76260. private _renderId;
  76261. constructor(name: string, scene: BABYLON.Scene);
  76262. needAlphaBlending(): boolean;
  76263. needAlphaTesting(): boolean;
  76264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76267. getAnimatables(): BABYLON.IAnimatable[];
  76268. getActiveTextures(): BABYLON.BaseTexture[];
  76269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76270. dispose(forceDisposeEffect?: boolean): void;
  76271. clone(name: string): LavaMaterial;
  76272. serialize(): any;
  76273. getClassName(): string;
  76274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76275. }
  76276. }
  76277. declare module BABYLON {
  76278. /** @hidden */
  76279. export var mixPixelShader: {
  76280. name: string;
  76281. shader: string;
  76282. };
  76283. }
  76284. declare module BABYLON {
  76285. /** @hidden */
  76286. export var mixVertexShader: {
  76287. name: string;
  76288. shader: string;
  76289. };
  76290. }
  76291. declare module BABYLON {
  76292. export class MixMaterial extends BABYLON.PushMaterial {
  76293. /**
  76294. * Mix textures
  76295. */
  76296. private _mixTexture1;
  76297. mixTexture1: BABYLON.BaseTexture;
  76298. private _mixTexture2;
  76299. mixTexture2: BABYLON.BaseTexture;
  76300. /**
  76301. * Diffuse textures
  76302. */
  76303. private _diffuseTexture1;
  76304. diffuseTexture1: BABYLON.Texture;
  76305. private _diffuseTexture2;
  76306. diffuseTexture2: BABYLON.Texture;
  76307. private _diffuseTexture3;
  76308. diffuseTexture3: BABYLON.Texture;
  76309. private _diffuseTexture4;
  76310. diffuseTexture4: BABYLON.Texture;
  76311. private _diffuseTexture5;
  76312. diffuseTexture5: BABYLON.Texture;
  76313. private _diffuseTexture6;
  76314. diffuseTexture6: BABYLON.Texture;
  76315. private _diffuseTexture7;
  76316. diffuseTexture7: BABYLON.Texture;
  76317. private _diffuseTexture8;
  76318. diffuseTexture8: BABYLON.Texture;
  76319. /**
  76320. * Uniforms
  76321. */
  76322. diffuseColor: BABYLON.Color3;
  76323. specularColor: BABYLON.Color3;
  76324. specularPower: number;
  76325. private _disableLighting;
  76326. disableLighting: boolean;
  76327. private _maxSimultaneousLights;
  76328. maxSimultaneousLights: number;
  76329. private _renderId;
  76330. constructor(name: string, scene: BABYLON.Scene);
  76331. needAlphaBlending(): boolean;
  76332. needAlphaTesting(): boolean;
  76333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76336. getAnimatables(): BABYLON.IAnimatable[];
  76337. getActiveTextures(): BABYLON.BaseTexture[];
  76338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76339. dispose(forceDisposeEffect?: boolean): void;
  76340. clone(name: string): MixMaterial;
  76341. serialize(): any;
  76342. getClassName(): string;
  76343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  76344. }
  76345. }
  76346. declare module BABYLON {
  76347. /** @hidden */
  76348. export var normalPixelShader: {
  76349. name: string;
  76350. shader: string;
  76351. };
  76352. }
  76353. declare module BABYLON {
  76354. /** @hidden */
  76355. export var normalVertexShader: {
  76356. name: string;
  76357. shader: string;
  76358. };
  76359. }
  76360. declare module BABYLON {
  76361. export class NormalMaterial extends BABYLON.PushMaterial {
  76362. private _diffuseTexture;
  76363. diffuseTexture: BABYLON.BaseTexture;
  76364. diffuseColor: BABYLON.Color3;
  76365. private _disableLighting;
  76366. disableLighting: boolean;
  76367. private _maxSimultaneousLights;
  76368. maxSimultaneousLights: number;
  76369. private _renderId;
  76370. constructor(name: string, scene: BABYLON.Scene);
  76371. needAlphaBlending(): boolean;
  76372. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76373. needAlphaTesting(): boolean;
  76374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76377. getAnimatables(): BABYLON.IAnimatable[];
  76378. getActiveTextures(): BABYLON.BaseTexture[];
  76379. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76380. dispose(forceDisposeEffect?: boolean): void;
  76381. clone(name: string): NormalMaterial;
  76382. serialize(): any;
  76383. getClassName(): string;
  76384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  76385. }
  76386. }
  76387. declare module BABYLON {
  76388. /** @hidden */
  76389. export var shadowOnlyPixelShader: {
  76390. name: string;
  76391. shader: string;
  76392. };
  76393. }
  76394. declare module BABYLON {
  76395. /** @hidden */
  76396. export var shadowOnlyVertexShader: {
  76397. name: string;
  76398. shader: string;
  76399. };
  76400. }
  76401. declare module BABYLON {
  76402. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  76403. private _renderId;
  76404. private _activeLight;
  76405. constructor(name: string, scene: BABYLON.Scene);
  76406. shadowColor: BABYLON.Color3;
  76407. needAlphaBlending(): boolean;
  76408. needAlphaTesting(): boolean;
  76409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76410. get activeLight(): BABYLON.IShadowLight;
  76411. set activeLight(light: BABYLON.IShadowLight);
  76412. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76413. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76414. clone(name: string): ShadowOnlyMaterial;
  76415. serialize(): any;
  76416. getClassName(): string;
  76417. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  76418. }
  76419. }
  76420. declare module BABYLON {
  76421. /** @hidden */
  76422. export var simplePixelShader: {
  76423. name: string;
  76424. shader: string;
  76425. };
  76426. }
  76427. declare module BABYLON {
  76428. /** @hidden */
  76429. export var simpleVertexShader: {
  76430. name: string;
  76431. shader: string;
  76432. };
  76433. }
  76434. declare module BABYLON {
  76435. export class SimpleMaterial extends BABYLON.PushMaterial {
  76436. private _diffuseTexture;
  76437. diffuseTexture: BABYLON.BaseTexture;
  76438. diffuseColor: BABYLON.Color3;
  76439. private _disableLighting;
  76440. disableLighting: boolean;
  76441. private _maxSimultaneousLights;
  76442. maxSimultaneousLights: number;
  76443. private _renderId;
  76444. constructor(name: string, scene: BABYLON.Scene);
  76445. needAlphaBlending(): boolean;
  76446. needAlphaTesting(): boolean;
  76447. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76450. getAnimatables(): BABYLON.IAnimatable[];
  76451. getActiveTextures(): BABYLON.BaseTexture[];
  76452. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76453. dispose(forceDisposeEffect?: boolean): void;
  76454. clone(name: string): SimpleMaterial;
  76455. serialize(): any;
  76456. getClassName(): string;
  76457. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  76458. }
  76459. }
  76460. declare module BABYLON {
  76461. /** @hidden */
  76462. export var skyPixelShader: {
  76463. name: string;
  76464. shader: string;
  76465. };
  76466. }
  76467. declare module BABYLON {
  76468. /** @hidden */
  76469. export var skyVertexShader: {
  76470. name: string;
  76471. shader: string;
  76472. };
  76473. }
  76474. declare module BABYLON {
  76475. /**
  76476. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  76477. * @see https://doc.babylonjs.com/extensions/sky
  76478. */
  76479. export class SkyMaterial extends BABYLON.PushMaterial {
  76480. /**
  76481. * Defines the overall luminance of sky in interval ]0, 1[.
  76482. */
  76483. luminance: number;
  76484. /**
  76485. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  76486. */
  76487. turbidity: number;
  76488. /**
  76489. * Defines the sky appearance (light intensity).
  76490. */
  76491. rayleigh: number;
  76492. /**
  76493. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  76494. */
  76495. mieCoefficient: number;
  76496. /**
  76497. * Defines the amount of haze particles following the Mie scattering theory.
  76498. */
  76499. mieDirectionalG: number;
  76500. /**
  76501. * Defines the distance of the sun according to the active scene camera.
  76502. */
  76503. distance: number;
  76504. /**
  76505. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  76506. * "inclined".
  76507. */
  76508. inclination: number;
  76509. /**
  76510. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  76511. * an object direction and a reference direction.
  76512. */
  76513. azimuth: number;
  76514. /**
  76515. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  76516. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  76517. */
  76518. sunPosition: BABYLON.Vector3;
  76519. /**
  76520. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  76521. * .sunPosition property.
  76522. */
  76523. useSunPosition: boolean;
  76524. /**
  76525. * Defines an offset vector used to get a horizon offset.
  76526. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  76527. */
  76528. cameraOffset: BABYLON.Vector3;
  76529. private _cameraPosition;
  76530. private _renderId;
  76531. /**
  76532. * Instantiates a new sky material.
  76533. * This material allows to create dynamic and texture free
  76534. * effects for skyboxes by taking care of the atmosphere state.
  76535. * @see https://doc.babylonjs.com/extensions/sky
  76536. * @param name Define the name of the material in the scene
  76537. * @param scene Define the scene the material belong to
  76538. */
  76539. constructor(name: string, scene: BABYLON.Scene);
  76540. /**
  76541. * Specifies if the material will require alpha blending
  76542. * @returns a boolean specifying if alpha blending is needed
  76543. */
  76544. needAlphaBlending(): boolean;
  76545. /**
  76546. * Specifies if this material should be rendered in alpha test mode
  76547. * @returns false as the sky material doesn't need alpha testing.
  76548. */
  76549. needAlphaTesting(): boolean;
  76550. /**
  76551. * Get the texture used for alpha test purpose.
  76552. * @returns null as the sky material has no texture.
  76553. */
  76554. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76555. /**
  76556. * Get if the submesh is ready to be used and all its information available.
  76557. * Child classes can use it to update shaders
  76558. * @param mesh defines the mesh to check
  76559. * @param subMesh defines which submesh to check
  76560. * @param useInstances specifies that instances should be used
  76561. * @returns a boolean indicating that the submesh is ready or not
  76562. */
  76563. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76564. /**
  76565. * Binds the submesh to this material by preparing the effect and shader to draw
  76566. * @param world defines the world transformation matrix
  76567. * @param mesh defines the mesh containing the submesh
  76568. * @param subMesh defines the submesh to bind the material to
  76569. */
  76570. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76571. /**
  76572. * Get the list of animatables in the material.
  76573. * @returns the list of animatables object used in the material
  76574. */
  76575. getAnimatables(): BABYLON.IAnimatable[];
  76576. /**
  76577. * Disposes the material
  76578. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76579. */
  76580. dispose(forceDisposeEffect?: boolean): void;
  76581. /**
  76582. * Makes a duplicate of the material, and gives it a new name
  76583. * @param name defines the new name for the duplicated material
  76584. * @returns the cloned material
  76585. */
  76586. clone(name: string): SkyMaterial;
  76587. /**
  76588. * Serializes this material in a JSON representation
  76589. * @returns the serialized material object
  76590. */
  76591. serialize(): any;
  76592. /**
  76593. * Gets the current class name of the material e.g. "SkyMaterial"
  76594. * Mainly use in serialization.
  76595. * @returns the class name
  76596. */
  76597. getClassName(): string;
  76598. /**
  76599. * Creates a sky material from parsed material data
  76600. * @param source defines the JSON representation of the material
  76601. * @param scene defines the hosting scene
  76602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76603. * @returns a new sky material
  76604. */
  76605. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  76606. }
  76607. }
  76608. declare module BABYLON {
  76609. /** @hidden */
  76610. export var terrainPixelShader: {
  76611. name: string;
  76612. shader: string;
  76613. };
  76614. }
  76615. declare module BABYLON {
  76616. /** @hidden */
  76617. export var terrainVertexShader: {
  76618. name: string;
  76619. shader: string;
  76620. };
  76621. }
  76622. declare module BABYLON {
  76623. export class TerrainMaterial extends BABYLON.PushMaterial {
  76624. private _mixTexture;
  76625. mixTexture: BABYLON.BaseTexture;
  76626. private _diffuseTexture1;
  76627. diffuseTexture1: BABYLON.Texture;
  76628. private _diffuseTexture2;
  76629. diffuseTexture2: BABYLON.Texture;
  76630. private _diffuseTexture3;
  76631. diffuseTexture3: BABYLON.Texture;
  76632. private _bumpTexture1;
  76633. bumpTexture1: BABYLON.Texture;
  76634. private _bumpTexture2;
  76635. bumpTexture2: BABYLON.Texture;
  76636. private _bumpTexture3;
  76637. bumpTexture3: BABYLON.Texture;
  76638. diffuseColor: BABYLON.Color3;
  76639. specularColor: BABYLON.Color3;
  76640. specularPower: number;
  76641. private _disableLighting;
  76642. disableLighting: boolean;
  76643. private _maxSimultaneousLights;
  76644. maxSimultaneousLights: number;
  76645. private _renderId;
  76646. constructor(name: string, scene: BABYLON.Scene);
  76647. needAlphaBlending(): boolean;
  76648. needAlphaTesting(): boolean;
  76649. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76651. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76652. getAnimatables(): BABYLON.IAnimatable[];
  76653. getActiveTextures(): BABYLON.BaseTexture[];
  76654. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76655. dispose(forceDisposeEffect?: boolean): void;
  76656. clone(name: string): TerrainMaterial;
  76657. serialize(): any;
  76658. getClassName(): string;
  76659. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  76660. }
  76661. }
  76662. declare module BABYLON {
  76663. /** @hidden */
  76664. export var triplanarPixelShader: {
  76665. name: string;
  76666. shader: string;
  76667. };
  76668. }
  76669. declare module BABYLON {
  76670. /** @hidden */
  76671. export var triplanarVertexShader: {
  76672. name: string;
  76673. shader: string;
  76674. };
  76675. }
  76676. declare module BABYLON {
  76677. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  76678. mixTexture: BABYLON.BaseTexture;
  76679. private _diffuseTextureX;
  76680. diffuseTextureX: BABYLON.BaseTexture;
  76681. private _diffuseTextureY;
  76682. diffuseTextureY: BABYLON.BaseTexture;
  76683. private _diffuseTextureZ;
  76684. diffuseTextureZ: BABYLON.BaseTexture;
  76685. private _normalTextureX;
  76686. normalTextureX: BABYLON.BaseTexture;
  76687. private _normalTextureY;
  76688. normalTextureY: BABYLON.BaseTexture;
  76689. private _normalTextureZ;
  76690. normalTextureZ: BABYLON.BaseTexture;
  76691. tileSize: number;
  76692. diffuseColor: BABYLON.Color3;
  76693. specularColor: BABYLON.Color3;
  76694. specularPower: number;
  76695. private _disableLighting;
  76696. disableLighting: boolean;
  76697. private _maxSimultaneousLights;
  76698. maxSimultaneousLights: number;
  76699. private _renderId;
  76700. constructor(name: string, scene: BABYLON.Scene);
  76701. needAlphaBlending(): boolean;
  76702. needAlphaTesting(): boolean;
  76703. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76704. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76705. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76706. getAnimatables(): BABYLON.IAnimatable[];
  76707. getActiveTextures(): BABYLON.BaseTexture[];
  76708. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76709. dispose(forceDisposeEffect?: boolean): void;
  76710. clone(name: string): TriPlanarMaterial;
  76711. serialize(): any;
  76712. getClassName(): string;
  76713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /** @hidden */
  76718. export var waterPixelShader: {
  76719. name: string;
  76720. shader: string;
  76721. };
  76722. }
  76723. declare module BABYLON {
  76724. /** @hidden */
  76725. export var waterVertexShader: {
  76726. name: string;
  76727. shader: string;
  76728. };
  76729. }
  76730. declare module BABYLON {
  76731. export class WaterMaterial extends BABYLON.PushMaterial {
  76732. renderTargetSize: BABYLON.Vector2;
  76733. private _bumpTexture;
  76734. bumpTexture: BABYLON.BaseTexture;
  76735. diffuseColor: BABYLON.Color3;
  76736. specularColor: BABYLON.Color3;
  76737. specularPower: number;
  76738. private _disableLighting;
  76739. disableLighting: boolean;
  76740. private _maxSimultaneousLights;
  76741. maxSimultaneousLights: number;
  76742. /**
  76743. * @param {number}: Represents the wind force
  76744. */
  76745. windForce: number;
  76746. /**
  76747. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  76748. */
  76749. windDirection: BABYLON.Vector2;
  76750. /**
  76751. * @param {number}: Wave height, represents the height of the waves
  76752. */
  76753. waveHeight: number;
  76754. /**
  76755. * @param {number}: Bump height, represents the bump height related to the bump map
  76756. */
  76757. bumpHeight: number;
  76758. /**
  76759. * @param {boolean}: Add a smaller moving bump to less steady waves.
  76760. */
  76761. private _bumpSuperimpose;
  76762. bumpSuperimpose: boolean;
  76763. /**
  76764. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  76765. */
  76766. private _fresnelSeparate;
  76767. fresnelSeparate: boolean;
  76768. /**
  76769. * @param {boolean}: bump Waves modify the reflection.
  76770. */
  76771. private _bumpAffectsReflection;
  76772. bumpAffectsReflection: boolean;
  76773. /**
  76774. * @param {number}: The water color blended with the refraction (near)
  76775. */
  76776. waterColor: BABYLON.Color3;
  76777. /**
  76778. * @param {number}: The blend factor related to the water color
  76779. */
  76780. colorBlendFactor: number;
  76781. /**
  76782. * @param {number}: The water color blended with the reflection (far)
  76783. */
  76784. waterColor2: BABYLON.Color3;
  76785. /**
  76786. * @param {number}: The blend factor related to the water color (reflection, far)
  76787. */
  76788. colorBlendFactor2: number;
  76789. /**
  76790. * @param {number}: Represents the maximum length of a wave
  76791. */
  76792. waveLength: number;
  76793. /**
  76794. * @param {number}: Defines the waves speed
  76795. */
  76796. waveSpeed: number;
  76797. /**
  76798. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  76799. * will avoid calculating useless pixels in the pixel shader of the water material.
  76800. */
  76801. disableClipPlane: boolean;
  76802. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  76803. private _mesh;
  76804. private _refractionRTT;
  76805. private _reflectionRTT;
  76806. private _reflectionTransform;
  76807. private _lastTime;
  76808. private _lastDeltaTime;
  76809. private _renderId;
  76810. private _useLogarithmicDepth;
  76811. private _waitingRenderList;
  76812. private _imageProcessingConfiguration;
  76813. private _imageProcessingObserver;
  76814. /**
  76815. * Gets a boolean indicating that current material needs to register RTT
  76816. */
  76817. get hasRenderTargetTextures(): boolean;
  76818. /**
  76819. * Constructor
  76820. */
  76821. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  76822. get useLogarithmicDepth(): boolean;
  76823. set useLogarithmicDepth(value: boolean);
  76824. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76825. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76826. addToRenderList(node: any): void;
  76827. enableRenderTargets(enable: boolean): void;
  76828. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  76829. get renderTargetsEnabled(): boolean;
  76830. needAlphaBlending(): boolean;
  76831. needAlphaTesting(): boolean;
  76832. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76833. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76834. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76835. private _createRenderTargets;
  76836. getAnimatables(): BABYLON.IAnimatable[];
  76837. getActiveTextures(): BABYLON.BaseTexture[];
  76838. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76839. dispose(forceDisposeEffect?: boolean): void;
  76840. clone(name: string): WaterMaterial;
  76841. serialize(): any;
  76842. getClassName(): string;
  76843. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  76844. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  76845. }
  76846. }
  76847. declare module BABYLON {
  76848. /** @hidden */
  76849. export var asciiartPixelShader: {
  76850. name: string;
  76851. shader: string;
  76852. };
  76853. }
  76854. declare module BABYLON {
  76855. /**
  76856. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  76857. *
  76858. * It basically takes care rendering the font front the given font size to a texture.
  76859. * This is used later on in the postprocess.
  76860. */
  76861. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  76862. private _font;
  76863. private _text;
  76864. private _charSize;
  76865. /**
  76866. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76867. */
  76868. get charSize(): number;
  76869. /**
  76870. * Create a new instance of the Ascii Art FontTexture class
  76871. * @param name the name of the texture
  76872. * @param font the font to use, use the W3C CSS notation
  76873. * @param text the caracter set to use in the rendering.
  76874. * @param scene the scene that owns the texture
  76875. */
  76876. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76877. /**
  76878. * Gets the max char width of a font.
  76879. * @param font the font to use, use the W3C CSS notation
  76880. * @return the max char width
  76881. */
  76882. private getFontWidth;
  76883. /**
  76884. * Gets the max char height of a font.
  76885. * @param font the font to use, use the W3C CSS notation
  76886. * @return the max char height
  76887. */
  76888. private getFontHeight;
  76889. /**
  76890. * Clones the current AsciiArtTexture.
  76891. * @return the clone of the texture.
  76892. */
  76893. clone(): AsciiArtFontTexture;
  76894. /**
  76895. * Parses a json object representing the texture and returns an instance of it.
  76896. * @param source the source JSON representation
  76897. * @param scene the scene to create the texture for
  76898. * @return the parsed texture
  76899. */
  76900. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  76901. }
  76902. /**
  76903. * Option available in the Ascii Art Post Process.
  76904. */
  76905. export interface IAsciiArtPostProcessOptions {
  76906. /**
  76907. * The font to use following the w3c font definition.
  76908. */
  76909. font?: string;
  76910. /**
  76911. * The character set to use in the postprocess.
  76912. */
  76913. characterSet?: string;
  76914. /**
  76915. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76916. * This number is defined between 0 and 1;
  76917. */
  76918. mixToTile?: number;
  76919. /**
  76920. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76921. * This number is defined between 0 and 1;
  76922. */
  76923. mixToNormal?: number;
  76924. }
  76925. /**
  76926. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  76927. *
  76928. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76929. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  76930. */
  76931. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  76932. /**
  76933. * The font texture used to render the char in the post process.
  76934. */
  76935. private _asciiArtFontTexture;
  76936. /**
  76937. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76938. * This number is defined between 0 and 1;
  76939. */
  76940. mixToTile: number;
  76941. /**
  76942. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76943. * This number is defined between 0 and 1;
  76944. */
  76945. mixToNormal: number;
  76946. /**
  76947. * Instantiates a new Ascii Art Post Process.
  76948. * @param name the name to give to the postprocess
  76949. * @camera the camera to apply the post process to.
  76950. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76951. */
  76952. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76953. }
  76954. }
  76955. declare module BABYLON {
  76956. /** @hidden */
  76957. export var digitalrainPixelShader: {
  76958. name: string;
  76959. shader: string;
  76960. };
  76961. }
  76962. declare module BABYLON {
  76963. /**
  76964. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76965. *
  76966. * It basically takes care rendering the font front the given font size to a texture.
  76967. * This is used later on in the postprocess.
  76968. */
  76969. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76970. private _font;
  76971. private _text;
  76972. private _charSize;
  76973. /**
  76974. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76975. */
  76976. get charSize(): number;
  76977. /**
  76978. * Create a new instance of the Digital Rain FontTexture class
  76979. * @param name the name of the texture
  76980. * @param font the font to use, use the W3C CSS notation
  76981. * @param text the caracter set to use in the rendering.
  76982. * @param scene the scene that owns the texture
  76983. */
  76984. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76985. /**
  76986. * Gets the max char width of a font.
  76987. * @param font the font to use, use the W3C CSS notation
  76988. * @return the max char width
  76989. */
  76990. private getFontWidth;
  76991. /**
  76992. * Gets the max char height of a font.
  76993. * @param font the font to use, use the W3C CSS notation
  76994. * @return the max char height
  76995. */
  76996. private getFontHeight;
  76997. /**
  76998. * Clones the current DigitalRainFontTexture.
  76999. * @return the clone of the texture.
  77000. */
  77001. clone(): DigitalRainFontTexture;
  77002. /**
  77003. * Parses a json object representing the texture and returns an instance of it.
  77004. * @param source the source JSON representation
  77005. * @param scene the scene to create the texture for
  77006. * @return the parsed texture
  77007. */
  77008. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  77009. }
  77010. /**
  77011. * Option available in the Digital Rain Post Process.
  77012. */
  77013. export interface IDigitalRainPostProcessOptions {
  77014. /**
  77015. * The font to use following the w3c font definition.
  77016. */
  77017. font?: string;
  77018. /**
  77019. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77020. * This number is defined between 0 and 1;
  77021. */
  77022. mixToTile?: number;
  77023. /**
  77024. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77025. * This number is defined between 0 and 1;
  77026. */
  77027. mixToNormal?: number;
  77028. }
  77029. /**
  77030. * DigitalRainPostProcess helps rendering everithing in digital rain.
  77031. *
  77032. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77033. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  77034. */
  77035. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  77036. /**
  77037. * The font texture used to render the char in the post process.
  77038. */
  77039. private _digitalRainFontTexture;
  77040. /**
  77041. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77042. * This number is defined between 0 and 1;
  77043. */
  77044. mixToTile: number;
  77045. /**
  77046. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77047. * This number is defined between 0 and 1;
  77048. */
  77049. mixToNormal: number;
  77050. /**
  77051. * Instantiates a new Digital Rain Post Process.
  77052. * @param name the name to give to the postprocess
  77053. * @camera the camera to apply the post process to.
  77054. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  77055. */
  77056. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  77057. }
  77058. }
  77059. declare module BABYLON {
  77060. /** @hidden */
  77061. export var oceanPostProcessPixelShader: {
  77062. name: string;
  77063. shader: string;
  77064. };
  77065. }
  77066. declare module BABYLON {
  77067. /**
  77068. * Option available in the Ocean Post Process.
  77069. */
  77070. export interface IOceanPostProcessOptions {
  77071. /**
  77072. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77073. */
  77074. reflectionSize?: number | {
  77075. width: number;
  77076. height: number;
  77077. } | {
  77078. ratio: number;
  77079. };
  77080. /**
  77081. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77082. */
  77083. refractionSize?: number | {
  77084. width: number;
  77085. height: number;
  77086. } | {
  77087. ratio: number;
  77088. };
  77089. }
  77090. /**
  77091. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  77092. *
  77093. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77094. * Example usage:
  77095. * var pp = new OceanPostProcess("myOcean", camera);
  77096. * pp.reflectionEnabled = true;
  77097. * pp.refractionEnabled = true;
  77098. */
  77099. export class OceanPostProcess extends BABYLON.PostProcess {
  77100. /**
  77101. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  77102. */
  77103. get reflectionEnabled(): boolean;
  77104. /**
  77105. * Sets weither or not the real-time reflection is enabled on the ocean.
  77106. * Is set to true, the reflection mirror texture will be used as reflection texture.
  77107. */
  77108. set reflectionEnabled(enabled: boolean);
  77109. /**
  77110. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  77111. */
  77112. get refractionEnabled(): boolean;
  77113. /**
  77114. * Sets weither or not the real-time refraction is enabled on the ocean.
  77115. * Is set to true, the refraction render target texture will be used as refraction texture.
  77116. */
  77117. set refractionEnabled(enabled: boolean);
  77118. /**
  77119. * Gets wether or not the post-processes is supported by the running hardware.
  77120. * This requires draw buffer supports.
  77121. */
  77122. get isSupported(): boolean;
  77123. /**
  77124. * This is the reflection mirror texture used to display reflections on the ocean.
  77125. * By default, render list is empty.
  77126. */
  77127. reflectionTexture: BABYLON.MirrorTexture;
  77128. /**
  77129. * This is the refraction render target texture used to display refraction on the ocean.
  77130. * By default, render list is empty.
  77131. */
  77132. refractionTexture: BABYLON.RenderTargetTexture;
  77133. private _time;
  77134. private _cameraRotation;
  77135. private _cameraViewMatrix;
  77136. private _reflectionEnabled;
  77137. private _refractionEnabled;
  77138. private _geometryRenderer;
  77139. /**
  77140. * Instantiates a new Ocean Post Process.
  77141. * @param name the name to give to the postprocess.
  77142. * @camera the camera to apply the post process to.
  77143. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77144. */
  77145. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77146. /**
  77147. * Returns the appropriate defines according to the current configuration.
  77148. */
  77149. private _getDefines;
  77150. /**
  77151. * Computes the current camera rotation as the shader requires a camera rotation.
  77152. */
  77153. private _computeCameraRotation;
  77154. }
  77155. }
  77156. declare module BABYLON {
  77157. /** @hidden */
  77158. export var brickProceduralTexturePixelShader: {
  77159. name: string;
  77160. shader: string;
  77161. };
  77162. }
  77163. declare module BABYLON {
  77164. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77165. private _numberOfBricksHeight;
  77166. private _numberOfBricksWidth;
  77167. private _jointColor;
  77168. private _brickColor;
  77169. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77170. updateShaderUniforms(): void;
  77171. get numberOfBricksHeight(): number;
  77172. set numberOfBricksHeight(value: number);
  77173. get numberOfBricksWidth(): number;
  77174. set numberOfBricksWidth(value: number);
  77175. get jointColor(): BABYLON.Color3;
  77176. set jointColor(value: BABYLON.Color3);
  77177. get brickColor(): BABYLON.Color3;
  77178. set brickColor(value: BABYLON.Color3);
  77179. /**
  77180. * Serializes this brick procedural texture
  77181. * @returns a serialized brick procedural texture object
  77182. */
  77183. serialize(): any;
  77184. /**
  77185. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77186. * @param parsedTexture defines parsed texture data
  77187. * @param scene defines the current scene
  77188. * @param rootUrl defines the root URL containing brick procedural texture information
  77189. * @returns a parsed Brick Procedural BABYLON.Texture
  77190. */
  77191. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77192. }
  77193. }
  77194. declare module BABYLON {
  77195. /** @hidden */
  77196. export var cloudProceduralTexturePixelShader: {
  77197. name: string;
  77198. shader: string;
  77199. };
  77200. }
  77201. declare module BABYLON {
  77202. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77203. private _skyColor;
  77204. private _cloudColor;
  77205. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77206. updateShaderUniforms(): void;
  77207. get skyColor(): BABYLON.Color4;
  77208. set skyColor(value: BABYLON.Color4);
  77209. get cloudColor(): BABYLON.Color4;
  77210. set cloudColor(value: BABYLON.Color4);
  77211. /**
  77212. * Serializes this cloud procedural texture
  77213. * @returns a serialized cloud procedural texture object
  77214. */
  77215. serialize(): any;
  77216. /**
  77217. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77218. * @param parsedTexture defines parsed texture data
  77219. * @param scene defines the current scene
  77220. * @param rootUrl defines the root URL containing cloud procedural texture information
  77221. * @returns a parsed Cloud Procedural BABYLON.Texture
  77222. */
  77223. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77224. }
  77225. }
  77226. declare module BABYLON {
  77227. /** @hidden */
  77228. export var fireProceduralTexturePixelShader: {
  77229. name: string;
  77230. shader: string;
  77231. };
  77232. }
  77233. declare module BABYLON {
  77234. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77235. private _time;
  77236. private _speed;
  77237. private _autoGenerateTime;
  77238. private _fireColors;
  77239. private _alphaThreshold;
  77240. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77241. updateShaderUniforms(): void;
  77242. render(useCameraPostProcess?: boolean): void;
  77243. static get PurpleFireColors(): BABYLON.Color3[];
  77244. static get GreenFireColors(): BABYLON.Color3[];
  77245. static get RedFireColors(): BABYLON.Color3[];
  77246. static get BlueFireColors(): BABYLON.Color3[];
  77247. get autoGenerateTime(): boolean;
  77248. set autoGenerateTime(value: boolean);
  77249. get fireColors(): BABYLON.Color3[];
  77250. set fireColors(value: BABYLON.Color3[]);
  77251. get time(): number;
  77252. set time(value: number);
  77253. get speed(): BABYLON.Vector2;
  77254. set speed(value: BABYLON.Vector2);
  77255. get alphaThreshold(): number;
  77256. set alphaThreshold(value: number);
  77257. /**
  77258. * Serializes this fire procedural texture
  77259. * @returns a serialized fire procedural texture object
  77260. */
  77261. serialize(): any;
  77262. /**
  77263. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77264. * @param parsedTexture defines parsed texture data
  77265. * @param scene defines the current scene
  77266. * @param rootUrl defines the root URL containing fire procedural texture information
  77267. * @returns a parsed Fire Procedural BABYLON.Texture
  77268. */
  77269. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77270. }
  77271. }
  77272. declare module BABYLON {
  77273. /** @hidden */
  77274. export var grassProceduralTexturePixelShader: {
  77275. name: string;
  77276. shader: string;
  77277. };
  77278. }
  77279. declare module BABYLON {
  77280. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77281. private _grassColors;
  77282. private _groundColor;
  77283. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77284. updateShaderUniforms(): void;
  77285. get grassColors(): BABYLON.Color3[];
  77286. set grassColors(value: BABYLON.Color3[]);
  77287. get groundColor(): BABYLON.Color3;
  77288. set groundColor(value: BABYLON.Color3);
  77289. /**
  77290. * Serializes this grass procedural texture
  77291. * @returns a serialized grass procedural texture object
  77292. */
  77293. serialize(): any;
  77294. /**
  77295. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77296. * @param parsedTexture defines parsed texture data
  77297. * @param scene defines the current scene
  77298. * @param rootUrl defines the root URL containing grass procedural texture information
  77299. * @returns a parsed Grass Procedural BABYLON.Texture
  77300. */
  77301. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77302. }
  77303. }
  77304. declare module BABYLON {
  77305. /** @hidden */
  77306. export var marbleProceduralTexturePixelShader: {
  77307. name: string;
  77308. shader: string;
  77309. };
  77310. }
  77311. declare module BABYLON {
  77312. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77313. private _numberOfTilesHeight;
  77314. private _numberOfTilesWidth;
  77315. private _amplitude;
  77316. private _jointColor;
  77317. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77318. updateShaderUniforms(): void;
  77319. get numberOfTilesHeight(): number;
  77320. set numberOfTilesHeight(value: number);
  77321. get amplitude(): number;
  77322. set amplitude(value: number);
  77323. get numberOfTilesWidth(): number;
  77324. set numberOfTilesWidth(value: number);
  77325. get jointColor(): BABYLON.Color3;
  77326. set jointColor(value: BABYLON.Color3);
  77327. /**
  77328. * Serializes this marble procedural texture
  77329. * @returns a serialized marble procedural texture object
  77330. */
  77331. serialize(): any;
  77332. /**
  77333. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  77334. * @param parsedTexture defines parsed texture data
  77335. * @param scene defines the current scene
  77336. * @param rootUrl defines the root URL containing marble procedural texture information
  77337. * @returns a parsed Marble Procedural BABYLON.Texture
  77338. */
  77339. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  77340. }
  77341. }
  77342. declare module BABYLON {
  77343. /** @hidden */
  77344. export var normalMapProceduralTexturePixelShader: {
  77345. name: string;
  77346. shader: string;
  77347. };
  77348. }
  77349. declare module BABYLON {
  77350. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  77351. private _baseTexture;
  77352. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77353. updateShaderUniforms(): void;
  77354. render(useCameraPostProcess?: boolean): void;
  77355. resize(size: any, generateMipMaps: any): void;
  77356. get baseTexture(): BABYLON.Texture;
  77357. set baseTexture(texture: BABYLON.Texture);
  77358. /**
  77359. * Serializes this normal map procedural texture
  77360. * @returns a serialized normal map procedural texture object
  77361. */
  77362. serialize(): any;
  77363. /**
  77364. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  77365. * @param parsedTexture defines parsed texture data
  77366. * @param scene defines the current scene
  77367. * @param rootUrl defines the root URL containing normal map procedural texture information
  77368. * @returns a parsed Normal Map Procedural BABYLON.Texture
  77369. */
  77370. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  77371. }
  77372. }
  77373. declare module BABYLON {
  77374. /** @hidden */
  77375. export var perlinNoiseProceduralTexturePixelShader: {
  77376. name: string;
  77377. shader: string;
  77378. };
  77379. }
  77380. declare module BABYLON {
  77381. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  77382. time: number;
  77383. timeScale: number;
  77384. translationSpeed: number;
  77385. private _currentTranslation;
  77386. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77387. updateShaderUniforms(): void;
  77388. render(useCameraPostProcess?: boolean): void;
  77389. resize(size: any, generateMipMaps: any): void;
  77390. /**
  77391. * Serializes this perlin noise procedural texture
  77392. * @returns a serialized perlin noise procedural texture object
  77393. */
  77394. serialize(): any;
  77395. /**
  77396. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  77397. * @param parsedTexture defines parsed texture data
  77398. * @param scene defines the current scene
  77399. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  77400. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  77401. */
  77402. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  77403. }
  77404. }
  77405. declare module BABYLON {
  77406. /** @hidden */
  77407. export var roadProceduralTexturePixelShader: {
  77408. name: string;
  77409. shader: string;
  77410. };
  77411. }
  77412. declare module BABYLON {
  77413. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  77414. private _roadColor;
  77415. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77416. updateShaderUniforms(): void;
  77417. get roadColor(): BABYLON.Color3;
  77418. set roadColor(value: BABYLON.Color3);
  77419. /**
  77420. * Serializes this road procedural texture
  77421. * @returns a serialized road procedural texture object
  77422. */
  77423. serialize(): any;
  77424. /**
  77425. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  77426. * @param parsedTexture defines parsed texture data
  77427. * @param scene defines the current scene
  77428. * @param rootUrl defines the root URL containing road procedural texture information
  77429. * @returns a parsed Road Procedural BABYLON.Texture
  77430. */
  77431. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  77432. }
  77433. }
  77434. declare module BABYLON {
  77435. /** @hidden */
  77436. export var starfieldProceduralTexturePixelShader: {
  77437. name: string;
  77438. shader: string;
  77439. };
  77440. }
  77441. declare module BABYLON {
  77442. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  77443. private _time;
  77444. private _alpha;
  77445. private _beta;
  77446. private _zoom;
  77447. private _formuparam;
  77448. private _stepsize;
  77449. private _tile;
  77450. private _brightness;
  77451. private _darkmatter;
  77452. private _distfading;
  77453. private _saturation;
  77454. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77455. updateShaderUniforms(): void;
  77456. get time(): number;
  77457. set time(value: number);
  77458. get alpha(): number;
  77459. set alpha(value: number);
  77460. get beta(): number;
  77461. set beta(value: number);
  77462. get formuparam(): number;
  77463. set formuparam(value: number);
  77464. get stepsize(): number;
  77465. set stepsize(value: number);
  77466. get zoom(): number;
  77467. set zoom(value: number);
  77468. get tile(): number;
  77469. set tile(value: number);
  77470. get brightness(): number;
  77471. set brightness(value: number);
  77472. get darkmatter(): number;
  77473. set darkmatter(value: number);
  77474. get distfading(): number;
  77475. set distfading(value: number);
  77476. get saturation(): number;
  77477. set saturation(value: number);
  77478. /**
  77479. * Serializes this starfield procedural texture
  77480. * @returns a serialized starfield procedural texture object
  77481. */
  77482. serialize(): any;
  77483. /**
  77484. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  77485. * @param parsedTexture defines parsed texture data
  77486. * @param scene defines the current scene
  77487. * @param rootUrl defines the root URL containing startfield procedural texture information
  77488. * @returns a parsed Starfield Procedural BABYLON.Texture
  77489. */
  77490. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  77491. }
  77492. }
  77493. declare module BABYLON {
  77494. /** @hidden */
  77495. export var woodProceduralTexturePixelShader: {
  77496. name: string;
  77497. shader: string;
  77498. };
  77499. }
  77500. declare module BABYLON {
  77501. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  77502. private _ampScale;
  77503. private _woodColor;
  77504. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77505. updateShaderUniforms(): void;
  77506. get ampScale(): number;
  77507. set ampScale(value: number);
  77508. get woodColor(): BABYLON.Color3;
  77509. set woodColor(value: BABYLON.Color3);
  77510. /**
  77511. * Serializes this wood procedural texture
  77512. * @returns a serialized wood procedural texture object
  77513. */
  77514. serialize(): any;
  77515. /**
  77516. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  77517. * @param parsedTexture defines parsed texture data
  77518. * @param scene defines the current scene
  77519. * @param rootUrl defines the root URL containing wood procedural texture information
  77520. * @returns a parsed Wood Procedural BABYLON.Texture
  77521. */
  77522. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  77523. }
  77524. }